Chromium Code Reviews

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

Issue 1287333002: Revert of [scheduler]: Fix a bug with non-nestable tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« 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 265 matching lines...)
276 internal::TaskQueueImpl::Task pending_task = queue->TakeTaskFromWorkQueue(); 276 internal::TaskQueueImpl::Task pending_task = queue->TakeTaskFromWorkQueue();
277 277
278 if (queue->GetQuiescenceMonitored()) 278 if (queue->GetQuiescenceMonitored())
279 task_was_run_on_quiescence_monitored_queue_ = true; 279 task_was_run_on_quiescence_monitored_queue_ = true;
280 280
281 if (!pending_task.nestable && main_task_runner_->IsNested()) { 281 if (!pending_task.nestable && main_task_runner_->IsNested()) {
282 // Defer non-nestable work to the main task runner. NOTE these tasks can be 282 // Defer non-nestable work to the main task runner. NOTE these tasks can be
283 // arbitrarily delayed so the additional delay should not be a problem. 283 // arbitrarily delayed so the additional delay should not be a problem.
284 main_task_runner_->PostNonNestableTask(pending_task.posted_from, 284 main_task_runner_->PostNonNestableTask(pending_task.posted_from,
285 pending_task.task); 285 pending_task.task);
286 // Even although we haven't actually run this task yet, we do set it as
287 // the out_previous_task below because it might be our only chance to
288 // wake up an after-wakeup queue.
289 } else { 286 } else {
290 TRACE_TASK_EXECUTION("TaskQueueManager::ProcessTaskFromWorkQueue", 287 TRACE_TASK_EXECUTION("TaskQueueManager::ProcessTaskFromWorkQueue",
291 pending_task); 288 pending_task);
292 if (queue->GetShouldNotifyObservers()) { 289 if (queue->GetShouldNotifyObservers()) {
293 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_, 290 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_,
294 WillProcessTask(pending_task)); 291 WillProcessTask(pending_task));
295 } 292 }
296 task_annotator_.RunTask("TaskQueueManager::PostTask", pending_task); 293 task_annotator_.RunTask("TaskQueueManager::PostTask", pending_task);
297 294
298 // Detect if the TaskQueueManager just got deleted. If this happens we must 295 // Detect if the TaskQueueManager just got deleted. If this happens we must
299 // not access any member variables after this point. 296 // not access any member variables after this point.
300 if (protect->HasOneRef()) 297 if (protect->HasOneRef())
301 return true; 298 return true;
302 299
303 if (queue->GetShouldNotifyObservers()) { 300 if (queue->GetShouldNotifyObservers()) {
304 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_, 301 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_,
305 DidProcessTask(pending_task)); 302 DidProcessTask(pending_task));
306 } 303 }
304
305 pending_task.task.Reset();
306 *out_previous_task = pending_task;
307 } 307 }
308
309 pending_task.task.Reset();
310 *out_previous_task = pending_task;
311 return false; 308 return false;
312 } 309 }
313 310
314 bool TaskQueueManager::RunsTasksOnCurrentThread() const { 311 bool TaskQueueManager::RunsTasksOnCurrentThread() const {
315 return main_task_runner_->RunsTasksOnCurrentThread(); 312 return main_task_runner_->RunsTasksOnCurrentThread();
316 } 313 }
317 314
318 bool TaskQueueManager::PostDelayedTask( 315 bool TaskQueueManager::PostDelayedTask(
319 const tracked_objects::Location& from_here, 316 const tracked_objects::Location& from_here,
320 const base::Closure& task, 317 const base::Closure& task,
(...skipping 65 matching lines...)
386 } 383 }
387 384
388 void TaskQueueManager::OnTaskQueueEnabled(internal::TaskQueueImpl* queue) { 385 void TaskQueueManager::OnTaskQueueEnabled(internal::TaskQueueImpl* queue) {
389 DCHECK(main_thread_checker_.CalledOnValidThread()); 386 DCHECK(main_thread_checker_.CalledOnValidThread());
390 // Only schedule DoWork if there's something to do. 387 // Only schedule DoWork if there's something to do.
391 if (!queue->work_queue().empty()) 388 if (!queue->work_queue().empty())
392 MaybePostDoWorkOnMainRunner(); 389 MaybePostDoWorkOnMainRunner();
393 } 390 }
394 391
395 } // namespace scheduler 392 } // 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