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_tracker.h" | 5 #include "base/task_scheduler/task_tracker.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/debug/task_annotator.h" | 8 #include "base/debug/task_annotator.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "base/trace_event/trace_event.h" | |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 namespace internal { | 14 namespace internal { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const char kQueueFunctionName[] = "base::PostTask"; | 18 const char kQueueFunctionName[] = "base::PostTask"; |
| 19 const char kRunFunctionName[] = "base::RunTask"; | |
|
fdoray
2016/05/02 19:50:08
I don't want to call this TaskTracker::RunTask bec
gab
2016/05/02 20:31:22
Okay but base::RunTask isn't a thing... Maybe just
fdoray
2016/05/03 14:06:36
Done.
| |
| 18 | 20 |
| 19 // Upper bound for the | 21 // Upper bound for the |
| 20 // TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram. | 22 // TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram. |
| 21 const HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = 1000; | 23 const HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = 1000; |
| 22 | 24 |
| 23 void RecordNumBlockShutdownTasksPostedDuringShutdown( | 25 void RecordNumBlockShutdownTasksPostedDuringShutdown( |
| 24 HistogramBase::Sample value) { | 26 HistogramBase::Sample value) { |
| 25 UMA_HISTOGRAM_CUSTOM_COUNTS( | 27 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 26 "TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1, | 28 "TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1, |
| 27 kMaxBlockShutdownTasksPostedDuringShutdown, 50); | 29 kMaxBlockShutdownTasksPostedDuringShutdown, 50); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 } | 74 } |
| 73 | 75 |
| 74 void TaskTracker::RunTask(const Task* task) { | 76 void TaskTracker::RunTask(const Task* task) { |
| 75 DCHECK(task); | 77 DCHECK(task); |
| 76 | 78 |
| 77 const TaskShutdownBehavior shutdown_behavior = | 79 const TaskShutdownBehavior shutdown_behavior = |
| 78 task->traits.shutdown_behavior(); | 80 task->traits.shutdown_behavior(); |
| 79 if (!BeforeRunTask(shutdown_behavior)) | 81 if (!BeforeRunTask(shutdown_behavior)) |
| 80 return; | 82 return; |
| 81 | 83 |
| 84 TRACE_TASK_EXECUTION(kRunFunctionName, *task); | |
|
gab
2016/05/02 20:31:22
https://codereview.chromium.org/1911023002/ is sco
robliao
2016/05/02 20:32:34
Should this occur right after we SetSingletonAllow
fdoray
2016/05/03 14:06:36
I initially included SetSingletonAllowed into TRAC
| |
| 85 | |
| 82 // All tasks run through here and the scheduler itself doesn't use singletons. | 86 // All tasks run through here and the scheduler itself doesn't use singletons. |
| 83 // Therefore, it isn't necessary to reset the singleton allowed bit after | 87 // Therefore, it isn't necessary to reset the singleton allowed bit after |
| 84 // running the task. | 88 // running the task. |
| 85 ThreadRestrictions::SetSingletonAllowed( | 89 ThreadRestrictions::SetSingletonAllowed( |
| 86 task->traits.shutdown_behavior() != | 90 task->traits.shutdown_behavior() != |
| 87 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); | 91 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); |
| 88 | 92 |
| 89 debug::TaskAnnotator task_annotator; | 93 debug::TaskAnnotator task_annotator; |
| 90 task_annotator.RunTask(kQueueFunctionName, *task); | 94 task_annotator.RunTask(kQueueFunctionName, *task); |
| 91 | 95 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 AutoSchedulerLock auto_lock(lock_); | 183 AutoSchedulerLock auto_lock(lock_); |
| 180 DCHECK_GT(num_tasks_blocking_shutdown_, 0U); | 184 DCHECK_GT(num_tasks_blocking_shutdown_, 0U); |
| 181 --num_tasks_blocking_shutdown_; | 185 --num_tasks_blocking_shutdown_; |
| 182 if (num_tasks_blocking_shutdown_ == 0 && shutdown_cv_) | 186 if (num_tasks_blocking_shutdown_ == 0 && shutdown_cv_) |
| 183 shutdown_cv_->Signal(); | 187 shutdown_cv_->Signal(); |
| 184 } | 188 } |
| 185 } | 189 } |
| 186 | 190 |
| 187 } // namespace internal | 191 } // namespace internal |
| 188 } // namespace base | 192 } // namespace base |
| OLD | NEW |