Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: ash/touch/touch_uma.cc

Issue 10826247: ash: Add some more touch UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/touch/touch_uma.cc
diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc
index a43af467caa74fb4305c85fdd0822cd49c85a411..f22e2902f7a9c8aef51b83eb067b42ea0fd0e7ae 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;
+ const gfx::Rect bounds = target->GetRootWindow()->bounds();
+ const int kBucketSizeX = bounds.width() / kBucketCount;
sky 2012/08/10 19:18:33 Don't use kStyle for computed values like this.
sadrul 2012/08/10 19:20:24 Done.
+ const int kBucketSizeY = 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() / kBucketSizeX),
+ base::LinearHistogram::FactoryGet("Ash.TouchPositionX", 1, kBucketCount,
+ kBucketCount + 1, base::Histogram::kUmaTargetedHistogramFlag));
+ STATIC_HISTOGRAM_POINTER_BLOCK("Ash.TouchPositionY",
+ Add(position.y() / kBucketSizeY),
+ base::LinearHistogram::FactoryGet("Ash.TouchPositionY", 1, kBucketCount,
+ kBucketCount + 1, base::Histogram::kUmaTargetedHistogramFlag));
+
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),
+ 1, kMaxTouchPoints, kMaxTouchPoints);
} else if (event.type() == ui::ET_TOUCH_RELEASED) {
if (details->last_start_time_.count(event.touch_id())) {
base::TimeDelta duration = event.time_stamp() -
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698