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

Unified Diff: ash/metrics/task_switch_metrics_recorder.cc

Issue 1133123003: Added metrics to track the time between task switches done via the shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ASH_EXPORT to TaskSwitchTimeTracker. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/metrics/task_switch_metrics_recorder.h ('k') | ash/metrics/task_switch_metrics_recorder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/metrics/task_switch_metrics_recorder.cc
diff --git a/ash/metrics/task_switch_metrics_recorder.cc b/ash/metrics/task_switch_metrics_recorder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..667c7e4ffc7fe2eb1fdf47a9504fff50801de531
--- /dev/null
+++ b/ash/metrics/task_switch_metrics_recorder.cc
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/metrics/task_switch_metrics_recorder.h"
+
+#include "ash/metrics/task_switch_time_tracker.h"
+
+namespace ash {
+
+namespace {
+
+const char kShelfHistogramName[] =
+ "Ash.Shelf.TimeBetweenNavigateToTaskSwitches";
+
+// Returns the histogram name for the given |task_switch_source|.
+const char* GetHistogramName(
+ TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) {
+ switch (task_switch_source) {
+ case TaskSwitchMetricsRecorder::kShelf:
+ return kShelfHistogramName;
+ }
+ NOTREACHED();
+ return nullptr;
+}
+
+} // namespace
+
+TaskSwitchMetricsRecorder::TaskSwitchMetricsRecorder() {
+}
+
+TaskSwitchMetricsRecorder::~TaskSwitchMetricsRecorder() {
+}
+
+void TaskSwitchMetricsRecorder::OnTaskSwitch(
+ TaskSwitchSource task_switch_source) {
+ TaskSwitchTimeTracker* task_switch_time_tracker =
+ FindTaskSwitchTimeTracker(task_switch_source);
+ if (!task_switch_time_tracker)
+ AddTaskSwitchTimeTracker(task_switch_source);
+
+ task_switch_time_tracker = FindTaskSwitchTimeTracker(task_switch_source);
+ CHECK(task_switch_time_tracker);
+
+ task_switch_time_tracker->OnTaskSwitch();
+}
+
+TaskSwitchTimeTracker* TaskSwitchMetricsRecorder::FindTaskSwitchTimeTracker(
+ TaskSwitchSource task_switch_source) {
+ return histogram_map_.get(task_switch_source);
+}
+
+void TaskSwitchMetricsRecorder::AddTaskSwitchTimeTracker(
+ TaskSwitchSource task_switch_source) {
+ CHECK(histogram_map_.find(task_switch_source) == histogram_map_.end());
+
+ const char* histogram_name = GetHistogramName(task_switch_source);
+ DCHECK(histogram_name);
+
+ histogram_map_.add(
+ task_switch_source,
+ make_scoped_ptr(new TaskSwitchTimeTracker(histogram_name)));
+}
+
+} // namespace ash
« no previous file with comments | « ash/metrics/task_switch_metrics_recorder.h ('k') | ash/metrics/task_switch_metrics_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698