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