| 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/root_window.h" | 10 #include "ui/aura/root_window.h" |
| (...skipping 71 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 ui::GestureEventImpl& event) { | 92 const ui::GestureEvent& 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ui::GestureEventImpl& gesture = | 169 const ui::GestureEvent& gesture = |
| 170 static_cast<const ui::GestureEventImpl&>(event); | 170 static_cast<const ui::GestureEvent&>(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 ui::GestureEventImpl& gesture = | 196 const ui::GestureEvent& gesture = |
| 197 static_cast<const ui::GestureEventImpl&>(event); | 197 static_cast<const ui::GestureEvent&>(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 ui::GestureEventImpl& gesture = | 207 const ui::GestureEvent& gesture = |
| 208 static_cast<const ui::GestureEventImpl&>(event); | 208 static_cast<const ui::GestureEvent&>(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 ui::GestureEventImpl& event) { | 238 const ui::GestureEvent& 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 } |
| (...skipping 64 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 |