Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| index 762f079bfccb32600c6b51b777f00741c92f19d8..5111bd33c8754a62d74a7f16ba066b80de79e0d4 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc |
| @@ -276,11 +276,14 @@ void TaskQueueImpl::PushOntoDelayedIncomingQueueFromMainThread( |
| main_thread_only().delayed_incoming_queue.push(std::move(pending_task)); |
| // If |pending_task| is at the head of the queue, then make sure a wakeup |
| - // is requested. |
| - if (main_thread_only().delayed_incoming_queue.top().delayed_run_time == |
| - delayed_run_time) { |
| - main_thread_only().time_domain->ScheduleDelayedWork( |
| - this, pending_task.delayed_run_time, now); |
| + // is requested if the queue is enabled. Note we still want to schedule a |
| + // wakeup even if blocked by a fence, because we'd break throttling logic |
| + // otherwise. |
| + base::TimeTicks next_delayed_task = |
| + main_thread_only().delayed_incoming_queue.top().delayed_run_time; |
| + if (next_delayed_task == delayed_run_time && IsQueueEnabled()) { |
| + main_thread_only().time_domain->ScheduleDelayedWork(this, delayed_run_time, |
| + now); |
| } |
| TraceQueueSize(false); |
| @@ -404,7 +407,7 @@ bool TaskQueueImpl::HasPendingImmediateWork() const { |
| } |
| base::Optional<base::TimeTicks> TaskQueueImpl::GetNextScheduledWakeUp() { |
| - if (main_thread_only().delayed_incoming_queue.empty()) |
| + if (main_thread_only().delayed_incoming_queue.empty() || !IsQueueEnabled()) |
|
Sami
2017/02/10 12:49:43
Should we do this at call site to avoid making thi
altimin
2017/02/10 13:05:32
I'm, for one, in favour of this approach: if the q
alex clarke (OOO till 29th)
2017/02/10 14:19:29
As discussed offline, this change is making the fu
|
| return base::nullopt; |
| return main_thread_only().delayed_incoming_queue.top().delayed_run_time; |
| @@ -799,10 +802,18 @@ void TaskQueueImpl::EnableOrDisableWithSelector(bool enable) { |
| return; |
| if (enable) { |
| + if (!main_thread_only().delayed_incoming_queue.empty()) { |
| + main_thread_only().time_domain->ScheduleDelayedWork( |
| + this, |
| + main_thread_only().delayed_incoming_queue.top().delayed_run_time, |
| + main_thread_only().time_domain->Now()); |
| + } |
| // Note the selector calls TaskQueueManager::OnTaskQueueEnabled which posts |
| // a DoWork if needed. |
| main_thread_only().task_queue_manager->selector_.EnableQueue(this); |
| } else { |
| + if (!main_thread_only().delayed_incoming_queue.empty()) |
| + main_thread_only().time_domain->CancelDelayedWork(this); |
| main_thread_only().task_queue_manager->selector_.DisableQueue(this); |
| } |
| } |