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..0f512060e68f39b8c2c928f05943b8f85c6c2a44 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 { |
@@ -55,12 +56,15 @@ TouchSelectionController::TouchSelectionController( |
activate_selection_automatically_(false), |
selection_empty_(false), |
selection_editable_(false), |
- temporarily_hidden_(false) { |
+ temporarily_hidden_(false), |
+ selection_handle_dragged_(false) { |
DCHECK(client_); |
HideAndDisallowShowingAutomatically(); |
} |
TouchSelectionController::~TouchSelectionController() { |
jdduke (slow)
2015/02/10 17:50:25
I'm not sure we ought to count this case, as this
mfomitchev
2015/02/10 19:05:23
Sure. Got rid of this.
|
+ if (is_selection_active_) |
+ LogSelectionEnd(); |
} |
void TouchSelectionController::OnSelectionBoundsChanged( |
@@ -239,6 +243,7 @@ void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) { |
base = start_selection_handle_->position() + GetStartLineOffset(); |
extent = end_selection_handle_->position() + GetEndLineOffset(); |
} |
+ selection_handle_dragged_ = true; |
// When moving the handle we want to move only the extent point. Before doing |
// so we must make sure that the base point is set correctly. |
@@ -385,7 +390,13 @@ 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_handle_dragged_ = false; |
+ selection_start_time_ = base::TimeTicks::Now(); |
response_pending_input_event_ = INPUT_EVENT_TYPE_NONE; |
client_->OnSelectionEvent(SELECTION_SHOWN, GetStartPosition()); |
} |
@@ -396,6 +407,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 +454,19 @@ TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( |
: TouchHandle::ANIMATION_NONE; |
} |
+void TouchSelectionController::LogSelectionEnd() { |
+ // TODO(mfomitchev): Once we are able to tell the difference between |
+ // 'successful' and 'unsuccessful' selections - log |
+ // Event.TouchSelectionDuration instead and get rid of |
+ // Event.TouchDragSelectionDuration. |
+ if (selection_handle_dragged_) { |
+ base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; |
+ UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchDragSelectionDuration", |
+ duration, |
+ base::TimeDelta::FromMilliseconds(1), |
+ base::TimeDelta::FromSeconds(60), |
+ 50); |
jdduke (slow)
2015/02/10 17:50:25
Is this enough buckets to get the granularity we w
mfomitchev
2015/02/10 19:05:23
That's a good point. The time scale is logarithmic
jdduke (slow)
2015/02/10 19:08:05
Ah, I didn't realize it was logarithmic, thanks.
|
+ } |
+} |
+ |
} // namespace ui |