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

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

Issue 1685093002: Fix bug with TaskQueueSelector and blocked queues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UAF Created 4 years, 10 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
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/base/task_queue_manager.h" 5 #include "components/scheduler/base/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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // pump-after-wakeup queue. 188 // pump-after-wakeup queue.
189 UpdateWorkQueues(false, nullptr); 189 UpdateWorkQueues(false, nullptr);
190 190
191 internal::TaskQueueImpl::Task previous_task; 191 internal::TaskQueueImpl::Task previous_task;
192 for (int i = 0; i < work_batch_size_; i++) { 192 for (int i = 0; i < work_batch_size_; i++) {
193 internal::WorkQueue* work_queue; 193 internal::WorkQueue* work_queue;
194 if (!SelectWorkQueueToService(&work_queue)) { 194 if (!SelectWorkQueueToService(&work_queue)) {
195 break; 195 break;
196 } 196 }
197 197
198 bool should_trigger_wakeup = work_queue->task_queue()->wakeup_policy() ==
199 TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES;
198 switch (ProcessTaskFromWorkQueue(work_queue, &previous_task)) { 200 switch (ProcessTaskFromWorkQueue(work_queue, &previous_task)) {
199 case ProcessTaskResult::DEFERRED: 201 case ProcessTaskResult::DEFERRED:
200 // If a task was deferred, try again with another task. Note that this 202 // If a task was deferred, try again with another task. Note that this
201 // means deferred tasks (i.e. non-nestable tasks) will never trigger 203 // means deferred tasks (i.e. non-nestable tasks) will never trigger
202 // queue wake-ups. 204 // queue wake-ups.
203 continue; 205 continue;
204 case ProcessTaskResult::EXECUTED: 206 case ProcessTaskResult::EXECUTED:
205 break; 207 break;
206 case ProcessTaskResult::TASK_QUEUE_MANAGER_DELETED: 208 case ProcessTaskResult::TASK_QUEUE_MANAGER_DELETED:
207 return; // The TaskQueueManager got deleted, we must bail out. 209 return; // The TaskQueueManager got deleted, we must bail out.
208 } 210 }
209 bool should_trigger_wakeup = work_queue->task_queue()->wakeup_policy() == 211 work_queue = nullptr; // The queue may have been unregistered.
210 TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES; 212
211 UpdateWorkQueues(should_trigger_wakeup, &previous_task); 213 UpdateWorkQueues(should_trigger_wakeup, &previous_task);
212 214
213 // Only run a single task per batch in nested run loops so that we can 215 // Only run a single task per batch in nested run loops so that we can
214 // properly exit the nested loop when someone calls RunLoop::Quit(). 216 // properly exit the nested loop when someone calls RunLoop::Quit().
215 if (delegate_->IsNested()) 217 if (delegate_->IsNested())
216 break; 218 break;
217 } 219 }
218 220
219 // TODO(alexclarke): Consider refactoring the above loop to terminate only 221 // TODO(alexclarke): Consider refactoring the above loop to terminate only
220 // when there's no more work left to be done, rather than posting a 222 // when there's no more work left to be done, rather than posting a
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 internal::WorkQueue* work_queue) { 406 internal::WorkQueue* work_queue) {
405 DCHECK(main_thread_checker_.CalledOnValidThread()); 407 DCHECK(main_thread_checker_.CalledOnValidThread());
406 DCHECK(!work_queue->Empty()); 408 DCHECK(!work_queue->Empty());
407 if (observer_) { 409 if (observer_) {
408 observer_->OnTriedToExecuteBlockedTask(*work_queue->task_queue(), 410 observer_->OnTriedToExecuteBlockedTask(*work_queue->task_queue(),
409 *work_queue->GetFrontTask()); 411 *work_queue->GetFrontTask());
410 } 412 }
411 } 413 }
412 414
413 } // namespace scheduler 415 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/base/task_queue_impl.cc ('k') | components/scheduler/base/task_queue_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698