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

Side by Side Diff: base/task_scheduler/task_tracker.cc

Issue 1937323002: TaskScheduler: Add TRACE_TASK_EXECUTION to TaskTracker::RunTask. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, base::RunTask->TaskSchedulerRunTask, no SetSingletonAllowed in scope Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "base/threading/sequenced_task_runner_handle.h" 11 #include "base/threading/sequenced_task_runner_handle.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "base/trace_event/trace_event.h"
13 14
14 namespace base { 15 namespace base {
15 namespace internal { 16 namespace internal {
16 17
17 namespace { 18 namespace {
18 19
19 const char kQueueFunctionName[] = "base::PostTask"; 20 const char kQueueFunctionName[] = "base::PostTask";
21 const char kRunFunctionName[] = "TaskSchedulerRunTask";
robliao 2016/05/03 16:46:51 Comment where this name originated.
fdoray 2016/05/03 17:07:14 Done.
20 22
21 // Upper bound for the 23 // Upper bound for the
22 // TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram. 24 // TaskScheduler.BlockShutdownTasksPostedDuringShutdown histogram.
23 const HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = 1000; 25 const HistogramBase::Sample kMaxBlockShutdownTasksPostedDuringShutdown = 1000;
24 26
25 void RecordNumBlockShutdownTasksPostedDuringShutdown( 27 void RecordNumBlockShutdownTasksPostedDuringShutdown(
26 HistogramBase::Sample value) { 28 HistogramBase::Sample value) {
27 UMA_HISTOGRAM_CUSTOM_COUNTS( 29 UMA_HISTOGRAM_CUSTOM_COUNTS(
28 "TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1, 30 "TaskScheduler.BlockShutdownTasksPostedDuringShutdown", value, 1,
29 kMaxBlockShutdownTasksPostedDuringShutdown, 50); 31 kMaxBlockShutdownTasksPostedDuringShutdown, 50);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DCHECK(!task->sequenced_task_runner_ref || 97 DCHECK(!task->sequenced_task_runner_ref ||
96 !task->single_thread_task_runner_ref); 98 !task->single_thread_task_runner_ref);
97 if (task->sequenced_task_runner_ref) { 99 if (task->sequenced_task_runner_ref) {
98 sequenced_task_runner_handle.reset( 100 sequenced_task_runner_handle.reset(
99 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref)); 101 new SequencedTaskRunnerHandle(task->sequenced_task_runner_ref));
100 } else if (task->single_thread_task_runner_ref) { 102 } else if (task->single_thread_task_runner_ref) {
101 single_thread_task_runner_handle.reset( 103 single_thread_task_runner_handle.reset(
102 new ThreadTaskRunnerHandle(task->single_thread_task_runner_ref)); 104 new ThreadTaskRunnerHandle(task->single_thread_task_runner_ref));
103 } 105 }
104 106
107 TRACE_TASK_EXECUTION(kRunFunctionName, *task);
108
105 debug::TaskAnnotator task_annotator; 109 debug::TaskAnnotator task_annotator;
106 task_annotator.RunTask(kQueueFunctionName, *task); 110 task_annotator.RunTask(kQueueFunctionName, *task);
107 } 111 }
108 112
109 AfterRunTask(shutdown_behavior); 113 AfterRunTask(shutdown_behavior);
110 } 114 }
111 115
112 bool TaskTracker::IsShuttingDownForTesting() const { 116 bool TaskTracker::IsShuttingDownForTesting() const {
113 AutoSchedulerLock auto_lock(lock_); 117 AutoSchedulerLock auto_lock(lock_);
114 return !!shutdown_cv_; 118 return !!shutdown_cv_;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 AutoSchedulerLock auto_lock(lock_); 200 AutoSchedulerLock auto_lock(lock_);
197 DCHECK_GT(num_tasks_blocking_shutdown_, 0U); 201 DCHECK_GT(num_tasks_blocking_shutdown_, 0U);
198 --num_tasks_blocking_shutdown_; 202 --num_tasks_blocking_shutdown_;
199 if (num_tasks_blocking_shutdown_ == 0 && shutdown_cv_) 203 if (num_tasks_blocking_shutdown_ == 0 && shutdown_cv_)
200 shutdown_cv_->Signal(); 204 shutdown_cv_->Signal();
201 } 205 }
202 } 206 }
203 207
204 } // namespace internal 208 } // namespace internal
205 } // namespace base 209 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698