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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments Created 3 years, 8 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 "platform/scheduler/base/task_queue_manager.h" 5 #include "platform/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 task_count_(0), 63 task_count_(0),
64 tracing_category_(tracing_category), 64 tracing_category_(tracing_category),
65 disabled_by_default_tracing_category_( 65 disabled_by_default_tracing_category_(
66 disabled_by_default_tracing_category), 66 disabled_by_default_tracing_category),
67 disabled_by_default_verbose_tracing_category_( 67 disabled_by_default_verbose_tracing_category_(
68 disabled_by_default_verbose_tracing_category), 68 disabled_by_default_verbose_tracing_category),
69 currently_executing_task_queue_(nullptr), 69 currently_executing_task_queue_(nullptr),
70 observer_(nullptr), 70 observer_(nullptr),
71 deletion_sentinel_(new DeletionSentinel()), 71 deletion_sentinel_(new DeletionSentinel()),
72 weak_factory_(this) { 72 weak_factory_(this) {
73 DCHECK(delegate->RunsTasksOnCurrentThread()); 73 DCHECK(delegate->RunsTasksInCurrentSequence());
74 TRACE_EVENT_OBJECT_CREATED_WITH_ID(disabled_by_default_tracing_category, 74 TRACE_EVENT_OBJECT_CREATED_WITH_ID(disabled_by_default_tracing_category,
75 "TaskQueueManager", this); 75 "TaskQueueManager", this);
76 selector_.SetTaskQueueSelectorObserver(this); 76 selector_.SetTaskQueueSelectorObserver(this);
77 77
78 delayed_do_work_closure_ = 78 delayed_do_work_closure_ =
79 base::Bind(&TaskQueueManager::DoWork, weak_factory_.GetWeakPtr(), true); 79 base::Bind(&TaskQueueManager::DoWork, weak_factory_.GetWeakPtr(), true);
80 immediate_do_work_closure_ = 80 immediate_do_work_closure_ =
81 base::Bind(&TaskQueueManager::DoWork, weak_factory_.GetWeakPtr(), false); 81 base::Bind(&TaskQueueManager::DoWork, weak_factory_.GetWeakPtr(), false);
82 82
83 // TODO(alexclarke): Change this to be a parameter that's passed in. 83 // TODO(alexclarke): Change this to be a parameter that's passed in.
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 // Record delayed task lateness and immediate task queuing durations. 570 // Record delayed task lateness and immediate task queuing durations.
571 if (!pending_task.delayed_run_time.is_null()) { 571 if (!pending_task.delayed_run_time.is_null()) {
572 RecordDelayedTaskLateness(delegate_->NowTicks() - 572 RecordDelayedTaskLateness(delegate_->NowTicks() -
573 pending_task.delayed_run_time); 573 pending_task.delayed_run_time);
574 } else if (!pending_task.time_posted.is_null()) { 574 } else if (!pending_task.time_posted.is_null()) {
575 RecordImmediateTaskQueueingDuration(tracked_objects::TrackedTime::Now() - 575 RecordImmediateTaskQueueingDuration(tracked_objects::TrackedTime::Now() -
576 pending_task.time_posted); 576 pending_task.time_posted);
577 } 577 }
578 } 578 }
579 579
580 bool TaskQueueManager::RunsTasksOnCurrentThread() const { 580 bool TaskQueueManager::RunsTasksInCurrentSequence() const {
581 return delegate_->RunsTasksOnCurrentThread(); 581 return delegate_->RunsTasksInCurrentSequence();
582 } 582 }
583 583
584 void TaskQueueManager::SetWorkBatchSize(int work_batch_size) { 584 void TaskQueueManager::SetWorkBatchSize(int work_batch_size) {
585 DCHECK(main_thread_checker_.CalledOnValidThread()); 585 DCHECK(main_thread_checker_.CalledOnValidThread());
586 DCHECK_GE(work_batch_size, 1); 586 DCHECK_GE(work_batch_size, 1);
587 work_batch_size_ = work_batch_size; 587 work_batch_size_ = work_batch_size;
588 } 588 }
589 589
590 void TaskQueueManager::AddTaskObserver( 590 void TaskQueueManager::AddTaskObserver(
591 base::MessageLoop::TaskObserver* task_observer) { 591 base::MessageLoop::TaskObserver* task_observer) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 for (const scoped_refptr<internal::TaskQueueImpl>& queue : queues_) { 711 for (const scoped_refptr<internal::TaskQueueImpl>& queue : queues_) {
712 TimeDomain* time_domain = queue->GetTimeDomain(); 712 TimeDomain* time_domain = queue->GetTimeDomain();
713 if (time_domain_now.find(time_domain) == time_domain_now.end()) 713 if (time_domain_now.find(time_domain) == time_domain_now.end())
714 time_domain_now.insert(std::make_pair(time_domain, time_domain->Now())); 714 time_domain_now.insert(std::make_pair(time_domain, time_domain->Now()));
715 queue->SweepCanceledDelayedTasks(time_domain_now[time_domain]); 715 queue->SweepCanceledDelayedTasks(time_domain_now[time_domain]);
716 } 716 }
717 } 717 }
718 718
719 } // namespace scheduler 719 } // namespace scheduler
720 } // namespace blink 720 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698