Index: base/task_scheduler/task_tracker.h |
diff --git a/base/task_scheduler/task_tracker.h b/base/task_scheduler/task_tracker.h |
index a5caf213985ea20bd986cafb70bea32d76891207..26ed110cbd9bf6a60da74114fd98e9c8b8722b89 100644 |
--- a/base/task_scheduler/task_tracker.h |
+++ b/base/task_scheduler/task_tracker.h |
@@ -10,6 +10,7 @@ |
#include "base/atomicops.h" |
#include "base/base_export.h" |
#include "base/callback_forward.h" |
+#include "base/gtest_prod_util.h" |
#include "base/macros.h" |
#include "base/metrics/histogram_base.h" |
#include "base/synchronization/waitable_event.h" |
@@ -21,13 +22,15 @@ |
namespace base { |
class ConditionVariable; |
+class HistogramBase; |
class SequenceToken; |
namespace internal { |
// All tasks go through the scheduler's TaskTracker when they are posted and |
-// when they are executed. The TaskTracker enforces shutdown semantics and takes |
-// care of tracing and profiling. This class is thread-safe. |
+// when they are executed. The TaskTracker sets up the environment to run tasks, |
+// enforces shutdown semantics, records metrics and takes care of tracing and |
gab
2017/01/05 19:25:46
, and
fdoray
2017/01/05 20:13:38
Done.
|
+// profiling. This class is thread-safe. |
class BASE_EXPORT TaskTracker { |
public: |
TaskTracker(); |
@@ -79,6 +82,8 @@ class BASE_EXPORT TaskTracker { |
virtual void PerformRunTask(std::unique_ptr<Task> task); |
private: |
+ FRIEND_TEST_ALL_PREFIXES(TaskSchedulerTaskTrackerHistogramTest, TaskLatency); |
+ |
class State; |
void PerformShutdown(); |
@@ -106,6 +111,10 @@ class BASE_EXPORT TaskTracker { |
// it reaches zero. |
void DecrementNumPendingUndelayedTasks(); |
+ // Records the TaskScheduler.TaskLatency.[task priority].[may block] histogram |
+ // for |task|. |
+ void RecordTaskLatencyHistogram(Task* task); |
+ |
// Number of tasks blocking shutdown and boolean indicating whether shutdown |
// has started. |
const std::unique_ptr<State> state_; |
@@ -133,6 +142,12 @@ class BASE_EXPORT TaskTracker { |
// completes. |
std::unique_ptr<WaitableEvent> shutdown_event_; |
+ // TaskScheduler.TaskLatency.[task priority].[may block] histograms. The first |
+ // index is a TaskPriority. The second index is 0 for non-blocking tasks, 1 |
+ // for blocking tasks. Intentionally leaked. |
+ HistogramBase* const |
+ task_latency_histograms_[static_cast<int>(TaskPriority::HIGHEST) + 1][2]; |
+ |
// Number of BLOCK_SHUTDOWN tasks posted during shutdown. |
HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; |