Skip to content

Commit

Permalink
Add a sanity DCHECK to TimeDomain::ScheduleDelayedWork
Browse files Browse the repository at this point in the history
This patch removes TimeNomain::MigrateQueue since it's now superfluous.

Was part of https://codereview.chromium.org/2546423002/

BUG=578176

Review-Url: https://codereview.chromium.org/2651003002
Cr-Commit-Position: refs/heads/master@{#446123}
  • Loading branch information
alexclarke authored and Commit bot committed Jan 25, 2017
1 parent 63f513b commit c0ec080
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,16 @@ void TaskQueueImpl::SetTimeDomain(TimeDomain* time_domain) {

any_thread().time_domain = time_domain;
}
// We rely here on TimeDomain::MigrateQueue being thread-safe to use with
// TimeDomain::Register.
main_thread_only().time_domain->MigrateQueue(this, time_domain);

main_thread_only().time_domain->UnregisterQueue(this);
main_thread_only().time_domain = time_domain;
time_domain->RegisterQueue(this);

if (!main_thread_only().delayed_incoming_queue.empty()) {
time_domain->ScheduleDelayedWork(
this, main_thread_only().delayed_incoming_queue.top().delayed_run_time,
time_domain->Now());
}
}

TimeDomain* TaskQueueImpl::GetTimeDomain() const {
Expand Down
22 changes: 1 addition & 21 deletions third_party/WebKit/Source/platform/scheduler/base/time_domain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,11 @@ void TimeDomain::UnregisterQueue(internal::TaskQueueImpl* queue) {
CancelDelayedWork(queue);
}

void TimeDomain::MigrateQueue(internal::TaskQueueImpl* queue,
TimeDomain* destination_time_domain) {
DCHECK(main_thread_checker_.CalledOnValidThread());
DCHECK_EQ(queue->GetTimeDomain(), this);
DCHECK(destination_time_domain);

// If no wakeup has been requested then bail out.
if (!queue->heap_handle().IsValid())
return;

base::TimeTicks wake_up_time = queue->scheduled_time_domain_wakeup();
DCHECK_NE(wake_up_time, base::TimeTicks());

// O(log n)
delayed_wakeup_queue_.erase(queue->heap_handle());

base::TimeTicks destination_now = destination_time_domain->Now();
destination_time_domain->ScheduleDelayedWork(queue, wake_up_time,
destination_now);
}

void TimeDomain::ScheduleDelayedWork(internal::TaskQueueImpl* queue,
base::TimeTicks delayed_run_time,
base::TimeTicks now) {
DCHECK(main_thread_checker_.CalledOnValidThread());
DCHECK_EQ(queue->GetTimeDomain(), this);
// We only want to store a single wakeup per queue, so we need to remove any
// previously registered wake up for |queue|.
if (queue->heap_handle().IsValid()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ class BLINK_PLATFORM_EXPORT TimeDomain {

void AsValueInto(base::trace_event::TracedValue* state) const;

// Migrates |queue| from this time domain to |destination_time_domain|.
// Main-thread only.
void MigrateQueue(internal::TaskQueueImpl* queue,
TimeDomain* destination_time_domain);

// If there is a scheduled delayed task, |out_task_queue| is set to the queue
// the next task was posted to and it returns true. Returns false otherwise.
bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const;
Expand Down

0 comments on commit c0ec080

Please sign in to comment.