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

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

Issue 1303353003: scheduler: Disable expensive timers during main thread user input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 years, 4 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/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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // Defer non-nestable work to the main task runner. NOTE these tasks can be 330 // Defer non-nestable work to the main task runner. NOTE these tasks can be
331 // arbitrarily delayed so the additional delay should not be a problem. 331 // arbitrarily delayed so the additional delay should not be a problem.
332 main_task_runner_->PostNonNestableTask(pending_task.posted_from, 332 main_task_runner_->PostNonNestableTask(pending_task.posted_from,
333 pending_task.task); 333 pending_task.task);
334 } else { 334 } else {
335 TRACE_TASK_EXECUTION("TaskQueueManager::ProcessTaskFromWorkQueue", 335 TRACE_TASK_EXECUTION("TaskQueueManager::ProcessTaskFromWorkQueue",
336 pending_task); 336 pending_task);
337 if (queue->GetShouldNotifyObservers()) { 337 if (queue->GetShouldNotifyObservers()) {
338 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_, 338 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_,
339 WillProcessTask(pending_task)); 339 WillProcessTask(pending_task));
340 queue->NotifyWillProcessTask(pending_task);
340 } 341 }
341 TRACE_EVENT1(disabled_by_default_tracing_category_, 342 TRACE_EVENT1(disabled_by_default_tracing_category_,
342 "Run Task From Queue", "queue", queue->GetName()); 343 "Run Task From Queue", "queue", queue->GetName());
343 task_annotator_.RunTask("TaskQueueManager::PostTask", pending_task); 344 task_annotator_.RunTask("TaskQueueManager::PostTask", pending_task);
344 345
345 // Detect if the TaskQueueManager just got deleted. If this happens we must 346 // Detect if the TaskQueueManager just got deleted. If this happens we must
346 // not access any member variables after this point. 347 // not access any member variables after this point.
347 if (protect->HasOneRef()) 348 if (protect->HasOneRef())
348 return true; 349 return true;
349 350
350 if (queue->GetShouldNotifyObservers()) { 351 if (queue->GetShouldNotifyObservers()) {
351 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_, 352 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_,
352 DidProcessTask(pending_task)); 353 DidProcessTask(pending_task));
354 queue->NotifyDidProcessTask(pending_task);
353 } 355 }
354 356
355 pending_task.task.Reset(); 357 pending_task.task.Reset();
356 *out_previous_task = pending_task; 358 *out_previous_task = pending_task;
357 } 359 }
358 return false; 360 return false;
359 } 361 }
360 362
361 bool TaskQueueManager::RunsTasksOnCurrentThread() const { 363 bool TaskQueueManager::RunsTasksOnCurrentThread() const {
362 return main_task_runner_->RunsTasksOnCurrentThread(); 364 return main_task_runner_->RunsTasksOnCurrentThread();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 435 }
434 436
435 void TaskQueueManager::OnTaskQueueEnabled(internal::TaskQueueImpl* queue) { 437 void TaskQueueManager::OnTaskQueueEnabled(internal::TaskQueueImpl* queue) {
436 DCHECK(main_thread_checker_.CalledOnValidThread()); 438 DCHECK(main_thread_checker_.CalledOnValidThread());
437 // Only schedule DoWork if there's something to do. 439 // Only schedule DoWork if there's something to do.
438 if (!queue->work_queue().empty()) 440 if (!queue->work_queue().empty())
439 MaybePostDoWorkOnMainRunner(); 441 MaybePostDoWorkOnMainRunner();
440 } 442 }
441 443
442 } // namespace scheduler 444 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/task_queue_impl.cc ('k') | components/scheduler/child/task_queue_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698