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

Side by Side Diff: ash/metrics/user_metrics_recorder.h

Issue 1093483002: Changed when the UMA metric Ash.NumberOfVisibleWindowsInPrimaryDisplay is recorded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed pkotwicz@ comments from patch set 3. Created 5 years, 8 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 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
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 records metrics periodically. Equivalent
135 // to calling UserMetricsRecorder(true).
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 record periodic metrics if
147 // |record_periodic_metrics| is true. This is useful for tests that do not
148 // want the timer to be started.
oshima 2015/04/25 01:06:58 can you be more explicit that this is for test? li
bruthig 2015/04/27 15:22:21 Done.
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. Invoked periodically by the |timer_|.
135 void RecordPeriodicMetrics(); 155 void RecordPeriodicMetrics();
136 156
157 // Returns true if the user's session is active and the user is in a multi
158 // window environment.
oshima 2015/04/25 01:06:58 "multi window environment" sounds a bit odd. how a
bruthig 2015/04/27 15:22:21 Done.
159 bool IsUserActiveInMultiWindowEnvironment() const;
160
161 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|.
162 void StartTimer();
163
164 // The periodic timer that triggers metrics to be recorded.
137 base::RepeatingTimer<UserMetricsRecorder> timer_; 165 base::RepeatingTimer<UserMetricsRecorder> timer_;
166
167 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder);
138 }; 168 };
139 169
140 } // namespace ash 170 } // namespace ash
141 171
142 #endif // ASH_USER_METRICS_RECORDER_H_ 172 #endif // ASH_USER_METRICS_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698