OLD | NEW |
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 "ash/common/wm_shell.h" | 7 #include "ash/common/wm_shell.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); | 115 position.set_x(std::min(bounds.width() - 1, std::max(0, position.x()))); |
116 position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); | 116 position.set_y(std::min(bounds.height() - 1, std::max(0, position.y()))); |
117 | 117 |
118 UMA_HISTOGRAM_CUSTOM_COUNTS( | 118 UMA_HISTOGRAM_CUSTOM_COUNTS( |
119 "Ash.TouchPositionX", position.x() / bucket_size_x, 1, | 119 "Ash.TouchPositionX", position.x() / bucket_size_x, 1, |
120 kBucketCountForLocation, kBucketCountForLocation + 1); | 120 kBucketCountForLocation, kBucketCountForLocation + 1); |
121 UMA_HISTOGRAM_CUSTOM_COUNTS( | 121 UMA_HISTOGRAM_CUSTOM_COUNTS( |
122 "Ash.TouchPositionY", position.y() / bucket_size_y, 1, | 122 "Ash.TouchPositionY", position.y() / bucket_size_y, 1, |
123 kBucketCountForLocation, kBucketCountForLocation + 1); | 123 kBucketCountForLocation, kBucketCountForLocation + 1); |
124 | 124 |
| 125 const int touch_pointer_id = event.pointer_details().id; |
125 if (event.type() == ui::ET_TOUCH_PRESSED) { | 126 if (event.type() == ui::ET_TOUCH_PRESSED) { |
126 WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHSCREEN_TAP_DOWN); | 127 WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHSCREEN_TAP_DOWN); |
127 | 128 |
128 details->last_start_time_[event.touch_id()] = event.time_stamp(); | 129 details->last_start_time_[touch_pointer_id] = event.time_stamp(); |
129 details->start_touch_position_[event.touch_id()] = event.root_location(); | 130 details->start_touch_position_[touch_pointer_id] = event.root_location(); |
130 details->last_touch_position_[event.touch_id()] = event.location(); | 131 details->last_touch_position_[touch_pointer_id] = event.location(); |
131 | 132 |
132 if (details->last_release_time_.ToInternalValue()) { | 133 if (details->last_release_time_.ToInternalValue()) { |
133 // Measuring the interval between a touch-release and the next | 134 // Measuring the interval between a touch-release and the next |
134 // touch-start is probably less useful when doing multi-touch (e.g. | 135 // touch-start is probably less useful when doing multi-touch (e.g. |
135 // gestures, or multi-touch friendly apps). So count this only if the user | 136 // gestures, or multi-touch friendly apps). So count this only if the user |
136 // hasn't done any multi-touch during the last 30 seconds. | 137 // hasn't done any multi-touch during the last 30 seconds. |
137 base::TimeDelta diff = event.time_stamp() - details->last_mt_time_; | 138 base::TimeDelta diff = event.time_stamp() - details->last_mt_time_; |
138 if (diff.InSeconds() > 30) { | 139 if (diff.InSeconds() > 30) { |
139 base::TimeDelta gap = event.time_stamp() - details->last_release_time_; | 140 base::TimeDelta gap = event.time_stamp() - details->last_release_time_; |
140 UMA_HISTOGRAM_COUNTS_10000("Ash.TouchStartAfterEnd", | 141 UMA_HISTOGRAM_COUNTS_10000("Ash.TouchStartAfterEnd", |
141 gap.InMilliseconds()); | 142 gap.InMilliseconds()); |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
145 // Record the number of touch-points currently active for the window. | 146 // Record the number of touch-points currently active for the window. |
146 const int kMaxTouchPoints = 10; | 147 const int kMaxTouchPoints = 10; |
147 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.ActiveTouchPoints", | 148 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.ActiveTouchPoints", |
148 details->last_start_time_.size(), 1, | 149 details->last_start_time_.size(), 1, |
149 kMaxTouchPoints, kMaxTouchPoints + 1); | 150 kMaxTouchPoints, kMaxTouchPoints + 1); |
150 } else if (event.type() == ui::ET_TOUCH_RELEASED) { | 151 } else if (event.type() == ui::ET_TOUCH_RELEASED) { |
151 if (details->last_start_time_.count(event.touch_id())) { | 152 if (details->last_start_time_.count(touch_pointer_id)) { |
152 base::TimeDelta duration = | 153 base::TimeDelta duration = |
153 event.time_stamp() - details->last_start_time_[event.touch_id()]; | 154 event.time_stamp() - details->last_start_time_[touch_pointer_id]; |
154 // Look for touches that were [almost] stationary for a long time. | 155 // Look for touches that were [almost] stationary for a long time. |
155 const double kLongStationaryTouchDuration = 10; | 156 const double kLongStationaryTouchDuration = 10; |
156 const int kLongStationaryTouchDistanceSquared = 100; | 157 const int kLongStationaryTouchDistanceSquared = 100; |
157 if (duration.InSecondsF() > kLongStationaryTouchDuration) { | 158 if (duration.InSecondsF() > kLongStationaryTouchDuration) { |
158 gfx::Vector2d distance = | 159 gfx::Vector2d distance = |
159 event.root_location() - | 160 event.root_location() - |
160 details->start_touch_position_[event.touch_id()]; | 161 details->start_touch_position_[touch_pointer_id]; |
161 if (distance.LengthSquared() < kLongStationaryTouchDistanceSquared) { | 162 if (distance.LengthSquared() < kLongStationaryTouchDistanceSquared) { |
162 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.StationaryTouchDuration", | 163 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.StationaryTouchDuration", |
163 duration.InSeconds(), | 164 duration.InSeconds(), |
164 kLongStationaryTouchDuration, 1000, 20); | 165 kLongStationaryTouchDuration, 1000, 20); |
165 } | 166 } |
166 } | 167 } |
167 } | 168 } |
168 details->last_start_time_.erase(event.touch_id()); | 169 details->last_start_time_.erase(touch_pointer_id); |
169 details->last_move_time_.erase(event.touch_id()); | 170 details->last_move_time_.erase(touch_pointer_id); |
170 details->start_touch_position_.erase(event.touch_id()); | 171 details->start_touch_position_.erase(touch_pointer_id); |
171 details->last_touch_position_.erase(event.touch_id()); | 172 details->last_touch_position_.erase(touch_pointer_id); |
172 details->last_release_time_ = event.time_stamp(); | 173 details->last_release_time_ = event.time_stamp(); |
173 } else if (event.type() == ui::ET_TOUCH_MOVED) { | 174 } else if (event.type() == ui::ET_TOUCH_MOVED) { |
174 int distance = 0; | 175 int distance = 0; |
175 if (details->last_touch_position_.count(event.touch_id())) { | 176 if (details->last_touch_position_.count(touch_pointer_id)) { |
176 gfx::Point lastpos = details->last_touch_position_[event.touch_id()]; | 177 gfx::Point lastpos = details->last_touch_position_[touch_pointer_id]; |
177 distance = | 178 distance = |
178 std::abs(lastpos.x() - event.x()) + std::abs(lastpos.y() - event.y()); | 179 std::abs(lastpos.x() - event.x()) + std::abs(lastpos.y() - event.y()); |
179 } | 180 } |
180 | 181 |
181 if (details->last_move_time_.count(event.touch_id())) { | 182 if (details->last_move_time_.count(touch_pointer_id)) { |
182 base::TimeDelta move_delay = | 183 base::TimeDelta move_delay = |
183 event.time_stamp() - details->last_move_time_[event.touch_id()]; | 184 event.time_stamp() - details->last_move_time_[touch_pointer_id]; |
184 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveInterval", | 185 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveInterval", |
185 move_delay.InMilliseconds(), 1, 50, 25); | 186 move_delay.InMilliseconds(), 1, 50, 25); |
186 } | 187 } |
187 | 188 |
188 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); | 189 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); |
189 | 190 |
190 details->last_move_time_[event.touch_id()] = event.time_stamp(); | 191 details->last_move_time_[touch_pointer_id] = event.time_stamp(); |
191 details->last_touch_position_[event.touch_id()] = event.location(); | 192 details->last_touch_position_[touch_pointer_id] = event.location(); |
192 } | 193 } |
193 } | 194 } |
194 | 195 |
195 TouchUMA::TouchUMA() | 196 TouchUMA::TouchUMA() |
196 : is_single_finger_gesture_(false), | 197 : is_single_finger_gesture_(false), |
197 touch_in_progress_(false), | 198 touch_in_progress_(false), |
198 burst_length_(0) {} | 199 burst_length_(0) {} |
199 | 200 |
200 TouchUMA::~TouchUMA() {} | 201 TouchUMA::~TouchUMA() {} |
201 | 202 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 return GESTURE_OMNIBOX_SCROLL; | 295 return GESTURE_OMNIBOX_SCROLL; |
295 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) | 296 if (event.type() == ui::ET_GESTURE_PINCH_BEGIN) |
296 return GESTURE_OMNIBOX_PINCH; | 297 return GESTURE_OMNIBOX_PINCH; |
297 return GESTURE_UNKNOWN; | 298 return GESTURE_UNKNOWN; |
298 } | 299 } |
299 | 300 |
300 return GESTURE_UNKNOWN; | 301 return GESTURE_UNKNOWN; |
301 } | 302 } |
302 | 303 |
303 } // namespace ash | 304 } // namespace ash |
OLD | NEW |