| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "ash/metrics/task_switch_metrics_recorder.h" | 5 #include "ash/metrics/task_switch_metrics_recorder.h" |
| 6 | 6 |
| 7 #include "ash/metrics/task_switch_time_tracker.h" | 7 #include "ash/metrics/task_switch_time_tracker.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 | 9 |
| 10 namespace ash { | 10 namespace ash { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 const char kAshTaskSwitchHistogramName[] = "Ash.TimeBetweenTaskSwitches"; | 14 const char kAshTaskSwitchHistogramName[] = "Ash.TimeBetweenTaskSwitches"; |
| 15 | 15 |
| 16 const char kDesktopHistogramName[] = | 16 const char kDesktopHistogramName[] = |
| 17 "Ash.Desktop.TimeBetweenNavigateToTaskSwitches"; | 17 "Ash.Desktop.TimeBetweenNavigateToTaskSwitches"; |
| 18 | 18 |
| 19 const char kShelfHistogramName[] = | 19 const char kShelfHistogramName[] = |
| 20 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches"; | 20 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches"; |
| 21 | 21 |
| 22 const char kTabStripHistogramName[] = | |
| 23 "Ash.Tab.TimeBetweenSwitchToExistingTabUserActions"; | |
| 24 | |
| 25 const char kAcceleratorWindowCycleHistogramName[] = | 22 const char kAcceleratorWindowCycleHistogramName[] = |
| 26 "Ash.WindowCycleController.TimeBetweenTaskSwitches"; | 23 "Ash.WindowCycleController.TimeBetweenTaskSwitches"; |
| 27 | 24 |
| 28 const char kAppListHistogramName[] = "Ash.AppList.TimeBetweenTaskSwitches"; | |
| 29 | |
| 30 const char kOverviewModeHistogramName[] = | 25 const char kOverviewModeHistogramName[] = |
| 31 "Ash.WindowSelector.TimeBetweenActiveWindowChanges"; | 26 "Ash.WindowSelector.TimeBetweenActiveWindowChanges"; |
| 32 | 27 |
| 33 // Returns the histogram name for the given |task_switch_source|. | 28 // Returns the histogram name for the given |task_switch_source|. |
| 34 const char* GetHistogramName(TaskSwitchSource task_switch_source) { | 29 const char* GetHistogramName(TaskSwitchSource task_switch_source) { |
| 35 switch (task_switch_source) { | 30 switch (task_switch_source) { |
| 36 case TaskSwitchSource::ANY: | 31 case TaskSwitchSource::ANY: |
| 37 return kAshTaskSwitchHistogramName; | 32 return kAshTaskSwitchHistogramName; |
| 38 case TaskSwitchSource::APP_LIST: | |
| 39 return kAppListHistogramName; | |
| 40 case TaskSwitchSource::DESKTOP: | 33 case TaskSwitchSource::DESKTOP: |
| 41 return kDesktopHistogramName; | 34 return kDesktopHistogramName; |
| 42 case TaskSwitchSource::OVERVIEW_MODE: | 35 case TaskSwitchSource::OVERVIEW_MODE: |
| 43 return kOverviewModeHistogramName; | 36 return kOverviewModeHistogramName; |
| 44 case TaskSwitchSource::SHELF: | 37 case TaskSwitchSource::SHELF: |
| 45 return kShelfHistogramName; | 38 return kShelfHistogramName; |
| 46 case TaskSwitchSource::TAB_STRIP: | |
| 47 return kTabStripHistogramName; | |
| 48 case TaskSwitchSource::WINDOW_CYCLE_CONTROLLER: | 39 case TaskSwitchSource::WINDOW_CYCLE_CONTROLLER: |
| 49 return kAcceleratorWindowCycleHistogramName; | 40 return kAcceleratorWindowCycleHistogramName; |
| 50 } | 41 } |
| 51 NOTREACHED(); | 42 NOTREACHED(); |
| 52 return nullptr; | 43 return nullptr; |
| 53 } | 44 } |
| 54 | 45 |
| 55 } // namespace | 46 } // namespace |
| 56 | 47 |
| 57 TaskSwitchMetricsRecorder::TaskSwitchMetricsRecorder() {} | 48 TaskSwitchMetricsRecorder::TaskSwitchMetricsRecorder() {} |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 histogram_map_.end()); | 82 histogram_map_.end()); |
| 92 | 83 |
| 93 const char* histogram_name = GetHistogramName(task_switch_source); | 84 const char* histogram_name = GetHistogramName(task_switch_source); |
| 94 DCHECK(histogram_name); | 85 DCHECK(histogram_name); |
| 95 | 86 |
| 96 histogram_map_.add(static_cast<int>(task_switch_source), | 87 histogram_map_.add(static_cast<int>(task_switch_source), |
| 97 base::MakeUnique<TaskSwitchTimeTracker>(histogram_name)); | 88 base::MakeUnique<TaskSwitchTimeTracker>(histogram_name)); |
| 98 } | 89 } |
| 99 | 90 |
| 100 } // namespace ash | 91 } // namespace ash |
| OLD | NEW |