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

Side by Side Diff: ash/metrics/task_switch_metrics_recorder.cc

Issue 1153633006: Added UMA statistics for changing the active window via click or touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 "ui/aura/window.h"
9 #include "ui/wm/public/window_types.h"
8 10
9 namespace ash { 11 namespace ash {
10 12
11 namespace { 13 namespace {
12 14
15 const char kScreenHistogramName[] =
16 "Ash.Screen.TimeBetweenNavigateToTaskSwitches";
tdanderson 2015/05/26 21:13:52 don't forget to update histograms.xml
bruthig 2015/06/03 21:59:31 Done.
17
13 const char kShelfHistogramName[] = 18 const char kShelfHistogramName[] =
14 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches"; 19 "Ash.Shelf.TimeBetweenNavigateToTaskSwitches";
15 20
16 const char kTabStripHistogramName[] = 21 const char kTabStripHistogramName[] =
17 "Ash.Tab.TimeBetweenSwitchToExistingTabUserActions"; 22 "Ash.Tab.TimeBetweenSwitchToExistingTabUserActions";
18 23
19 const char kAcceleratorWindowCycleHistogramName[] = 24 const char kAcceleratorWindowCycleHistogramName[] =
20 "Ash.WindowCycleController.TimeBetweenTaskSwitches"; 25 "Ash.WindowCycleController.TimeBetweenTaskSwitches";
21 26
22 const char kAppListHistogramName[] = "Ash.AppList.TimeBetweenTaskSwitches"; 27 const char kAppListHistogramName[] = "Ash.AppList.TimeBetweenTaskSwitches";
23 28
24 const char kOverviewModeHistogramName[] = 29 const char kOverviewModeHistogramName[] =
25 "Ash.WindowSelector.TimeBetweenActiveWindowChanges"; 30 "Ash.WindowSelector.TimeBetweenActiveWindowChanges";
26 31
27 // Returns the histogram name for the given |task_switch_source|. 32 // Returns the histogram name for the given |task_switch_source|.
28 const char* GetHistogramName( 33 const char* GetHistogramName(
29 TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) { 34 TaskSwitchMetricsRecorder::TaskSwitchSource task_switch_source) {
30 switch (task_switch_source) { 35 switch (task_switch_source) {
31 case TaskSwitchMetricsRecorder::kAppList: 36 case TaskSwitchMetricsRecorder::kAppList:
32 return kAppListHistogramName; 37 return kAppListHistogramName;
33 case TaskSwitchMetricsRecorder::kOverviewMode: 38 case TaskSwitchMetricsRecorder::kOverviewMode:
34 return kOverviewModeHistogramName; 39 return kOverviewModeHistogramName;
40 case TaskSwitchMetricsRecorder::kScreen:
41 return kScreenHistogramName;
35 case TaskSwitchMetricsRecorder::kShelf: 42 case TaskSwitchMetricsRecorder::kShelf:
36 return kShelfHistogramName; 43 return kShelfHistogramName;
37 case TaskSwitchMetricsRecorder::kTabStrip: 44 case TaskSwitchMetricsRecorder::kTabStrip:
38 return kTabStripHistogramName; 45 return kTabStripHistogramName;
39 case TaskSwitchMetricsRecorder::kWindowCycleController: 46 case TaskSwitchMetricsRecorder::kWindowCycleController:
40 return kAcceleratorWindowCycleHistogramName; 47 return kAcceleratorWindowCycleHistogramName;
41 } 48 }
42 NOTREACHED(); 49 NOTREACHED();
43 return nullptr; 50 return nullptr;
44 } 51 }
(...skipping 12 matching lines...) Expand all
57 FindTaskSwitchTimeTracker(task_switch_source); 64 FindTaskSwitchTimeTracker(task_switch_source);
58 if (!task_switch_time_tracker) 65 if (!task_switch_time_tracker)
59 AddTaskSwitchTimeTracker(task_switch_source); 66 AddTaskSwitchTimeTracker(task_switch_source);
60 67
61 task_switch_time_tracker = FindTaskSwitchTimeTracker(task_switch_source); 68 task_switch_time_tracker = FindTaskSwitchTimeTracker(task_switch_source);
62 CHECK(task_switch_time_tracker); 69 CHECK(task_switch_time_tracker);
63 70
64 task_switch_time_tracker->OnTaskSwitch(); 71 task_switch_time_tracker->OnTaskSwitch();
65 } 72 }
66 73
74 bool TaskSwitchMetricsRecorder::IsATaskWindow(aura::Window* window) const {
75 return window && (window->type() == ui::wm::WINDOW_TYPE_NORMAL ||
tdanderson 2015/05/26 21:13:52 It might be nice to define this as a static utilit
bruthig 2015/06/03 21:59:31 Done.
76 window->type() == ui::wm::WINDOW_TYPE_PANEL);
77 }
78
67 TaskSwitchTimeTracker* TaskSwitchMetricsRecorder::FindTaskSwitchTimeTracker( 79 TaskSwitchTimeTracker* TaskSwitchMetricsRecorder::FindTaskSwitchTimeTracker(
68 TaskSwitchSource task_switch_source) { 80 TaskSwitchSource task_switch_source) {
69 return histogram_map_.get(task_switch_source); 81 return histogram_map_.get(task_switch_source);
70 } 82 }
71 83
72 void TaskSwitchMetricsRecorder::AddTaskSwitchTimeTracker( 84 void TaskSwitchMetricsRecorder::AddTaskSwitchTimeTracker(
73 TaskSwitchSource task_switch_source) { 85 TaskSwitchSource task_switch_source) {
74 CHECK(histogram_map_.find(task_switch_source) == histogram_map_.end()); 86 CHECK(histogram_map_.find(task_switch_source) == histogram_map_.end());
75 87
76 const char* histogram_name = GetHistogramName(task_switch_source); 88 const char* histogram_name = GetHistogramName(task_switch_source);
77 DCHECK(histogram_name); 89 DCHECK(histogram_name);
78 90
79 histogram_map_.add( 91 histogram_map_.add(
80 task_switch_source, 92 task_switch_source,
81 make_scoped_ptr(new TaskSwitchTimeTracker(histogram_name))); 93 make_scoped_ptr(new TaskSwitchTimeTracker(histogram_name)));
82 } 94 }
83 95
84 } // namespace ash 96 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698