Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1064)

Unified Diff: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc

Issue 2528963002: [scheduler] Fix TaskQueueThrottler::SetQueueEnabled logic. (Closed)
Patch Set: Rebased Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5e6877f801c4a99834f5ed47f50f0ffcac4d9fdc..a88e4b374e34dbcf307b05ad40182ae80246861f 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,13 +315,25 @@ 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 (!IsThrottled(task_queue)) {
@@ -329,13 +341,14 @@ void TaskQueueThrottler::SetQueueEnabled(TaskQueue* task_queue, bool 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);
}
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698