OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef ASH_METRICS_USER_METRICS_RECORDER_H_ | 5 #ifndef ASH_METRICS_USER_METRICS_RECORDER_H_ |
6 #define ASH_METRICS_USER_METRICS_RECORDER_H_ | 6 #define ASH_METRICS_USER_METRICS_RECORDER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/metrics/task_switch_metrics_recorder.h" | 9 #include "ash/metrics/task_switch_metrics_recorder.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
12 | 11 |
13 namespace ash { | 12 namespace ash { |
14 | 13 |
15 class DesktopTaskSwitchMetricRecorder; | |
16 | |
17 namespace test { | 14 namespace test { |
18 class UserMetricsRecorderTestAPI; | 15 class UserMetricsRecorderTestAPI; |
19 } | 16 } |
20 | 17 |
21 enum UserMetricsAction { | 18 enum UserMetricsAction { |
22 UMA_ACCEL_EXIT_FIRST_Q, | 19 UMA_ACCEL_EXIT_FIRST_Q, |
23 UMA_ACCEL_EXIT_SECOND_Q, | 20 UMA_ACCEL_EXIT_SECOND_Q, |
24 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6, | 21 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6, |
25 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7, | 22 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7, |
26 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON, | 23 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON, |
27 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON, | 24 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON, |
28 UMA_ACCEL_MAXIMIZE_RESTORE_F4, | 25 UMA_ACCEL_MAXIMIZE_RESTORE_F4, |
29 UMA_ACCEL_PREVWINDOW_F5, | 26 UMA_ACCEL_PREVWINDOW_F5, |
30 UMA_ACCEL_RESTART_POWER_BUTTON, | 27 UMA_ACCEL_RESTART_POWER_BUTTON, |
31 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON, | 28 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON, |
32 UMA_CLOSE_THROUGH_CONTEXT_MENU, | 29 UMA_CLOSE_THROUGH_CONTEXT_MENU, |
33 UMA_DESKTOP_SWITCH_TASK, | |
34 UMA_DRAG_MAXIMIZE_LEFT, | 30 UMA_DRAG_MAXIMIZE_LEFT, |
35 UMA_DRAG_MAXIMIZE_RIGHT, | 31 UMA_DRAG_MAXIMIZE_RIGHT, |
36 UMA_GESTURE_OVERVIEW, | 32 UMA_GESTURE_OVERVIEW, |
37 UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE, | 33 UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE, |
38 UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH, | 34 UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH, |
39 UMA_LAUNCHER_CLICK_ON_APP, | 35 UMA_LAUNCHER_CLICK_ON_APP, |
40 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON, | 36 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON, |
41 UMA_LAUNCHER_LAUNCH_TASK, | 37 UMA_LAUNCHER_LAUNCH_TASK, |
42 UMA_LAUNCHER_MINIMIZE_TASK, | 38 UMA_LAUNCHER_MINIMIZE_TASK, |
43 UMA_LAUNCHER_SWITCH_TASK, | 39 UMA_LAUNCHER_SWITCH_TASK, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 146 |
151 virtual ~UserMetricsRecorder(); | 147 virtual ~UserMetricsRecorder(); |
152 | 148 |
153 // Records an Ash owned user action. | 149 // Records an Ash owned user action. |
154 void RecordUserMetricsAction(ash::UserMetricsAction action); | 150 void RecordUserMetricsAction(ash::UserMetricsAction action); |
155 | 151 |
156 TaskSwitchMetricsRecorder& task_switch_metrics_recorder() { | 152 TaskSwitchMetricsRecorder& task_switch_metrics_recorder() { |
157 return task_switch_metrics_recorder_; | 153 return task_switch_metrics_recorder_; |
158 } | 154 } |
159 | 155 |
160 // Informs |this| that the Shell has been initialized. | |
161 void OnShellInitialized(); | |
162 | |
163 // Informs |this| that the Shell is going to be shut down. | |
164 void OnShellShuttingDown(); | |
165 | |
166 private: | 156 private: |
167 friend class test::UserMetricsRecorderTestAPI; | 157 friend class test::UserMetricsRecorderTestAPI; |
168 | 158 |
169 // Creates a UserMetricsRecorder and will only record periodic metrics if | 159 // Creates a UserMetricsRecorder and will only record periodic metrics if |
170 // |record_periodic_metrics| is true. This is used by tests that do not want | 160 // |record_periodic_metrics| is true. This is used by tests that do not want |
171 // the timer to be started. | 161 // the timer to be started. |
172 // TODO(bruthig): Add a constructor that accepts a base::RepeatingTimer so | 162 // TODO(bruthig): Add a constructor that accepts a base::RepeatingTimer so |
173 // that tests can inject a test double that can be controlled by the test. The | 163 // that tests can inject a test double that can be controlled by the test. The |
174 // missing piece is a suitable base::RepeatingTimer test double. | 164 // missing piece is a suitable base::RepeatingTimer test double. |
175 explicit UserMetricsRecorder(bool record_periodic_metrics); | 165 explicit UserMetricsRecorder(bool record_periodic_metrics); |
176 | 166 |
177 // Records UMA metrics. Invoked periodically by the |timer_|. | 167 // Records UMA metrics. Invoked periodically by the |timer_|. |
178 void RecordPeriodicMetrics(); | 168 void RecordPeriodicMetrics(); |
179 | 169 |
180 // Returns true if the user's session is active and they are in a desktop | 170 // Returns true if the user's session is active and they are in a desktop |
181 // environment. | 171 // environment. |
182 bool IsUserInActiveDesktopEnvironment() const; | 172 bool IsUserInActiveDesktopEnvironment() const; |
183 | 173 |
184 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|. | 174 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|. |
185 void StartTimer(); | 175 void StartTimer(); |
186 | 176 |
187 // The periodic timer that triggers metrics to be recorded. | 177 // The periodic timer that triggers metrics to be recorded. |
188 base::RepeatingTimer<UserMetricsRecorder> timer_; | 178 base::RepeatingTimer<UserMetricsRecorder> timer_; |
189 | 179 |
190 TaskSwitchMetricsRecorder task_switch_metrics_recorder_; | 180 TaskSwitchMetricsRecorder task_switch_metrics_recorder_; |
191 | 181 |
192 // Metric recorder to track how often task windows are activated by mouse | |
193 // clicks or touchscreen taps. | |
194 scoped_ptr<DesktopTaskSwitchMetricRecorder> | |
195 desktop_task_switch_metric_recorder_; | |
196 | |
197 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder); | 182 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder); |
198 }; | 183 }; |
199 | 184 |
200 } // namespace ash | 185 } // namespace ash |
201 | 186 |
202 #endif // ASH_METRICS_USER_METRICS_RECORDER_H_ | 187 #endif // ASH_METRICS_USER_METRICS_RECORDER_H_ |
OLD | NEW |