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

Side by Side Diff: ash/touch/touch_uma.cc

Issue 10816008: ash: Record some additional information about the gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/touch/touch_uma.h" 5 #include "ash/touch/touch_uma.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "ui/aura/event.h" 9 #include "ui/aura/event.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 10 matching lines...) Expand all
21 GESTURE_BEZEL_SCROLL, 21 GESTURE_BEZEL_SCROLL,
22 GESTURE_DESKTOP_SCROLL, 22 GESTURE_DESKTOP_SCROLL,
23 GESTURE_DESKTOP_PINCH, 23 GESTURE_DESKTOP_PINCH,
24 GESTURE_WEBPAGE_PINCH, 24 GESTURE_WEBPAGE_PINCH,
25 // NOTE: Add new action types only immediately above this line. Also, make sure 25 // NOTE: Add new action types only immediately above this line. Also, make sure
26 // the enum list in tools/histogram/histograms.xml is updated with any change in 26 // the enum list in tools/histogram/histograms.xml is updated with any change in
27 // here. 27 // here.
28 GESTURE_ACTION_COUNT 28 GESTURE_ACTION_COUNT
29 }; 29 };
30 30
31 enum UMAEventType {
32 UMA_ET_UNKNOWN,
33 UMA_ET_TOUCH_RELEASED,
34 UMA_ET_TOUCH_PRESSED,
35 UMA_ET_TOUCH_MOVED,
36 UMA_ET_TOUCH_STATIONARY,
37 UMA_ET_TOUCH_CANCELLED,
38 UMA_ET_GESTURE_SCROLL_BEGIN,
39 UMA_ET_GESTURE_SCROLL_END,
40 UMA_ET_GESTURE_SCROLL_UPDATE,
41 UMA_ET_GESTURE_TAP,
42 UMA_ET_GESTURE_TAP_DOWN,
43 UMA_ET_GESTURE_BEGIN,
44 UMA_ET_GESTURE_END,
45 UMA_ET_GESTURE_DOUBLE_TAP,
46 UMA_ET_GESTURE_TWO_FINGER_TAP,
47 UMA_ET_GESTURE_PINCH_BEGIN,
48 UMA_ET_GESTURE_PINCH_END,
49 UMA_ET_GESTURE_PINCH_UPDATE,
50 UMA_ET_GESTURE_LONG_PRESS,
51 UMA_ET_GESTURE_MULTIFINGER_SWIPE,
52 UMA_ET_SCROLL,
53 UMA_ET_SCROLL_FLING_START,
54 UMA_ET_SCROLL_FLING_CANCEL,
55 UMA_ET_GESTURE_MULTIFINGER_SWIPE_3,
56 UMA_ET_GESTURE_MULTIFINGER_SWIPE_4P, // 4+ fingers
57 UMA_ET_GESTURE_SCROLL_UPDATE_2,
58 UMA_ET_GESTURE_SCROLL_UPDATE_3,
59 UMA_ET_GESTURE_SCROLL_UPDATE_4P,
60 UMA_ET_GESTURE_PINCH_UPDATE_3,
61 UMA_ET_GESTURE_PINCH_UPDATE_4P,
62 // NOTE: Add new event types only immediately above this line. Make sure to
63 // update the enum list in tools/histogram/histograms.xml accordingly.
64 UMA_ET_COUNT
65 };
66
31 GestureActionType FindGestureActionType(aura::Window* window, 67 GestureActionType FindGestureActionType(aura::Window* window,
32 const aura::GestureEvent& event) { 68 const aura::GestureEvent& event) {
33 if (!window || window->GetRootWindow() == window) { 69 if (!window || window->GetRootWindow() == window) {
34 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) 70 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
35 return GESTURE_BEZEL_SCROLL; 71 return GESTURE_BEZEL_SCROLL;
36 return GESTURE_UNKNOWN; 72 return GESTURE_UNKNOWN;
37 } 73 }
38 74
39 std::string name = window ? window->name() : std::string(); 75 std::string name = window ? window->name() : std::string();
40 76
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) 116 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
81 return GESTURE_OMNIBOX_SCROLL; 117 return GESTURE_OMNIBOX_SCROLL;
82 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) 118 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN)
83 return GESTURE_OMNIBOX_PINCH; 119 return GESTURE_OMNIBOX_PINCH;
84 return GESTURE_UNKNOWN; 120 return GESTURE_UNKNOWN;
85 } 121 }
86 122
87 return GESTURE_UNKNOWN; 123 return GESTURE_UNKNOWN;
88 } 124 }
89 125
90 std::vector<int> GetEventCodes() { 126 UMAEventType UMAEventTypeFromEvent(const aura::Event& event) {
91 // NOTE: Add new events only at the end of this list. Also, make sure the enum 127 switch (event.type()) {
92 // list in tools/histogram/histograms.xml is also updated. 128 case ui::ET_TOUCH_RELEASED:
93 int types[] = { 129 return UMA_ET_TOUCH_RELEASED;
94 ui::ET_UNKNOWN, // This is to make sure that every intersting value 130 case ui::ET_TOUCH_PRESSED:
95 // has positive index. 131 return UMA_ET_TOUCH_PRESSED;
96 ui::ET_TOUCH_RELEASED, 132 case ui::ET_TOUCH_MOVED:
97 ui::ET_TOUCH_PRESSED, 133 return UMA_ET_TOUCH_MOVED;
98 ui::ET_TOUCH_MOVED, 134 case ui::ET_TOUCH_STATIONARY:
99 ui::ET_TOUCH_STATIONARY, 135 return UMA_ET_TOUCH_STATIONARY;
100 ui::ET_TOUCH_CANCELLED, 136 case ui::ET_TOUCH_CANCELLED:
101 ui::ET_GESTURE_SCROLL_BEGIN, 137 return UMA_ET_TOUCH_CANCELLED;
102 ui::ET_GESTURE_SCROLL_END, 138 case ui::ET_GESTURE_SCROLL_BEGIN:
103 ui::ET_GESTURE_SCROLL_UPDATE, 139 return UMA_ET_GESTURE_SCROLL_BEGIN;
104 ui::ET_GESTURE_TAP, 140 case ui::ET_GESTURE_SCROLL_END:
105 ui::ET_GESTURE_TAP_DOWN, 141 return UMA_ET_GESTURE_SCROLL_END;
106 ui::ET_GESTURE_BEGIN, 142 case ui::ET_GESTURE_SCROLL_UPDATE: {
107 ui::ET_GESTURE_END, 143 const aura::GestureEvent& gesture =
108 ui::ET_GESTURE_DOUBLE_TAP, 144 static_cast<const aura::GestureEvent&>(event);
109 ui::ET_GESTURE_TWO_FINGER_TAP, 145 if (gesture.details().touch_points() >= 4)
110 ui::ET_GESTURE_PINCH_BEGIN, 146 return UMA_ET_GESTURE_SCROLL_UPDATE_4P;
111 ui::ET_GESTURE_PINCH_END, 147 else if (gesture.details().touch_points() == 3)
112 ui::ET_GESTURE_PINCH_UPDATE, 148 return UMA_ET_GESTURE_SCROLL_UPDATE_3;
113 ui::ET_GESTURE_LONG_PRESS, 149 else if (gesture.details().touch_points() == 2)
114 ui::ET_GESTURE_MULTIFINGER_SWIPE, 150 return UMA_ET_GESTURE_SCROLL_UPDATE_2;
115 ui::ET_SCROLL, 151 return UMA_ET_GESTURE_SCROLL_UPDATE;
116 ui::ET_SCROLL_FLING_START, 152 }
117 ui::ET_SCROLL_FLING_CANCEL, 153 case ui::ET_GESTURE_TAP:
118 }; 154 return UMA_ET_GESTURE_TAP;
119 155 case ui::ET_GESTURE_TAP_DOWN:
120 return std::vector<int>(types, types + arraysize(types)); 156 return UMA_ET_GESTURE_TAP_DOWN;
157 case ui::ET_GESTURE_BEGIN:
158 return UMA_ET_GESTURE_BEGIN;
159 case ui::ET_GESTURE_END:
160 return UMA_ET_GESTURE_END;
161 case ui::ET_GESTURE_DOUBLE_TAP:
162 return UMA_ET_GESTURE_DOUBLE_TAP;
163 case ui::ET_GESTURE_TWO_FINGER_TAP:
164 return UMA_ET_GESTURE_TWO_FINGER_TAP;
165 case ui::ET_GESTURE_PINCH_BEGIN:
166 return UMA_ET_GESTURE_PINCH_BEGIN;
167 case ui::ET_GESTURE_PINCH_END:
168 return UMA_ET_GESTURE_PINCH_END;
169 case ui::ET_GESTURE_PINCH_UPDATE: {
170 const aura::GestureEvent& gesture =
171 static_cast<const aura::GestureEvent&>(event);
172 if (gesture.details().touch_points() >= 4)
173 return UMA_ET_GESTURE_PINCH_UPDATE_4P;
174 else if (gesture.details().touch_points() == 3)
175 return UMA_ET_GESTURE_PINCH_UPDATE_3;
176 return UMA_ET_GESTURE_PINCH_UPDATE;
177 }
178 case ui::ET_GESTURE_LONG_PRESS:
179 return UMA_ET_GESTURE_LONG_PRESS;
180 case ui::ET_GESTURE_MULTIFINGER_SWIPE: {
181 const aura::GestureEvent& gesture =
182 static_cast<const aura::GestureEvent&>(event);
183 if (gesture.details().touch_points() >= 4)
184 return UMA_ET_GESTURE_MULTIFINGER_SWIPE_4P;
185 else if (gesture.details().touch_points() == 3)
186 return UMA_ET_GESTURE_MULTIFINGER_SWIPE_3;
187 return UMA_ET_GESTURE_MULTIFINGER_SWIPE;
188 }
189 case ui::ET_SCROLL:
190 return UMA_ET_SCROLL;
191 case ui::ET_SCROLL_FLING_START:
192 return UMA_ET_SCROLL_FLING_START;
193 case ui::ET_SCROLL_FLING_CANCEL:
194 return UMA_ET_SCROLL_FLING_CANCEL;
195 default:
196 return UMA_ET_UNKNOWN;
197 }
121 } 198 }
122 199
123 } 200 }
124 201
125 namespace ash { 202 namespace ash {
126 namespace internal { 203 namespace internal {
127 204
128 TouchUMA::TouchUMA() { 205 TouchUMA::TouchUMA() {
129 std::vector<int> types = GetEventCodes();
130 for (std::vector<int>::iterator iter = types.begin();
131 iter != types.end();
132 ++iter) {
133 ui_event_type_map_[static_cast<ui::EventType>(*iter)] =
134 iter - types.begin();
135 }
136 } 206 }
137 207
138 TouchUMA::~TouchUMA() { 208 TouchUMA::~TouchUMA() {
139 } 209 }
140 210
141 void TouchUMA::RecordGestureEvent(aura::Window* target, 211 void TouchUMA::RecordGestureEvent(aura::Window* target,
142 const aura::GestureEvent& event) { 212 const aura::GestureEvent& event) {
143 UMA_HISTOGRAM_ENUMERATION("Ash.GestureCreated", 213 UMA_HISTOGRAM_ENUMERATION("Ash.GestureCreated",
sky 2012/07/21 00:01:54 Why are these histograms and not UserMetricsAction
sadrul 2012/07/21 00:55:40 We considered using UserMetricsAction, but since w
144 ui_event_type_map_[event.type()], 214 UMAEventTypeFromEvent(event),
145 ui_event_type_map_.size()); 215 UMA_ET_COUNT);
146 216
147 GestureActionType action = FindGestureActionType(target, event); 217 GestureActionType action = FindGestureActionType(target, event);
148 if (action != GESTURE_UNKNOWN) { 218 if (action != GESTURE_UNKNOWN) {
149 UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget", 219 UMA_HISTOGRAM_ENUMERATION("Ash.GestureTarget",
150 action, 220 action,
151 GESTURE_ACTION_COUNT); 221 GESTURE_ACTION_COUNT);
152 } 222 }
153 } 223 }
154 224
155 void TouchUMA::RecordTouchEvent(aura::Window* target, 225 void TouchUMA::RecordTouchEvent(aura::Window* target,
156 const aura::TouchEvent& event) { 226 const aura::TouchEvent& event) {
157 // TODO(sad|rjkroege): Figure out what to do (heat map?). 227 // TODO(sad|rjkroege): Figure out what to do (heat map?).
158 } 228 }
159 229
160 } // namespace internal 230 } // namespace internal
161 } // namespace ash 231 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698