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/shell_delegate.h" | 7 #include "ash/shell_delegate.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchRadius", | 260 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchRadius", |
261 static_cast<int>(std::max(event.radius_x(), event.radius_y())), | 261 static_cast<int>(std::max(event.radius_x(), event.radius_y())), |
262 1, 500, 100); | 262 1, 500, 100); |
263 | 263 |
264 WindowTouchDetails* details = target->GetProperty(kWindowTouchDetails); | 264 WindowTouchDetails* details = target->GetProperty(kWindowTouchDetails); |
265 if (!details) { | 265 if (!details) { |
266 details = new WindowTouchDetails; | 266 details = new WindowTouchDetails; |
267 target->SetProperty(kWindowTouchDetails, details); | 267 target->SetProperty(kWindowTouchDetails, details); |
268 } | 268 } |
269 | 269 |
270 // Record the location of the touch points. | |
271 const int kBucketCount = 100; | |
272 const gfx::Rect bounds = target->GetRootWindow()->bounds(); | |
273 const int kBucketSizeX = bounds.width() / kBucketCount; | |
274 const int kBucketSizeY = bounds.height() / kBucketCount; | |
275 STATIC_HISTOGRAM_POINTER_BLOCK("Ash.TouchPositionX", | |
Rick Byers
2012/08/10 18:07:09
Too bad there's not a linear version of UMA_HISTOG
| |
276 Add(event.root_location().x() / kBucketSizeX), | |
277 base::LinearHistogram::FactoryGet("Ash.TouchPositionX", 1, kBucketCount, | |
278 kBucketCount + 1, base::Histogram::kUmaTargetedHistogramFlag)); | |
279 STATIC_HISTOGRAM_POINTER_BLOCK("Ash.TouchPositionY", | |
280 Add(event.root_location().y() / kBucketSizeY), | |
281 base::LinearHistogram::FactoryGet("Ash.TouchPositionY", 1, kBucketCount, | |
282 kBucketCount + 1, base::Histogram::kUmaTargetedHistogramFlag)); | |
283 | |
270 if (event.type() == ui::ET_TOUCH_PRESSED) { | 284 if (event.type() == ui::ET_TOUCH_PRESSED) { |
271 Shell::GetInstance()->delegate()->RecordUserMetricsAction( | 285 Shell::GetInstance()->delegate()->RecordUserMetricsAction( |
272 UMA_TOUCHSCREEN_TAP_DOWN); | 286 UMA_TOUCHSCREEN_TAP_DOWN); |
273 | 287 |
274 details->last_start_time_[event.touch_id()] = event.time_stamp(); | 288 details->last_start_time_[event.touch_id()] = event.time_stamp(); |
275 details->last_touch_position_[event.touch_id()] = event.location(); | 289 details->last_touch_position_[event.touch_id()] = event.location(); |
276 | 290 |
277 if (details->last_release_time_.ToInternalValue()) { | 291 if (details->last_release_time_.ToInternalValue()) { |
278 // Measuring the interval between a touch-release and the next | 292 // Measuring the interval between a touch-release and the next |
279 // touch-start is probably less useful when doing multi-touch (e.g. | 293 // touch-start is probably less useful when doing multi-touch (e.g. |
280 // gestures, or multi-touch friendly apps). So count this only if the user | 294 // gestures, or multi-touch friendly apps). So count this only if the user |
281 // hasn't done any multi-touch during the last 30 seconds. | 295 // hasn't done any multi-touch during the last 30 seconds. |
282 base::TimeDelta diff = event.time_stamp() - details->last_mt_time_; | 296 base::TimeDelta diff = event.time_stamp() - details->last_mt_time_; |
283 if (diff.InSeconds() > 30) { | 297 if (diff.InSeconds() > 30) { |
284 base::TimeDelta gap = event.time_stamp() - details->last_release_time_; | 298 base::TimeDelta gap = event.time_stamp() - details->last_release_time_; |
285 UMA_HISTOGRAM_COUNTS_10000("Ash.TouchStartAfterEnd", | 299 UMA_HISTOGRAM_COUNTS_10000("Ash.TouchStartAfterEnd", |
286 gap.InMilliseconds()); | 300 gap.InMilliseconds()); |
287 } | 301 } |
288 } | 302 } |
303 | |
304 // Record the number of touch-points currently active for the window. | |
305 const int kMaxTouchPoints = 10; | |
306 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.ActiveTouchPoints", | |
307 std::min(static_cast<int>(details->last_start_time_.size()), | |
308 kMaxTouchPoints), | |
309 1, kMaxTouchPoints, kMaxTouchPoints); | |
sadrul
2012/08/10 15:54:43
This will effectively be linear, right?
| |
289 } else if (event.type() == ui::ET_TOUCH_RELEASED) { | 310 } else if (event.type() == ui::ET_TOUCH_RELEASED) { |
290 if (details->last_start_time_.count(event.touch_id())) { | 311 if (details->last_start_time_.count(event.touch_id())) { |
291 base::TimeDelta duration = event.time_stamp() - | 312 base::TimeDelta duration = event.time_stamp() - |
292 details->last_start_time_[event.touch_id()]; | 313 details->last_start_time_[event.touch_id()]; |
293 UMA_HISTOGRAM_COUNTS_100("Ash.TouchDuration", duration.InMilliseconds()); | 314 UMA_HISTOGRAM_COUNTS_100("Ash.TouchDuration", duration.InMilliseconds()); |
294 } | 315 } |
295 details->last_start_time_.erase(event.touch_id()); | 316 details->last_start_time_.erase(event.touch_id()); |
296 details->last_move_time_.erase(event.touch_id()); | 317 details->last_move_time_.erase(event.touch_id()); |
297 details->last_touch_position_.erase(event.touch_id()); | 318 details->last_touch_position_.erase(event.touch_id()); |
298 details->last_release_time_ = event.time_stamp(); | 319 details->last_release_time_ = event.time_stamp(); |
(...skipping 14 matching lines...) Expand all Loading... | |
313 | 334 |
314 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); | 335 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchMoveSteps", distance, 1, 1000, 50); |
315 | 336 |
316 details->last_move_time_[event.touch_id()] = event.time_stamp(); | 337 details->last_move_time_[event.touch_id()] = event.time_stamp(); |
317 details->last_touch_position_[event.touch_id()] = event.location(); | 338 details->last_touch_position_[event.touch_id()] = event.location(); |
318 } | 339 } |
319 } | 340 } |
320 | 341 |
321 } // namespace internal | 342 } // namespace internal |
322 } // namespace ash | 343 } // namespace ash |
OLD | NEW |