Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ash / metrics / task_switch_metrics_recorder.cc
blobb8b57fe4753606428c68f2be1236c100070d10c9
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.
5 #include "ash/metrics/task_switch_metrics_recorder.h"
7 #include "ash/metrics/task_switch_time_tracker.h"
9 namespace ash {
11 namespace {
13 const char kShelfHistogramName[] =
14 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches";
16 const char kTabStripHistogramName[] =
17 "Ash.Tab.TimeBetweenSwitchToExistingTabUserActions";
19 const char kAcceleratorWindowCycleHistogramName[] =
20 "Ash.WindowCycleController.TimeBetweenTaskSwitches";
22 const char kAppListHistogramName[] = "Ash.AppList.TimeBetweenTaskSwitches";
24 const char kOverviewModeHistogramName[] =
25 "Ash.WindowSelector.TimeBetweenActiveWindowChanges";
27 // Returns the histogram name for the given |task_switch_source|.
28 const char* GetHistogramName(
29 TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) {
30 switch (task_switch_source) {
31 case TaskSwitchMetricsRecorder::kAppList:
32 return kAppListHistogramName;
33 case TaskSwitchMetricsRecorder::kOverviewMode:
34 return kOverviewModeHistogramName;
35 case TaskSwitchMetricsRecorder::kShelf:
36 return kShelfHistogramName;
37 case TaskSwitchMetricsRecorder::kTabStrip:
38 return kTabStripHistogramName;
39 case TaskSwitchMetricsRecorder::kWindowCycleController:
40 return kAcceleratorWindowCycleHistogramName;
42 NOTREACHED();
43 return nullptr;
46 } // namespace
48 TaskSwitchMetricsRecorder::TaskSwitchMetricsRecorder() {
51 TaskSwitchMetricsRecorder::~TaskSwitchMetricsRecorder() {
54 void TaskSwitchMetricsRecorder::OnTaskSwitch(
55 TaskSwitchSource task_switch_source) {
56 TaskSwitchTimeTracker* task_switch_time_tracker =
57 FindTaskSwitchTimeTracker(task_switch_source);
58 if (!task_switch_time_tracker)
59 AddTaskSwitchTimeTracker(task_switch_source);
61 task_switch_time_tracker = FindTaskSwitchTimeTracker(task_switch_source);
62 CHECK(task_switch_time_tracker);
64 task_switch_time_tracker->OnTaskSwitch();
67 TaskSwitchTimeTracker* TaskSwitchMetricsRecorder::FindTaskSwitchTimeTracker(
68 TaskSwitchSource task_switch_source) {
69 return histogram_map_.get(task_switch_source);
72 void TaskSwitchMetricsRecorder::AddTaskSwitchTimeTracker(
73 TaskSwitchSource task_switch_source) {
74 CHECK(histogram_map_.find(task_switch_source) == histogram_map_.end());
76 const char* histogram_name = GetHistogramName(task_switch_source);
77 DCHECK(histogram_name);
79 histogram_map_.add(
80 task_switch_source,
81 make_scoped_ptr(new TaskSwitchTimeTracker(histogram_name)));
84 } // namespace ash