Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc |
| diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc b/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc |
| index 350cf27aeda21ebf609921dd9dda65315bc0e88f..9911d002fa309a9d5b50b4baa83ef821344cd6a2 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc |
| +++ b/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc |
| @@ -315,27 +315,42 @@ TaskQueueThrottler::~TaskQueueThrottler() { |
| } |
| void TaskQueueThrottler::SetQueueEnabled(TaskQueue* task_queue, bool enabled) { |
| + // Both the TaskQueueThrottler and other systems want to enable and disable |
| + // task queues. The policy we've adopted to deal with this is: |
| + // |
| + // A task queue is disabled if either the TaskQueueThrottler or the caller |
| + // vote to disable it. |
| + // |
| + // A task queue is enabled only if both the TaskQueueThrottler and the caller |
| + // vote to enable it. |
| TaskQueueMap::iterator find_it = queue_details_.find(task_queue); |
| + // If TaskQueueThrottler does not know about this queue, just call |
| + // SetQueueEnabled directly. |
| if (find_it == queue_details_.end()) { |
| task_queue->SetQueueEnabled(enabled); |
| return; |
| } |
| + // Remember the caller's preference so we know what to do when the task queue |
| + // isn't throttled, or has budget to run. |
| find_it->second.enabled = enabled; |
| + // If this queue is not throttled by task queue throttler, just call |
| + // SetQueueEnabled directly. |
| if (!find_it->second.IsThrottled()) { |
|
Sami
2016/11/24 16:05:49
I think this needs a rebase; IsThrottled() isn't t
altimin
2016/11/24 16:09:36
It does indeed, thanks.
|
| task_queue->SetQueueEnabled(enabled); |
| return; |
| } |
| - // We don't enable the queue here because it's throttled and there might be |
| - // tasks in it's work queue that would execute immediatly rather than after |
| - // PumpThrottledTasks runs. |
| - if (!enabled) { |
| - task_queue->SetQueueEnabled(false); |
| + if (enabled) { |
| + // If the task queue is throttled and we want to enable it, we can't |
| + // do it immediately due to task alignment requirement and we should |
| + // schedule a call to PumpThrottledTasks. |
| MaybeSchedulePumpQueue(FROM_HERE, tick_clock_->NowTicks(), task_queue, |
| base::nullopt); |
| + } else { |
| + task_queue->SetQueueEnabled(false); |
| } |
| } |