Chromium Code Reviews| Index: ui/touch_selection/touch_selection_controller.cc |
| diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc |
| index d53f4095e05195aa24e52ff1f6ea2a45770a8632..16de0cb1019f938ebe930d82294a77a2ec080d00 100644 |
| --- a/ui/touch_selection/touch_selection_controller.cc |
| +++ b/ui/touch_selection/touch_selection_controller.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/auto_reset.h" |
| #include "base/logging.h" |
| +#include "base/metrics/histogram_macros.h" |
| namespace ui { |
| namespace { |
| @@ -61,6 +62,8 @@ TouchSelectionController::TouchSelectionController( |
| } |
| TouchSelectionController::~TouchSelectionController() { |
| + if (is_selection_active_) |
| + LogSelectionEnd(); |
| } |
| void TouchSelectionController::OnSelectionBoundsChanged( |
| @@ -385,7 +388,12 @@ void TouchSelectionController::ActivateSelection() { |
| // an entirely new selection, notify the client but avoid sending an |
| // intervening SELECTION_CLEARED update to avoid unnecessary state changes. |
| if (!is_selection_active_ || response_pending_input_event_ == LONG_PRESS) { |
| + if (is_selection_active_) { |
| + // The active selection session finishes with the start of the new one. |
| + LogSelectionEnd(); |
| + } |
| is_selection_active_ = true; |
| + selection_start_time_ = base::Time::Now(); |
| response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; |
| client_->OnSelectionEvent(SELECTION_SHOWN, GetStartPosition()); |
| } |
| @@ -396,6 +404,7 @@ void TouchSelectionController::DeactivateSelection() { |
| return; |
| DCHECK(start_selection_handle_); |
| DCHECK(end_selection_handle_); |
| + LogSelectionEnd(); |
| start_selection_handle_->SetEnabled(false); |
| end_selection_handle_->SetEnabled(false); |
| is_selection_active_ = false; |
| @@ -442,4 +451,13 @@ TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( |
| : TouchHandle::ANIMATION_NONE; |
| } |
| +void TouchSelectionController::LogSelectionEnd() { |
| + base::TimeDelta duration = base::Time::Now() - selection_start_time_; |
|
jdduke (slow)
2015/02/05 21:00:28
Shouldn't we be using TimeTicks (CPU time), not Ti
mfomitchev
2015/02/05 21:28:31
Good point. Fixed.
|
| + UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelectionDuration", |
| + duration, |
| + base::TimeDelta::FromMilliseconds(1), |
| + base::TimeDelta::FromSeconds(60), |
| + 50); |
| +} |
| + |
| } // namespace ui |