summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-09 18:16:31 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-09 18:16:31 +0000
commit0008f6ee4e312bb1bcc6a9997c93ded9aa1040f3 (patch)
tree4ab1020d4547bb6992f200a2670d015ebd45af4b /ash
parentf71b101e1edc7042ee46055bd79ea7af00f1ff0e (diff)
downloadchromium_src-0008f6ee4e312bb1bcc6a9997c93ded9aa1040f3.zip
chromium_src-0008f6ee4e312bb1bcc6a9997c93ded9aa1040f3.tar.gz
chromium_src-0008f6ee4e312bb1bcc6a9997c93ded9aa1040f3.tar.bz2
ash: Improve UMA data for gestures on specific UI components.
Collecting UMA for all gestures on all UI components is expensive and not all that useful. So instead, collection very targetted data for only some gestures on some UI elements. BUG=121179 TEST=manually Review URL: https://chromiumcodereview.appspot.com/10700108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145698 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/touch/touch_uma.cc100
1 files changed, 79 insertions, 21 deletions
diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc
index 02dfe34..8a0167b 100644
--- a/ash/touch/touch_uma.cc
+++ b/ash/touch/touch_uma.cc
@@ -7,24 +7,84 @@
#include "base/metrics/histogram.h"
#include "base/stringprintf.h"
#include "ui/aura/event.h"
+#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
namespace {
-std::string FindAppropriateHistogramNameFromTarget(aura::Window* window,
- const gfx::Point& location) {
+enum GestureActionType {
+ GESTURE_UNKNOWN,
+ GESTURE_OMNIBOX_PINCH,
+ GESTURE_OMNIBOX_SCROLL,
+ GESTURE_TABSTRIP_PINCH,
+ GESTURE_TABSTRIP_SCROLL,
+ GESTURE_BEZEL_SCROLL,
+ GESTURE_DESKTOP_SCROLL,
+ GESTURE_DESKTOP_PINCH,
+ GESTURE_WEBPAGE_PINCH,
+// NOTE: Add new action types only immediately above this line. Also, make sure
+// the enum list in tools/histogram/histograms.xml is updated with any change in
+// here.
+ GESTURE_ACTION_COUNT
+};
+
+GestureActionType FindGestureActionType(aura::Window* window,
+ const aura::GestureEvent& event) {
+ if (!window || window->GetRootWindow() == window) {
+ if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
+ return GESTURE_BEZEL_SCROLL;
+ return GESTURE_UNKNOWN;
+ }
+
std::string name = window ? window->name() : std::string();
+
+ const char kDesktopBackgroundView[] = "DesktopBackgroundView";
+ if (name == kDesktopBackgroundView) {
+ if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
+ return GESTURE_DESKTOP_SCROLL;
+ if (event.type() == ui::ET_GESTURE_PINCH_BEGIN)
+ return GESTURE_DESKTOP_PINCH;
+ return GESTURE_UNKNOWN;
+ }
+
+ const char kWebPage[] = "RenderWidgetHostViewAura";
+ if (name == kWebPage) {
+ if (event.type() == ui::ET_GESTURE_PINCH_BEGIN)
+ return GESTURE_WEBPAGE_PINCH;
+ return GESTURE_UNKNOWN;
+ }
+
views::Widget* widget = views::Widget::GetWidgetForNativeView(window);
- if (widget) {
- views::View* view =
- widget->GetRootView()->GetEventHandlerForPoint(location);
- if (view)
- name = view->GetClassName();
+ if (!widget)
+ return GESTURE_UNKNOWN;
+
+ views::View* view = widget->GetRootView()->
+ GetEventHandlerForPoint(event.location());
+ if (!view)
+ return GESTURE_UNKNOWN;
+
+ name = view->GetClassName();
+
+ const char kTabStrip[] = "TabStrip";
+ const char kTab[] = "BrowserTab";
+ if (name == kTabStrip || name == kTab) {
+ if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
+ return GESTURE_TABSTRIP_SCROLL;
+ if (event.type() == ui::ET_GESTURE_PINCH_BEGIN)
+ return GESTURE_TABSTRIP_PINCH;
+ return GESTURE_UNKNOWN;
}
- if (name.empty())
- name = "[unknown]";
- return name;
+ const char kOmnibox[] = "BrowserOmniboxViewViews";
+ if (name == kOmnibox) {
+ if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
+ return GESTURE_OMNIBOX_SCROLL;
+ if (event.type() == ui::ET_GESTURE_PINCH_BEGIN)
+ return GESTURE_OMNIBOX_PINCH;
+ return GESTURE_UNKNOWN;
+ }
+
+ return GESTURE_UNKNOWN;
}
std::vector<int> GetEventCodes() {
@@ -81,17 +141,15 @@ TouchUMA::~TouchUMA() {
void TouchUMA::RecordGestureEvent(aura::Window* target,
const aura::GestureEvent& event) {
UMA_HISTOGRAM_ENUMERATION("Ash.GestureCreated",
- ui_event_type_map_[event.type()],
- ui_event_type_map_.size());
-
- // Try to record the component the gesture was created on.
- std::string component = FindAppropriateHistogramNameFromTarget(target,
- event.location());
- base::Histogram* histogram = base::LinearHistogram::FactoryGet(
- StringPrintf("Ash.GestureTarget.%s", component.c_str()),
- 1, ui_event_type_map_.size(), ui_event_type_map_.size() + 1,
- base::Histogram::kUmaTargetedHistogramFlag);
- histogram->Add(ui_event_type_map_[event.type()]);
+ ui_event_type_map_[event.type()],
+ ui_event_type_map_.size());
+
+ GestureActionType action = FindGestureActionType(target, event);
+ if (action != GESTURE_UNKNOWN) {
+ UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget",
+ action,
+ GESTURE_ACTION_COUNT);
+ }
}
void TouchUMA::RecordTouchEvent(aura::Window* target,