OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ash/touch/touch_uma.h" | 5 #include "ash/touch/touch_uma.h" |
6 | 6 |
7 #include "ash/shell_delegate.h" | 7 #include "ash/shell_delegate.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "ui/aura/event.h" | |
11 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
12 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
13 #include "ui/aura/window_property.h" | 12 #include "ui/aura/window_property.h" |
| 13 #include "ui/base/event.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 enum GestureActionType { | 17 enum GestureActionType { |
18 GESTURE_UNKNOWN, | 18 GESTURE_UNKNOWN, |
19 GESTURE_OMNIBOX_PINCH, | 19 GESTURE_OMNIBOX_PINCH, |
20 GESTURE_OMNIBOX_SCROLL, | 20 GESTURE_OMNIBOX_SCROLL, |
21 GESTURE_TABSTRIP_PINCH, | 21 GESTURE_TABSTRIP_PINCH, |
22 GESTURE_TABSTRIP_SCROLL, | 22 GESTURE_TABSTRIP_SCROLL, |
23 GESTURE_BEZEL_SCROLL, | 23 GESTURE_BEZEL_SCROLL, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // multi-touch gesture on the window, then this is the release-time of the | 82 // multi-touch gesture on the window, then this is the release-time of the |
83 // last touch on the window). | 83 // last touch on the window). |
84 base::TimeDelta last_mt_time_; | 84 base::TimeDelta last_mt_time_; |
85 }; | 85 }; |
86 | 86 |
87 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowTouchDetails, | 87 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WindowTouchDetails, |
88 kWindowTouchDetails, | 88 kWindowTouchDetails, |
89 NULL); | 89 NULL); |
90 | 90 |
91 GestureActionType FindGestureActionType(aura::Window* window, | 91 GestureActionType FindGestureActionType(aura::Window* window, |
92 const aura::GestureEvent& event) { | 92 const ui::GestureEventImpl& event) { |
93 if (!window || window->GetRootWindow() == window) { | 93 if (!window || window->GetRootWindow() == window) { |
94 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) | 94 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) |
95 return GESTURE_BEZEL_SCROLL; | 95 return GESTURE_BEZEL_SCROLL; |
96 return GESTURE_UNKNOWN; | 96 return GESTURE_UNKNOWN; |
97 } | 97 } |
98 | 98 |
99 std::string name = window ? window->name() : std::string(); | 99 std::string name = window ? window->name() : std::string(); |
100 | 100 |
101 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; | 101 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; |
102 if (name == kDesktopBackgroundView) { | 102 if (name == kDesktopBackgroundView) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) | 142 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) |
143 return GESTURE_OMNIBOX_SCROLL; | 143 return GESTURE_OMNIBOX_SCROLL; |
144 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) | 144 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) |
145 return GESTURE_OMNIBOX_PINCH; | 145 return GESTURE_OMNIBOX_PINCH; |
146 return GESTURE_UNKNOWN; | 146 return GESTURE_UNKNOWN; |
147 } | 147 } |
148 | 148 |
149 return GESTURE_UNKNOWN; | 149 return GESTURE_UNKNOWN; |
150 } | 150 } |
151 | 151 |
152 UMAEventType UMAEventTypeFromEvent(const aura::Event& event) { | 152 UMAEventType UMAEventTypeFromEvent(const ui::Event& event) { |
153 switch (event.type()) { | 153 switch (event.type()) { |
154 case ui::ET_TOUCH_RELEASED: | 154 case ui::ET_TOUCH_RELEASED: |
155 return UMA_ET_TOUCH_RELEASED; | 155 return UMA_ET_TOUCH_RELEASED; |
156 case ui::ET_TOUCH_PRESSED: | 156 case ui::ET_TOUCH_PRESSED: |
157 return UMA_ET_TOUCH_PRESSED; | 157 return UMA_ET_TOUCH_PRESSED; |
158 case ui::ET_TOUCH_MOVED: | 158 case ui::ET_TOUCH_MOVED: |
159 return UMA_ET_TOUCH_MOVED; | 159 return UMA_ET_TOUCH_MOVED; |
160 case ui::ET_TOUCH_STATIONARY: | 160 case ui::ET_TOUCH_STATIONARY: |
161 return UMA_ET_TOUCH_STATIONARY; | 161 return UMA_ET_TOUCH_STATIONARY; |
162 case ui::ET_TOUCH_CANCELLED: | 162 case ui::ET_TOUCH_CANCELLED: |
163 return UMA_ET_TOUCH_CANCELLED; | 163 return UMA_ET_TOUCH_CANCELLED; |
164 case ui::ET_GESTURE_SCROLL_BEGIN: | 164 case ui::ET_GESTURE_SCROLL_BEGIN: |
165 return UMA_ET_GESTURE_SCROLL_BEGIN; | 165 return UMA_ET_GESTURE_SCROLL_BEGIN; |
166 case ui::ET_GESTURE_SCROLL_END: | 166 case ui::ET_GESTURE_SCROLL_END: |
167 return UMA_ET_GESTURE_SCROLL_END; | 167 return UMA_ET_GESTURE_SCROLL_END; |
168 case ui::ET_GESTURE_SCROLL_UPDATE: { | 168 case ui::ET_GESTURE_SCROLL_UPDATE: { |
169 const aura::GestureEvent& gesture = | 169 const ui::GestureEventImpl& gesture = |
170 static_cast<const aura::GestureEvent&>(event); | 170 static_cast<const ui::GestureEventImpl&>(event); |
171 if (gesture.details().touch_points() >= 4) | 171 if (gesture.details().touch_points() >= 4) |
172 return UMA_ET_GESTURE_SCROLL_UPDATE_4P; | 172 return UMA_ET_GESTURE_SCROLL_UPDATE_4P; |
173 else if (gesture.details().touch_points() == 3) | 173 else if (gesture.details().touch_points() == 3) |
174 return UMA_ET_GESTURE_SCROLL_UPDATE_3; | 174 return UMA_ET_GESTURE_SCROLL_UPDATE_3; |
175 else if (gesture.details().touch_points() == 2) | 175 else if (gesture.details().touch_points() == 2) |
176 return UMA_ET_GESTURE_SCROLL_UPDATE_2; | 176 return UMA_ET_GESTURE_SCROLL_UPDATE_2; |
177 return UMA_ET_GESTURE_SCROLL_UPDATE; | 177 return UMA_ET_GESTURE_SCROLL_UPDATE; |
178 } | 178 } |
179 case ui::ET_GESTURE_TAP: | 179 case ui::ET_GESTURE_TAP: |
180 return UMA_ET_GESTURE_TAP; | 180 return UMA_ET_GESTURE_TAP; |
181 case ui::ET_GESTURE_TAP_DOWN: | 181 case ui::ET_GESTURE_TAP_DOWN: |
182 return UMA_ET_GESTURE_TAP_DOWN; | 182 return UMA_ET_GESTURE_TAP_DOWN; |
183 case ui::ET_GESTURE_BEGIN: | 183 case ui::ET_GESTURE_BEGIN: |
184 return UMA_ET_GESTURE_BEGIN; | 184 return UMA_ET_GESTURE_BEGIN; |
185 case ui::ET_GESTURE_END: | 185 case ui::ET_GESTURE_END: |
186 return UMA_ET_GESTURE_END; | 186 return UMA_ET_GESTURE_END; |
187 case ui::ET_GESTURE_DOUBLE_TAP: | 187 case ui::ET_GESTURE_DOUBLE_TAP: |
188 return UMA_ET_GESTURE_DOUBLE_TAP; | 188 return UMA_ET_GESTURE_DOUBLE_TAP; |
189 case ui::ET_GESTURE_TWO_FINGER_TAP: | 189 case ui::ET_GESTURE_TWO_FINGER_TAP: |
190 return UMA_ET_GESTURE_TWO_FINGER_TAP; | 190 return UMA_ET_GESTURE_TWO_FINGER_TAP; |
191 case ui::ET_GESTURE_PINCH_BEGIN: | 191 case ui::ET_GESTURE_PINCH_BEGIN: |
192 return UMA_ET_GESTURE_PINCH_BEGIN; | 192 return UMA_ET_GESTURE_PINCH_BEGIN; |
193 case ui::ET_GESTURE_PINCH_END: | 193 case ui::ET_GESTURE_PINCH_END: |
194 return UMA_ET_GESTURE_PINCH_END; | 194 return UMA_ET_GESTURE_PINCH_END; |
195 case ui::ET_GESTURE_PINCH_UPDATE: { | 195 case ui::ET_GESTURE_PINCH_UPDATE: { |
196 const aura::GestureEvent& gesture = | 196 const ui::GestureEventImpl& gesture = |
197 static_cast<const aura::GestureEvent&>(event); | 197 static_cast<const ui::GestureEventImpl&>(event); |
198 if (gesture.details().touch_points() >= 4) | 198 if (gesture.details().touch_points() >= 4) |
199 return UMA_ET_GESTURE_PINCH_UPDATE_4P; | 199 return UMA_ET_GESTURE_PINCH_UPDATE_4P; |
200 else if (gesture.details().touch_points() == 3) | 200 else if (gesture.details().touch_points() == 3) |
201 return UMA_ET_GESTURE_PINCH_UPDATE_3; | 201 return UMA_ET_GESTURE_PINCH_UPDATE_3; |
202 return UMA_ET_GESTURE_PINCH_UPDATE; | 202 return UMA_ET_GESTURE_PINCH_UPDATE; |
203 } | 203 } |
204 case ui::ET_GESTURE_LONG_PRESS: | 204 case ui::ET_GESTURE_LONG_PRESS: |
205 return UMA_ET_GESTURE_LONG_PRESS; | 205 return UMA_ET_GESTURE_LONG_PRESS; |
206 case ui::ET_GESTURE_MULTIFINGER_SWIPE: { | 206 case ui::ET_GESTURE_MULTIFINGER_SWIPE: { |
207 const aura::GestureEvent& gesture = | 207 const ui::GestureEventImpl& gesture = |
208 static_cast<const aura::GestureEvent&>(event); | 208 static_cast<const ui::GestureEventImpl&>(event); |
209 if (gesture.details().touch_points() >= 4) | 209 if (gesture.details().touch_points() >= 4) |
210 return UMA_ET_GESTURE_MULTIFINGER_SWIPE_4P; | 210 return UMA_ET_GESTURE_MULTIFINGER_SWIPE_4P; |
211 else if (gesture.details().touch_points() == 3) | 211 else if (gesture.details().touch_points() == 3) |
212 return UMA_ET_GESTURE_MULTIFINGER_SWIPE_3; | 212 return UMA_ET_GESTURE_MULTIFINGER_SWIPE_3; |
213 return UMA_ET_GESTURE_MULTIFINGER_SWIPE; | 213 return UMA_ET_GESTURE_MULTIFINGER_SWIPE; |
214 } | 214 } |
215 case ui::ET_SCROLL: | 215 case ui::ET_SCROLL: |
216 return UMA_ET_SCROLL; | 216 return UMA_ET_SCROLL; |
217 case ui::ET_SCROLL_FLING_START: | 217 case ui::ET_SCROLL_FLING_START: |
218 return UMA_ET_SCROLL_FLING_START; | 218 return UMA_ET_SCROLL_FLING_START; |
219 case ui::ET_SCROLL_FLING_CANCEL: | 219 case ui::ET_SCROLL_FLING_CANCEL: |
220 return UMA_ET_SCROLL_FLING_CANCEL; | 220 return UMA_ET_SCROLL_FLING_CANCEL; |
221 default: | 221 default: |
222 return UMA_ET_UNKNOWN; | 222 return UMA_ET_UNKNOWN; |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 } | 226 } |
227 | 227 |
228 namespace ash { | 228 namespace ash { |
229 namespace internal { | 229 namespace internal { |
230 | 230 |
231 TouchUMA::TouchUMA() { | 231 TouchUMA::TouchUMA() { |
232 } | 232 } |
233 | 233 |
234 TouchUMA::~TouchUMA() { | 234 TouchUMA::~TouchUMA() { |
235 } | 235 } |
236 | 236 |
237 void TouchUMA::RecordGestureEvent(aura::Window* target, | 237 void TouchUMA::RecordGestureEvent(aura::Window* target, |
238 const aura::GestureEvent& event) { | 238 const ui::GestureEventImpl& event) { |
239 UMA_HISTOGRAM_ENUMERATION("Ash.GestureCreated", | 239 UMA_HISTOGRAM_ENUMERATION("Ash.GestureCreated", |
240 UMAEventTypeFromEvent(event), | 240 UMAEventTypeFromEvent(event), |
241 UMA_ET_COUNT); | 241 UMA_ET_COUNT); |
242 | 242 |
243 GestureActionType action = FindGestureActionType(target, event); | 243 GestureActionType action = FindGestureActionType(target, event); |
244 if (action != GESTURE_UNKNOWN) { | 244 if (action != GESTURE_UNKNOWN) { |
245 UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget", | 245 UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget", |
246 action, | 246 action, |
247 GESTURE_ACTION_COUNT); | 247 GESTURE_ACTION_COUNT); |
248 } | 248 } |
249 | 249 |
250 if (event.type() == ui::ET_GESTURE_END && | 250 if (event.type() == ui::ET_GESTURE_END && |
251 event.details().touch_points() == 2) { | 251 event.details().touch_points() == 2) { |
252 WindowTouchDetails* details = target->GetProperty(kWindowTouchDetails); | 252 WindowTouchDetails* details = target->GetProperty(kWindowTouchDetails); |
253 CHECK(details) << "Window received gesture but no touch events?"; | 253 CHECK(details) << "Window received gesture but no touch events?"; |
254 details->last_mt_time_ = event.time_stamp(); | 254 details->last_mt_time_ = event.time_stamp(); |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 void TouchUMA::RecordTouchEvent(aura::Window* target, | 258 void TouchUMA::RecordTouchEvent(aura::Window* target, |
259 const aura::TouchEvent& event) { | 259 const ui::TouchEventImpl& event) { |
260 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchRadius", | 260 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchRadius", |
261 static_cast<int>(std::max(event.radius_x(), event.radius_y())), | 261 static_cast<int>(std::max(event.radius_x(), event.radius_y())), |
262 1, 500, 100); | 262 1, 500, 100); |
263 | 263 |
264 WindowTouchDetails* details = target->GetProperty(kWindowTouchDetails); | 264 WindowTouchDetails* details = target->GetProperty(kWindowTouchDetails); |
265 if (!details) { | 265 if (!details) { |
266 details = new WindowTouchDetails; | 266 details = new WindowTouchDetails; |
267 target->SetProperty(kWindowTouchDetails, details); | 267 target->SetProperty(kWindowTouchDetails, details); |
268 } | 268 } |
269 | 269 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); | 314 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); |
315 | 315 |
316 details->last_move_time_[event.touch_id()] = event.time_stamp(); | 316 details->last_move_time_[event.touch_id()] = event.time_stamp(); |
317 details->last_touch_position_[event.touch_id()] = event.location(); | 317 details->last_touch_position_[event.touch_id()] = event.location(); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 } // namespace internal | 321 } // namespace internal |
322 } // namespace ash | 322 } // namespace ash |
OLD | NEW |