Chromium Code Reviews| 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_USER_METRICS_RECORDER_H_ | 5 #ifndef ASH_USER_METRICS_RECORDER_H_ |
| 6 #define ASH_USER_METRICS_RECORDER_H_ | 6 #define ASH_USER_METRICS_RECORDER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 | 10 |
| 11 namespace ash { | 11 namespace ash { |
| 12 | 12 |
| 13 namespace test { | |
| 14 class UserMetricsRecorderTestAPI; | |
| 15 } | |
| 16 | |
| 13 enum UserMetricsAction { | 17 enum UserMetricsAction { |
| 14 UMA_ACCEL_EXIT_FIRST_Q, | 18 UMA_ACCEL_EXIT_FIRST_Q, |
| 15 UMA_ACCEL_EXIT_SECOND_Q, | 19 UMA_ACCEL_EXIT_SECOND_Q, |
| 16 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6, | 20 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6, |
| 17 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7, | 21 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7, |
| 18 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON, | 22 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON, |
| 19 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON, | 23 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON, |
| 20 UMA_ACCEL_MAXIMIZE_RESTORE_F4, | 24 UMA_ACCEL_MAXIMIZE_RESTORE_F4, |
| 21 UMA_ACCEL_PREVWINDOW_F5, | 25 UMA_ACCEL_PREVWINDOW_F5, |
| 22 UMA_ACCEL_RESTART_POWER_BUTTON, | 26 UMA_ACCEL_RESTART_POWER_BUTTON, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 UMA_WINDOW_CYCLE, | 124 UMA_WINDOW_CYCLE, |
| 121 }; | 125 }; |
| 122 | 126 |
| 123 // User Metrics Recorder provides a repeating callback (RecordPeriodicMetrics) | 127 // User Metrics Recorder provides a repeating callback (RecordPeriodicMetrics) |
| 124 // on a timer to allow recording of state data over time to the UMA records. | 128 // on a timer to allow recording of state data over time to the UMA records. |
| 125 // Any additional states (in ash) that require monitoring can be added to | 129 // Any additional states (in ash) that require monitoring can be added to |
| 126 // this class. As well calls to record on action metrics | 130 // this class. As well calls to record on action metrics |
| 127 // (RecordUserMetricsAction) are passed through the UserMetricsRecorder. | 131 // (RecordUserMetricsAction) are passed through the UserMetricsRecorder. |
| 128 class ASH_EXPORT UserMetricsRecorder { | 132 class ASH_EXPORT UserMetricsRecorder { |
| 129 public: | 133 public: |
| 134 // Creates a UserMetricsRecorder that will automatically start the repeating | |
| 135 // timer. Equivalent to calling UserMetricsRecorder(true). | |
|
pkotwicz
2015/04/21 16:15:17
How about: "Creates a UserMetricsRecorder that rec
bruthig
2015/04/24 20:00:11
Done.
| |
| 130 UserMetricsRecorder(); | 136 UserMetricsRecorder(); |
| 131 ~UserMetricsRecorder(); | |
| 132 | 137 |
| 138 virtual ~UserMetricsRecorder(); | |
| 139 | |
| 140 // Records an Ash owned user action. | |
| 133 void RecordUserMetricsAction(ash::UserMetricsAction action); | 141 void RecordUserMetricsAction(ash::UserMetricsAction action); |
| 142 | |
| 134 private: | 143 private: |
| 144 friend class test::UserMetricsRecorderTestAPI; | |
| 145 | |
| 146 // Creates a UserMetricsRecorder and will only start the repeating timer if | |
| 147 // |record_periodic_metrics| is true. This is useful for tests that do not | |
| 148 // want the timer to be started. | |
| 149 // TODO(bruthig): Add a constructor that accepts a base::RepeatingTimer so | |
| 150 // that tests can inject a test double that can be controlled by the test. The | |
| 151 // missing piece is a suitable base::RepeatingTimer test double. | |
| 152 explicit UserMetricsRecorder(bool record_periodic_metrics); | |
| 153 | |
| 154 // Records UMA metrics. Is invoked periodically by the |timer_|. | |
|
pkotwicz
2015/04/21 16:15:17
Nit: Is invoked -> Invoked
bruthig
2015/04/24 20:00:11
Done.
| |
| 135 void RecordPeriodicMetrics(); | 155 void RecordPeriodicMetrics(); |
| 136 | 156 |
| 157 // Returns true if the user sessions is active in a multi window environment. | |
|
pkotwicz
2015/04/21 16:15:17
How about: "Returns true if the user's session is
bruthig
2015/04/24 20:00:11
Done.
| |
| 158 bool IsUserActiveInMultiWindowEnvironment() const; | |
| 159 | |
| 160 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|. | |
| 161 void StartTimer(); | |
| 162 | |
| 163 // The periodic timer that triggers metrics to be recorded. | |
| 137 base::RepeatingTimer<UserMetricsRecorder> timer_; | 164 base::RepeatingTimer<UserMetricsRecorder> timer_; |
| 165 | |
| 166 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder); | |
| 138 }; | 167 }; |
| 139 | 168 |
| 140 } // namespace ash | 169 } // namespace ash |
| 141 | 170 |
| 142 #endif // ASH_USER_METRICS_RECORDER_H_ | 171 #endif // ASH_USER_METRICS_RECORDER_H_ |
| OLD | NEW |