Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/task_scheduler/task_scheduler_impl.h" | 5 #include "base/task_scheduler/task_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_base.h" | |
| 12 #include "base/task_scheduler/scheduler_service_thread.h" | 13 #include "base/task_scheduler/scheduler_service_thread.h" |
| 13 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 14 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 14 #include "base/task_scheduler/sequence_sort_key.h" | 15 #include "base/task_scheduler/sequence_sort_key.h" |
| 15 #include "base/task_scheduler/task.h" | 16 #include "base/task_scheduler/task.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 // static | 22 // static |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 45 make_scoped_refptr(new Sequence), nullptr); | 46 make_scoped_refptr(new Sequence), nullptr); |
| 46 } | 47 } |
| 47 | 48 |
| 48 scoped_refptr<TaskRunner> TaskSchedulerImpl::CreateTaskRunnerWithTraits( | 49 scoped_refptr<TaskRunner> TaskSchedulerImpl::CreateTaskRunnerWithTraits( |
| 49 const TaskTraits& traits, | 50 const TaskTraits& traits, |
| 50 ExecutionMode execution_mode) { | 51 ExecutionMode execution_mode) { |
| 51 return GetWorkerPoolForTraits(traits)->CreateTaskRunnerWithTraits( | 52 return GetWorkerPoolForTraits(traits)->CreateTaskRunnerWithTraits( |
| 52 traits, execution_mode); | 53 traits, execution_mode); |
| 53 } | 54 } |
| 54 | 55 |
| 56 std::vector<const HistogramBase*> TaskSchedulerImpl::GetHistograms() { | |
|
fdoray
2016/10/14 20:59:05
... GetHistograms() const {
robliao
2016/10/17 22:36:57
Done.
| |
| 57 std::vector<const HistogramBase*> histograms; | |
| 58 for (const auto& worker_pool : worker_pools_) { | |
|
fdoray
2016/10/14 20:59:06
Could worker pools have a GetHistograms() method?
robliao
2016/10/17 22:36:57
Done.
| |
| 59 histograms.push_back(worker_pool->detach_duration_histogram()); | |
| 60 histograms.push_back(worker_pool->num_tasks_between_waits_histogram()); | |
| 61 } | |
| 62 return histograms; | |
| 63 } | |
| 64 | |
| 55 void TaskSchedulerImpl::Shutdown() { | 65 void TaskSchedulerImpl::Shutdown() { |
| 56 // TODO(fdoray): Increase the priority of BACKGROUND tasks blocking shutdown. | 66 // TODO(fdoray): Increase the priority of BACKGROUND tasks blocking shutdown. |
| 57 task_tracker_.Shutdown(); | 67 task_tracker_.Shutdown(); |
| 58 } | 68 } |
| 59 | 69 |
| 60 void TaskSchedulerImpl::FlushForTesting() { | 70 void TaskSchedulerImpl::FlushForTesting() { |
| 61 task_tracker_.Flush(); | 71 task_tracker_.Flush(); |
| 62 } | 72 } |
| 63 | 73 |
| 64 void TaskSchedulerImpl::JoinForTesting() { | 74 void TaskSchedulerImpl::JoinForTesting() { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), | 138 GetWorkerPoolForTraits(traits)->ReEnqueueSequence(std::move(sequence), |
| 129 sort_key); | 139 sort_key); |
| 130 } | 140 } |
| 131 | 141 |
| 132 void TaskSchedulerImpl::OnDelayedRunTimeUpdated() { | 142 void TaskSchedulerImpl::OnDelayedRunTimeUpdated() { |
| 133 service_thread_->WakeUp(); | 143 service_thread_->WakeUp(); |
| 134 } | 144 } |
| 135 | 145 |
| 136 } // namespace internal | 146 } // namespace internal |
| 137 } // namespace base | 147 } // namespace base |
| OLD | NEW |