OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |