Chromium Code Reviews| Index: ash/touch/touch_uma.cc |
| diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc |
| index a43af467caa74fb4305c85fdd0822cd49c85a411..729a6e4e6f8d487c29da77ec0832508816db217f 100644 |
| --- a/ash/touch/touch_uma.cc |
| +++ b/ash/touch/touch_uma.cc |
| @@ -12,6 +12,11 @@ |
| #include "ui/aura/window_property.h" |
| #include "ui/base/event.h" |
| +#if defined(USE_XI2_MT) |
| +#include <X11/extensions/XInput2.h> |
| +#include <X11/Xlib.h> |
| +#endif |
| + |
| namespace { |
| enum GestureActionType { |
| @@ -267,6 +272,47 @@ void TouchUMA::RecordTouchEvent(aura::Window* target, |
| target->SetProperty(kWindowTouchDetails, details); |
| } |
| + // Record the location of the touch points. |
| + const int kBucketCount = 100; |
|
Ilya Sherman
2012/08/13 22:22:42
Optional nit: Since you have another histogram fur
Ilya Sherman
2012/08/13 22:22:42
100 buckets is rather a lot -- are you sure you ne
sadrul
2012/08/14 05:21:32
Done.
|
| + const gfx::Rect bounds = target->GetRootWindow()->bounds(); |
| + const int bucket_size_x = bounds.width() / kBucketCount; |
| + const int bucket_size_y = bounds.height() / kBucketCount; |
| + |
| + gfx::Point position = event.root_location(); |
| + |
| + // Prefer raw event location (when available) over calibrated location. |
| + if (event.HasNativeEvent()) { |
| +#if defined(USE_XI2_MT) |
| + XEvent* xevent = event.native_event(); |
| + CHECK_EQ(GenericEvent, xevent->type); |
| + XIEvent* xievent = static_cast<XIEvent*>(xevent->xcookie.data); |
| + if (xievent->evtype == XI_TouchBegin || |
| + xievent->evtype == XI_TouchUpdate || |
| + xievent->evtype == XI_TouchEnd) { |
| + XIDeviceEvent* device_event = |
| + static_cast<XIDeviceEvent*>(xevent->xcookie.data); |
| + position.SetPoint(static_cast<int>(device_event->event_x), |
| + static_cast<int>(device_event->event_y)); |
| + } else { |
| + position = ui::EventLocationFromNative(event.native_event()); |
| + } |
| +#else |
| + position = ui::EventLocationFromNative(event.native_event()); |
| +#endif |
| + } |
| + |
| + position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); |
| + position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); |
| + |
| + STATIC_HISTOGRAM_POINTER_BLOCK("Ash.TouchPositionX", |
| + Add(position.x() / bucket_size_x), |
| + base::LinearHistogram::FactoryGet("Ash.TouchPositionX", 1, kBucketCount, |
|
Ilya Sherman
2012/08/13 22:22:42
Optional nit: Since logging a sample of "0" seems
sadrul
2012/08/14 05:21:32
Done.
|
| + kBucketCount + 1, base::Histogram::kUmaTargetedHistogramFlag)); |
| + STATIC_HISTOGRAM_POINTER_BLOCK("Ash.TouchPositionY", |
| + Add(position.y() / bucket_size_y), |
| + base::LinearHistogram::FactoryGet("Ash.TouchPositionY", 1, kBucketCount, |
| + kBucketCount + 1, base::Histogram::kUmaTargetedHistogramFlag)); |
|
Ilya Sherman
2012/08/13 22:22:42
I don't think that you should be using STATIC_HIST
|
| + |
| if (event.type() == ui::ET_TOUCH_PRESSED) { |
| Shell::GetInstance()->delegate()->RecordUserMetricsAction( |
| UMA_TOUCHSCREEN_TAP_DOWN); |
| @@ -286,6 +332,13 @@ void TouchUMA::RecordTouchEvent(aura::Window* target, |
| gap.InMilliseconds()); |
| } |
| } |
| + |
| + // Record the number of touch-points currently active for the window. |
| + const int kMaxTouchPoints = 10; |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.ActiveTouchPoints", |
| + std::min(static_cast<int>(details->last_start_time_.size()), |
| + kMaxTouchPoints), |
|
Ilya Sherman
2012/08/13 22:22:42
nit: No need for the std::min; all samples above t
sadrul
2012/08/14 05:21:32
Done.
|
| + 1, kMaxTouchPoints, kMaxTouchPoints); |
|
Ilya Sherman
2012/08/13 22:22:42
nit: The bucket count should be kMaxTouchPoints +
sadrul
2012/08/14 05:21:32
Done.
|
| } else if (event.type() == ui::ET_TOUCH_RELEASED) { |
| if (details->last_start_time_.count(event.touch_id())) { |
| base::TimeDelta duration = event.time_stamp() - |