| 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" |
| 10 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
| 11 | 12 |
| 12 namespace ash { | 13 namespace ash { |
| 13 | 14 |
| 15 class UserMetricsRecorderProxy; |
| 16 |
| 14 namespace test { | 17 namespace test { |
| 15 class UserMetricsRecorderTestAPI; | 18 class UserMetricsRecorderTestAPI; |
| 16 } | 19 } |
| 17 | 20 |
| 18 enum UserMetricsAction { | 21 enum UserMetricsAction { |
| 19 UMA_ACCEL_EXIT_FIRST_Q, | 22 UMA_ACCEL_EXIT_FIRST_Q, |
| 20 UMA_ACCEL_EXIT_SECOND_Q, | 23 UMA_ACCEL_EXIT_SECOND_Q, |
| 21 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6, | 24 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6, |
| 22 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7, | 25 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7, |
| 23 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON, | 26 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 friend class test::UserMetricsRecorderTestAPI; | 160 friend class test::UserMetricsRecorderTestAPI; |
| 158 | 161 |
| 159 // Creates a UserMetricsRecorder and will only record periodic metrics if | 162 // Creates a UserMetricsRecorder and will only record periodic metrics if |
| 160 // |record_periodic_metrics| is true. This is used by tests that do not want | 163 // |record_periodic_metrics| is true. This is used by tests that do not want |
| 161 // the timer to be started. | 164 // the timer to be started. |
| 162 // TODO(bruthig): Add a constructor that accepts a base::RepeatingTimer so | 165 // TODO(bruthig): Add a constructor that accepts a base::RepeatingTimer so |
| 163 // that tests can inject a test double that can be controlled by the test. The | 166 // that tests can inject a test double that can be controlled by the test. The |
| 164 // missing piece is a suitable base::RepeatingTimer test double. | 167 // missing piece is a suitable base::RepeatingTimer test double. |
| 165 explicit UserMetricsRecorder(bool record_periodic_metrics); | 168 explicit UserMetricsRecorder(bool record_periodic_metrics); |
| 166 | 169 |
| 170 void Init(bool record_periodic_metrics); |
| 171 |
| 167 // Records UMA metrics. Invoked periodically by the |timer_|. | 172 // Records UMA metrics. Invoked periodically by the |timer_|. |
| 168 void RecordPeriodicMetrics(); | 173 void RecordPeriodicMetrics(); |
| 169 | 174 |
| 170 // Returns true if the user's session is active and they are in a desktop | 175 // Returns true if the user's session is active and they are in a desktop |
| 171 // environment. | 176 // environment. |
| 172 bool IsUserInActiveDesktopEnvironment() const; | 177 bool IsUserInActiveDesktopEnvironment() const; |
| 173 | 178 |
| 174 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|. | 179 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|. |
| 175 void StartTimer(); | 180 void StartTimer(); |
| 176 | 181 |
| 177 // The periodic timer that triggers metrics to be recorded. | 182 // The periodic timer that triggers metrics to be recorded. |
| 178 base::RepeatingTimer<UserMetricsRecorder> timer_; | 183 base::RepeatingTimer<UserMetricsRecorder> timer_; |
| 179 | 184 |
| 180 TaskSwitchMetricsRecorder task_switch_metrics_recorder_; | 185 TaskSwitchMetricsRecorder task_switch_metrics_recorder_; |
| 181 | 186 |
| 187 scoped_ptr<UserMetricsRecorderProxy> user_metrics_recorder_proxy_; |
| 188 |
| 182 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder); | 189 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder); |
| 183 }; | 190 }; |
| 184 | 191 |
| 185 } // namespace ash | 192 } // namespace ash |
| 186 | 193 |
| 187 #endif // ASH_METRICS_USER_METRICS_RECORDER_H_ | 194 #endif // ASH_METRICS_USER_METRICS_RECORDER_H_ |
| OLD | NEW |