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

Side by Side Diff: components/scheduler/child/task_queue_manager.cc

Issue 1252143002: scheduler: Don't run multiple tasks per batch in a nested run loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix. Created 5 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/scheduler/child/task_queue_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/scheduler/child/task_queue_manager.h" 5 #include "components/scheduler/child/task_queue_manager.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // already pending, so it is safe to call it in a loop. 148 // already pending, so it is safe to call it in a loop.
149 MaybePostDoWorkOnMainRunner(); 149 MaybePostDoWorkOnMainRunner();
150 150
151 if (ProcessTaskFromWorkQueue(queue, &previous_task)) 151 if (ProcessTaskFromWorkQueue(queue, &previous_task))
152 return; // The TaskQueueManager got deleted, we must bail out. 152 return; // The TaskQueueManager got deleted, we must bail out.
153 153
154 bool should_trigger_wakeup = queue->wakeup_policy() == 154 bool should_trigger_wakeup = queue->wakeup_policy() ==
155 TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES; 155 TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES;
156 if (!UpdateWorkQueues(should_trigger_wakeup, &previous_task)) 156 if (!UpdateWorkQueues(should_trigger_wakeup, &previous_task))
157 return; 157 return;
158
159 // Only run a single task per batch in nested run loops so that we can
160 // properly exit the nested loop when someone calls RunLoop::Quit().
161 if (main_task_runner_->IsNested())
162 break;
158 } 163 }
159 } 164 }
160 165
161 bool TaskQueueManager::SelectQueueToService( 166 bool TaskQueueManager::SelectQueueToService(
162 internal::TaskQueueImpl** out_queue) { 167 internal::TaskQueueImpl** out_queue) {
163 bool should_run = selector_.SelectQueueToService(out_queue); 168 bool should_run = selector_.SelectQueueToService(out_queue);
164 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 169 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
165 disabled_by_default_tracing_category_, "TaskQueueManager", this, 170 disabled_by_default_tracing_category_, "TaskQueueManager", this,
166 AsValueWithSelectorResult(should_run, *out_queue)); 171 AsValueWithSelectorResult(should_run, *out_queue));
167 return should_run; 172 return should_run;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 state->SetString("selected_queue", selected_queue->GetName()); 280 state->SetString("selected_queue", selected_queue->GetName());
276 return state; 281 return state;
277 } 282 }
278 283
279 void TaskQueueManager::OnTaskQueueEnabled() { 284 void TaskQueueManager::OnTaskQueueEnabled() {
280 DCHECK(main_thread_checker_.CalledOnValidThread()); 285 DCHECK(main_thread_checker_.CalledOnValidThread());
281 MaybePostDoWorkOnMainRunner(); 286 MaybePostDoWorkOnMainRunner();
282 } 287 }
283 288
284 } // namespace scheduler 289 } // namespace scheduler
OLDNEW
« no previous file with comments | « no previous file | components/scheduler/child/task_queue_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698