Don't preload rarely seen large images
[chromium-blink-merge.git] / ash / metrics / user_metrics_recorder.h
blobfb6669d654f4e994cb7714944924a120d4ff1be6
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
3 // found in the LICENSE file.
5 #ifndef ASH_METRICS_USER_METRICS_RECORDER_H_
6 #define ASH_METRICS_USER_METRICS_RECORDER_H_
8 #include "ash/ash_export.h"
9 #include "ash/metrics/task_switch_metrics_recorder.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/timer/timer.h"
13 namespace ash {
15 class DesktopTaskSwitchMetricRecorder;
17 namespace test {
18 class UserMetricsRecorderTestAPI;
21 enum UserMetricsAction {
22 UMA_ACCEL_EXIT_FIRST_Q,
23 UMA_ACCEL_EXIT_SECOND_Q,
24 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6,
25 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7,
26 UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON,
27 UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON,
28 UMA_ACCEL_MAXIMIZE_RESTORE_F4,
29 UMA_ACCEL_PREVWINDOW_F5,
30 UMA_ACCEL_RESTART_POWER_BUTTON,
31 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON,
32 UMA_CLOSE_THROUGH_CONTEXT_MENU,
33 UMA_DESKTOP_SWITCH_TASK,
34 UMA_DRAG_MAXIMIZE_LEFT,
35 UMA_DRAG_MAXIMIZE_RIGHT,
36 UMA_GESTURE_OVERVIEW,
37 UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE,
38 UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH,
39 UMA_LAUNCHER_CLICK_ON_APP,
40 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON,
41 UMA_LAUNCHER_LAUNCH_TASK,
42 UMA_LAUNCHER_MINIMIZE_TASK,
43 UMA_LAUNCHER_SWITCH_TASK,
44 UMA_MAXIMIZE_MODE_DISABLED,
45 UMA_MAXIMIZE_MODE_ENABLED,
46 UMA_MAXIMIZE_MODE_INITIALLY_DISABLED,
47 UMA_MOUSE_DOWN,
48 UMA_PANEL_MINIMIZE_CAPTION_CLICK,
49 UMA_PANEL_MINIMIZE_CAPTION_GESTURE,
50 UMA_SHELF_ALIGNMENT_SET_BOTTOM,
51 UMA_SHELF_ALIGNMENT_SET_LEFT,
52 UMA_SHELF_ALIGNMENT_SET_RIGHT,
53 UMA_STATUS_AREA_AUDIO_CURRENT_INPUT_DEVICE,
54 UMA_STATUS_AREA_AUDIO_CURRENT_OUTPUT_DEVICE,
55 UMA_STATUS_AREA_AUDIO_SWITCH_INPUT_DEVICE,
56 UMA_STATUS_AREA_AUDIO_SWITCH_OUTPUT_DEVICE,
57 UMA_STATUS_AREA_BRIGHTNESS_CHANGED,
58 UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE,
59 UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE,
60 UMA_STATUS_AREA_BLUETOOTH_DISABLED,
61 UMA_STATUS_AREA_BLUETOOTH_ENABLED,
62 UMA_STATUS_AREA_CAPS_LOCK_DETAILED,
63 UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK,
64 UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK,
65 UMA_STATUS_AREA_CAPS_LOCK_POPUP,
66 UMA_STATUS_AREA_CAST_STOP_CAST,
67 UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK,
68 UMA_STATUS_AREA_CONNECT_TO_UNCONFIGURED_NETWORK,
69 UMA_STATUS_AREA_CONNECT_TO_VPN,
70 UMA_STATUS_AREA_CHANGED_VOLUME_MENU,
71 UMA_STATUS_AREA_CHANGED_VOLUME_POPUP,
72 UMA_STATUS_AREA_DETAILED_ACCESSABILITY,
73 UMA_STATUS_AREA_DETAILED_AUDIO_VIEW,
74 UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW,
75 UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW,
76 UMA_STATUS_AREA_DETAILED_CAST_VIEW,
77 UMA_STATUS_AREA_DETAILED_CAST_VIEW_LAUNCH_CAST,
78 UMA_STATUS_AREA_DETAILED_DRIVE_VIEW,
79 UMA_STATUS_AREA_DETAILED_NETWORK_VIEW,
80 UMA_STATUS_AREA_DETAILED_VPN_VIEW,
81 UMA_STATUS_AREA_DISABLE_AUTO_CLICK,
82 UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST,
83 UMA_STATUS_AREA_DISABLE_LARGE_CURSOR,
84 UMA_STATUS_AREA_DISABLE_MAGNIFIER,
85 UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK,
86 UMA_STATUS_AREA_DISABLE_WIFI,
87 UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD,
88 UMA_STATUS_AREA_DRIVE_CANCEL_OPERATION,
89 UMA_STATUS_AREA_DRIVE_SETTINGS,
90 UMA_STATUS_AREA_ENABLE_AUTO_CLICK,
91 UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST,
92 UMA_STATUS_AREA_ENABLE_LARGE_CURSOR,
93 UMA_STATUS_AREA_ENABLE_MAGNIFIER,
94 UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK,
95 UMA_STATUS_AREA_ENABLE_WIFI,
96 UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD,
97 UMA_STATUS_AREA_IME_SHOW_DETAILED,
98 UMA_STATUS_AREA_IME_SWITCH_MODE,
99 UMA_STATUS_AREA_MENU_OPENED,
100 UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED,
101 UMA_STATUS_AREA_NETWORK_SETTINGS_CLICKED,
102 UMA_STATUS_AREA_SHOW_NETWORK_CONNECTION_DETAILS,
103 UMA_STATUS_AREA_SHOW_VPN_CONNECTION_DETAILS,
104 UMA_STATUS_AREA_SIGN_OUT,
105 UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED,
106 UMA_STATUS_AREA_VPN_ADD_THIRD_PARTY_CLICKED,
107 UMA_STATUS_AREA_VPN_DISCONNECT_CLICKED,
108 UMA_STATUS_AREA_VPN_SETTINGS_CLICKED,
109 UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK,
110 UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE,
111 UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK,
112 UMA_TOUCHPAD_GESTURE_OVERVIEW,
113 UMA_TOUCHSCREEN_TAP_DOWN,
114 UMA_TRAY_HELP,
115 UMA_TRAY_LOCK_SCREEN,
116 UMA_TRAY_OVERVIEW,
117 UMA_TRAY_SHUT_DOWN,
118 UMA_WINDOW_APP_CLOSE_BUTTON_CLICK,
119 UMA_WINDOW_CLOSE_BUTTON_CLICK,
120 UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_EXIT_FULLSCREEN,
121 UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MAXIMIZE,
122 UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MINIMIZE,
123 UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_RESTORE,
124 UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT,
125 UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT,
127 // Thumbnail sized overview of windows triggered by pressing the overview key.
128 UMA_WINDOW_OVERVIEW,
130 // User selected a window in overview mode different from the
131 // previously-active window.
132 UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED,
134 // Selecting a window in overview mode by pressing the enter key.
135 UMA_WINDOW_OVERVIEW_ENTER_KEY,
137 // Window selection started by beginning an alt+tab cycle. This does not count
138 // each step through an alt+tab cycle.
139 UMA_WINDOW_CYCLE,
142 // User Metrics Recorder provides a repeating callback (RecordPeriodicMetrics)
143 // on a timer to allow recording of state data over time to the UMA records.
144 // Any additional states (in ash) that require monitoring can be added to
145 // this class. As well calls to record on action metrics
146 // (RecordUserMetricsAction) are passed through the UserMetricsRecorder.
147 class ASH_EXPORT UserMetricsRecorder {
148 public:
149 // Creates a UserMetricsRecorder that records metrics periodically. Equivalent
150 // to calling UserMetricsRecorder(true).
151 UserMetricsRecorder();
153 virtual ~UserMetricsRecorder();
155 // Records an Ash owned user action.
156 void RecordUserMetricsAction(ash::UserMetricsAction action);
158 TaskSwitchMetricsRecorder& task_switch_metrics_recorder() {
159 return task_switch_metrics_recorder_;
162 // Informs |this| that the Shell has been initialized.
163 void OnShellInitialized();
165 // Informs |this| that the Shell is going to be shut down.
166 void OnShellShuttingDown();
168 private:
169 friend class test::UserMetricsRecorderTestAPI;
171 // Creates a UserMetricsRecorder and will only record periodic metrics if
172 // |record_periodic_metrics| is true. This is used by tests that do not want
173 // the timer to be started.
174 // TODO(bruthig): Add a constructor that accepts a base::RepeatingTimer so
175 // that tests can inject a test double that can be controlled by the test. The
176 // missing piece is a suitable base::RepeatingTimer test double.
177 explicit UserMetricsRecorder(bool record_periodic_metrics);
179 // Records UMA metrics. Invoked periodically by the |timer_|.
180 void RecordPeriodicMetrics();
182 // Returns true if the user's session is active and they are in a desktop
183 // environment.
184 bool IsUserInActiveDesktopEnvironment() const;
186 // Starts the |timer_| and binds it to |RecordPeriodicMetrics|.
187 void StartTimer();
189 // The periodic timer that triggers metrics to be recorded.
190 base::RepeatingTimer<UserMetricsRecorder> timer_;
192 TaskSwitchMetricsRecorder task_switch_metrics_recorder_;
194 // Metric recorder to track how often task windows are activated by mouse
195 // clicks or touchscreen taps.
196 scoped_ptr<DesktopTaskSwitchMetricRecorder>
197 desktop_task_switch_metric_recorder_;
199 DISALLOW_COPY_AND_ASSIGN(UserMetricsRecorder);
202 } // namespace ash
204 #endif // ASH_METRICS_USER_METRICS_RECORDER_H_