summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-26 17:17:42 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-26 17:17:42 +0000
commit332aaf7b7c14317d4384240944439a8e6fcde692 (patch)
tree883cab7d1a705a995cf20085109c40ee5fc96fda /ash
parent18c0fa1653a5ac98a047bf959e2cc0e32db29dca (diff)
downloadchromium_src-332aaf7b7c14317d4384240944439a8e6fcde692.zip
chromium_src-332aaf7b7c14317d4384240944439a8e6fcde692.tar.gz
chromium_src-332aaf7b7c14317d4384240944439a8e6fcde692.tar.bz2
ash: Record some UMA for gestures.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10663026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/accelerator_dispatcher.h4
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/touch/touch_uma.cc103
-rw-r--r--ash/touch/touch_uma.h46
-rw-r--r--ash/wm/system_gesture_event_filter.cc2
-rw-r--r--ash/wm/system_gesture_event_filter.h4
6 files changed, 159 insertions, 2 deletions
diff --git a/ash/accelerators/accelerator_dispatcher.h b/ash/accelerators/accelerator_dispatcher.h
index fcc69f0..2c8fb7b 100644
--- a/ash/accelerators/accelerator_dispatcher.h
+++ b/ash/accelerators/accelerator_dispatcher.h
@@ -22,8 +22,8 @@ namespace ash {
class ASH_EXPORT AcceleratorDispatcher : public MessageLoop::Dispatcher,
public aura::WindowObserver {
public:
- explicit AcceleratorDispatcher(MessageLoop::Dispatcher* nested_dispatcher,
- aura::Window* associated_window);
+ AcceleratorDispatcher(MessageLoop::Dispatcher* nested_dispatcher,
+ aura::Window* associated_window);
virtual ~AcceleratorDispatcher();
// MessageLoop::Dispatcher overrides:
diff --git a/ash/ash.gyp b/ash/ash.gyp
index d2e57aa..964834c9 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -203,6 +203,8 @@
'tooltips/tooltip_controller.h',
'touch/touch_observer_hud.cc',
'touch/touch_observer_hud.h',
+ 'touch/touch_uma.cc',
+ 'touch/touch_uma.h',
'ui_controls_ash.cc',
'volume_control_delegate.h',
'wm/app_list_controller.cc',
diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc
new file mode 100644
index 0000000..02dfe34
--- /dev/null
+++ b/ash/touch/touch_uma.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/touch/touch_uma.h"
+
+#include "base/metrics/histogram.h"
+#include "base/stringprintf.h"
+#include "ui/aura/event.h"
+#include "ui/aura/window.h"
+
+namespace {
+
+std::string FindAppropriateHistogramNameFromTarget(aura::Window* window,
+ const gfx::Point& location) {
+ std::string name = window ? window->name() : std::string();
+ views::Widget* widget = views::Widget::GetWidgetForNativeView(window);
+ if (widget) {
+ views::View* view =
+ widget->GetRootView()->GetEventHandlerForPoint(location);
+ if (view)
+ name = view->GetClassName();
+ }
+
+ if (name.empty())
+ name = "[unknown]";
+ return name;
+}
+
+std::vector<int> GetEventCodes() {
+ // NOTE: Add new events only at the end of this list. Also, make sure the enum
+ // list in tools/histogram/histograms.xml is also updated.
+ int types[] = {
+ ui::ET_UNKNOWN, // This is to make sure that every intersting value
+ // has positive index.
+ ui::ET_TOUCH_RELEASED,
+ ui::ET_TOUCH_PRESSED,
+ ui::ET_TOUCH_MOVED,
+ ui::ET_TOUCH_STATIONARY,
+ ui::ET_TOUCH_CANCELLED,
+ ui::ET_GESTURE_SCROLL_BEGIN,
+ ui::ET_GESTURE_SCROLL_END,
+ ui::ET_GESTURE_SCROLL_UPDATE,
+ ui::ET_GESTURE_TAP,
+ ui::ET_GESTURE_TAP_DOWN,
+ ui::ET_GESTURE_BEGIN,
+ ui::ET_GESTURE_END,
+ ui::ET_GESTURE_DOUBLE_TAP,
+ ui::ET_GESTURE_TWO_FINGER_TAP,
+ ui::ET_GESTURE_PINCH_BEGIN,
+ ui::ET_GESTURE_PINCH_END,
+ ui::ET_GESTURE_PINCH_UPDATE,
+ ui::ET_GESTURE_LONG_PRESS,
+ ui::ET_GESTURE_MULTIFINGER_SWIPE,
+ ui::ET_SCROLL,
+ ui::ET_SCROLL_FLING_START,
+ ui::ET_SCROLL_FLING_CANCEL,
+ };
+
+ return std::vector<int>(types, types + arraysize(types));
+}
+
+}
+
+namespace ash {
+namespace internal {
+
+TouchUMA::TouchUMA() {
+ std::vector<int> types = GetEventCodes();
+ for (std::vector<int>::iterator iter = types.begin();
+ iter != types.end();
+ ++iter) {
+ ui_event_type_map_[static_cast<ui::EventType>(*iter)] =
+ iter - types.begin();
+ }
+}
+
+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()]);
+}
+
+void TouchUMA::RecordTouchEvent(aura::Window* target,
+ const aura::TouchEvent& event) {
+ // TODO(sad|rjkroege): Figure out what to do (heat map?).
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/touch/touch_uma.h b/ash/touch/touch_uma.h
new file mode 100644
index 0000000..f71ee04
--- /dev/null
+++ b/ash/touch/touch_uma.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_TOUCH_TOUCH_OBSERVER_UMA_H_
+#define ASH_TOUCH_TOUCH_OBSERVER_UMA_H_
+#pragma once
+
+#include <map>
+
+#include "ash/shell.h"
+#include "ui/aura/event_filter.h"
+#include "ui/gfx/point.h"
+#include "ui/views/widget/widget.h"
+
+namespace aura {
+class GestureEvent;
+class TouchEvent;
+class Window;
+}
+
+namespace ash {
+namespace internal {
+
+// Records some touch/gesture event specific details (e.g. what gestures are
+// targetted to which components etc.)
+class TouchUMA {
+ public:
+ TouchUMA();
+ ~TouchUMA();
+
+ void RecordGestureEvent(aura::Window* target,
+ const aura::GestureEvent& event);
+ void RecordTouchEvent(aura::Window* target,
+ const aura::TouchEvent& event);
+
+ private:
+ std::map<ui::EventType, int> ui_event_type_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchUMA);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_TOUCH_TOUCH_OBSERVER_UMA_H_
diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc
index a9b7a56..4af722d 100644
--- a/ash/wm/system_gesture_event_filter.cc
+++ b/ash/wm/system_gesture_event_filter.cc
@@ -467,12 +467,14 @@ bool SystemGestureEventFilter::PreHandleMouseEvent(aura::Window* target,
ui::TouchStatus SystemGestureEventFilter::PreHandleTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
+ touch_uma_.RecordTouchEvent(target, *event);
long_press_affordance_->ProcessEvent(target, event);
return ui::TOUCH_STATUS_UNKNOWN;
}
ui::GestureStatus SystemGestureEventFilter::PreHandleGestureEvent(
aura::Window* target, aura::GestureEvent* event) {
+ touch_uma_.RecordGestureEvent(target, *event);
long_press_affordance_->ProcessEvent(target, event);
if (!target || target == target->GetRootWindow()) {
switch (event->type()) {
diff --git a/ash/wm/system_gesture_event_filter.h b/ash/wm/system_gesture_event_filter.h
index ec61563..3c258d7 100644
--- a/ash/wm/system_gesture_event_filter.h
+++ b/ash/wm/system_gesture_event_filter.h
@@ -7,6 +7,7 @@
#pragma once
#include "ash/shell.h"
+#include "ash/touch/touch_uma.h"
#include "ui/aura/event_filter.h"
#include "ui/aura/window_observer.h"
@@ -22,6 +23,7 @@ namespace ash {
namespace internal {
class SystemPinchHandler;
+class TouchUMA;
enum BezelStart {
BEZEL_START_UNSET = 0,
@@ -97,6 +99,8 @@ class SystemGestureEventFilter : public aura::EventFilter,
class LongPressAffordanceAnimation;
scoped_ptr<LongPressAffordanceAnimation> long_press_affordance_;
+ TouchUMA touch_uma_;
+
DISALLOW_COPY_AND_ASSIGN(SystemGestureEventFilter);
};