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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/metrics/task_switch_metrics_recorder.h"
6
7 #include "ash/metrics/task_switch_time_tracker.h"
8
9 namespace ash {
10
11 namespace {
12
13 const char kShelfHistogramName[] =
14 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches";
15
16 // Returns the histogram name for the given |task_switch_source|.
17 const char* GetHistogramName(
18 TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) {
19 switch (task_switch_source) {
20 case TaskSwitchMetricsRecorder::kShelf:
21 return kShelfHistogramName;
22 }
23 NOTREACHED();
24 return nullptr;
25 }
26
27 } // namespace
28
29 TaskSwitchMetricsRecorder::TaskSwitchMetricsRecorder() {
30 }
31
32 TaskSwitchMetricsRecorder::~TaskSwitchMetricsRecorder() {
33 }
34
35 void TaskSwitchMetricsRecorder::OnTaskSwitch(
36 TaskSwitchSource task_switch_source) {
37 TaskSwitchTimeTracker* task_switch_time_tracker =
38 FindTaskSwitchTimeTracker(task_switch_source);
39 if (!task_switch_time_tracker)
40 AddTaskSwitchTimeTracker(task_switch_source);
41
42 task_switch_time_tracker = FindTaskSwitchTimeTracker(task_switch_source);
43 CHECK(task_switch_time_tracker);
44
45 task_switch_time_tracker->OnTaskSwitch();
46 }
47
48 TaskSwitchTimeTracker* TaskSwitchMetricsRecorder::FindTaskSwitchTimeTracker(
49 TaskSwitchSource task_switch_source) {
50 return histogram_map_.get(task_switch_source);
51 }
52
53 void TaskSwitchMetricsRecorder::AddTaskSwitchTimeTracker(
54 TaskSwitchSource task_switch_source) {
55 CHECK(histogram_map_.find(task_switch_source) == histogram_map_.end());
56
57 const char* histogram_name = GetHistogramName(task_switch_source);
58 DCHECK(histogram_name);
59
60 histogram_map_.add(
61 task_switch_source,
62 make_scoped_ptr(new TaskSwitchTimeTracker(histogram_name)));
63 }
64
65 } // namespace ash
OLDNEW
« 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