| 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/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionY", | 279 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionY", |
| 280 position.y() / bucket_size_y, | 280 position.y() / bucket_size_y, |
| 281 0, kBucketCountForLocation, kBucketCountForLocation + 1); | 281 0, kBucketCountForLocation, kBucketCountForLocation + 1); |
| 282 | 282 |
| 283 if (event.type() == ui::ET_TOUCH_PRESSED) { | 283 if (event.type() == ui::ET_TOUCH_PRESSED) { |
| 284 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 284 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 285 UMA_TOUCHSCREEN_TAP_DOWN); | 285 UMA_TOUCHSCREEN_TAP_DOWN); |
| 286 | 286 |
| 287 details->last_start_time_[event.touch_id()] = event.time_stamp(); | 287 details->last_start_time_[event.touch_id()] = event.time_stamp(); |
| 288 details->start_touch_position_[event.touch_id()] = event.root_location(); | 288 details->start_touch_position_[event.touch_id()] = event.root_location(); |
| 289 details->last_touch_position_[event.touch_id()] = event.location(); | 289 details->last_touch_position_[event.touch_id()] = |
| 290 gfx::ToFlooredPoint(event.location()); |
| 290 details->max_distance_from_start_squared_ = 0; | 291 details->max_distance_from_start_squared_ = 0; |
| 291 | 292 |
| 292 if (details->last_release_time_.ToInternalValue()) { | 293 if (details->last_release_time_.ToInternalValue()) { |
| 293 // Measuring the interval between a touch-release and the next | 294 // Measuring the interval between a touch-release and the next |
| 294 // touch-start is probably less useful when doing multi-touch (e.g. | 295 // touch-start is probably less useful when doing multi-touch (e.g. |
| 295 // gestures, or multi-touch friendly apps). So count this only if the user | 296 // gestures, or multi-touch friendly apps). So count this only if the user |
| 296 // hasn't done any multi-touch during the last 30 seconds. | 297 // hasn't done any multi-touch during the last 30 seconds. |
| 297 base::TimeDelta diff = event.time_stamp() - details->last_mt_time_; | 298 base::TimeDelta diff = event.time_stamp() - details->last_mt_time_; |
| 298 if (diff.InSeconds() > 30) { | 299 if (diff.InSeconds() > 30) { |
| 299 base::TimeDelta gap = event.time_stamp() - details->last_release_time_; | 300 base::TimeDelta gap = event.time_stamp() - details->last_release_time_; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 base::TimeDelta move_delay = event.time_stamp() - | 351 base::TimeDelta move_delay = event.time_stamp() - |
| 351 details->last_move_time_[event.touch_id()]; | 352 details->last_move_time_[event.touch_id()]; |
| 352 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveInterval", | 353 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveInterval", |
| 353 move_delay.InMilliseconds(), | 354 move_delay.InMilliseconds(), |
| 354 1, 50, 25); | 355 1, 50, 25); |
| 355 } | 356 } |
| 356 | 357 |
| 357 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); | 358 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); |
| 358 | 359 |
| 359 details->last_move_time_[event.touch_id()] = event.time_stamp(); | 360 details->last_move_time_[event.touch_id()] = event.time_stamp(); |
| 360 details->last_touch_position_[event.touch_id()] = event.location(); | 361 details->last_touch_position_[event.touch_id()] = |
| 362 gfx::ToFlooredPoint(event.location()); |
| 361 | 363 |
| 362 float cur_dist = (details->start_touch_position_[event.touch_id()] - | 364 float cur_dist = (details->start_touch_position_[event.touch_id()] - |
| 363 event.root_location()).LengthSquared(); | 365 event.root_location()).LengthSquared(); |
| 364 if (cur_dist > details->max_distance_from_start_squared_) | 366 if (cur_dist > details->max_distance_from_start_squared_) |
| 365 details->max_distance_from_start_squared_ = cur_dist; | 367 details->max_distance_from_start_squared_ = cur_dist; |
| 366 } | 368 } |
| 367 } | 369 } |
| 368 | 370 |
| 369 TouchUMA::TouchUMA() | 371 TouchUMA::TouchUMA() |
| 370 : is_single_finger_gesture_(false), | 372 : is_single_finger_gesture_(false), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 return GESTURE_WEBPAGE_SCROLL; | 432 return GESTURE_WEBPAGE_SCROLL; |
| 431 if (event.type() == ui::ET_GESTURE_TAP) | 433 if (event.type() == ui::ET_GESTURE_TAP) |
| 432 return GESTURE_WEBPAGE_TAP; | 434 return GESTURE_WEBPAGE_TAP; |
| 433 return GESTURE_UNKNOWN; | 435 return GESTURE_UNKNOWN; |
| 434 } | 436 } |
| 435 | 437 |
| 436 views::Widget* widget = views::Widget::GetWidgetForNativeView(window); | 438 views::Widget* widget = views::Widget::GetWidgetForNativeView(window); |
| 437 if (!widget) | 439 if (!widget) |
| 438 return GESTURE_UNKNOWN; | 440 return GESTURE_UNKNOWN; |
| 439 | 441 |
| 440 views::View* view = widget->GetRootView()-> | 442 views::View* view = widget->GetRootView()->GetEventHandlerForPoint( |
| 441 GetEventHandlerForPoint(event.location()); | 443 gfx::ToFlooredPoint(event.location())); |
| 442 if (!view) | 444 if (!view) |
| 443 return GESTURE_UNKNOWN; | 445 return GESTURE_UNKNOWN; |
| 444 | 446 |
| 445 name = view->GetClassName(); | 447 name = view->GetClassName(); |
| 446 | 448 |
| 447 const char kTabStrip[] = "TabStrip"; | 449 const char kTabStrip[] = "TabStrip"; |
| 448 const char kTab[] = "BrowserTab"; | 450 const char kTab[] = "BrowserTab"; |
| 449 if (name == kTabStrip || name == kTab) { | 451 if (name == kTabStrip || name == kTab) { |
| 450 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) | 452 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) |
| 451 return GESTURE_TABSTRIP_SCROLL; | 453 return GESTURE_TABSTRIP_SCROLL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 462 return GESTURE_OMNIBOX_SCROLL; | 464 return GESTURE_OMNIBOX_SCROLL; |
| 463 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) | 465 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) |
| 464 return GESTURE_OMNIBOX_PINCH; | 466 return GESTURE_OMNIBOX_PINCH; |
| 465 return GESTURE_UNKNOWN; | 467 return GESTURE_UNKNOWN; |
| 466 } | 468 } |
| 467 | 469 |
| 468 return GESTURE_UNKNOWN; | 470 return GESTURE_UNKNOWN; |
| 469 } | 471 } |
| 470 | 472 |
| 471 } // namespace ash | 473 } // namespace ash |
| OLD | NEW |