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

Side by Side Diff: ui/events/gesture_detection/gesture_touch_uma_histogram.cc.save

Issue 501553004: Move gesture/touch UMA logs into gesture provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 6 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
tdresser 2014/08/27 12:35:39 This file looks like an accidental commit.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/events/gesture_detection/gesture_touch_uma_histogram.h"
6
7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
9
10 #include "ui/aura/env.h"
11 #include "ui/aura/window.h"
12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/aura/window_property.h"
14 #include "ui/events/event.h"
15 #include "ui/events/gesture_detection/motion_event.h"
16
17 namespace ui {
18
19 GestureTouchUMAHistogram::GestureTouchUMAHistogram() {
20 }
21
22 GestureTouchUMAHistogram::~GestureTouchUMAHistogram() {
23 }
24
25 GestureTouchUMAHistogram::WindowTouchDetails::WindowTouchDetails()
26 : max_distance_from_start_squared_(0) {
27 }
28
29 GestureTouchUMAHistogram::WindowTouchDetails::WindowTouchDetails(base::TimeTicks start_time, const gfx::Point& start_touch_position)
30 : start_time_(start_time),
31 start_touch_position_(start_touch_position),
32 max_distance_from_start_squared_(0) {
33 }
34
35 GestureTouchUMAHistogram::WindowTouchDetails::~WindowTouchDetails() {}
36
37 void GestureTouchUMAHistogram::RecordGestureEvent(
38 const ui::GestureEventData& gesture) {
39 GestureEvent event(gesture.x, gesture.y, 1, gesture.time - base::TimeTicks(), gesture.details);
40 UMA_HISTOGRAM_ENUMERATION("Event.GestureCreated",
41 ui::UMAEventTypeFromEvent(event), ui::UMA_ET_COUNT);
42 LOG(ERROR) << " gesture created in GestureTouchUMAHistogram ";
43 }
44
45 void GestureTouchUMAHistogram::RecordTouchEvent(const ui::MotionEvent& event) {
46 EventType eventType = TouchEventTypeFromMotionEvent(event);
47 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.TouchMaxDistance",
48 static_cast<int>(sqrt(details->max_distance_from_start_squared_)), 0,
49 1500, 50);
50 LOG(ERROR) << " TouchMaxDistance in GestureTouchUMAHistogram ";
51
52 base::TimeDelta duration = event.GetEventTime()
53 - details->start_time_;
54 UMA_HISTOGRAM_TIMES("Event.TouchDuration2", duration);
55 LOG(ERROR) << " TouchDuration2 in GestureTouchUMAHistogram ";
56 }
57 details.reset( new WindowTouchDetails());
58 } else if (eventType == ui::ET_TOUCH_MOVED) {
59 float cur_dist = (details->start_touch_position_ - gfx::Point(event.GetX(), event.GetY())).LengthSquared();
60 if (cur_dist > details->max_distance_from_start_squared_)
61 details->max_distance_from_start_squared_ = cur_dist;
62 } else {
63 details.reset( new WindowTouchDetails());
64 }
65 }
66
67 EventType GestureTouchUMAHistogram::TouchEventTypeFromMotionEvent(const MotionEv ent& event) {
68 switch (event.GetAction()) {
69 case MotionEvent::ACTION_DOWN:
70 return ET_TOUCH_PRESSED;
71 case MotionEvent::ACTION_UP:
72 return ET_TOUCH_RELEASED;
73 case MotionEvent::ACTION_MOVE:
74 return ET_TOUCH_MOVED;
75 case MotionEvent::ACTION_CANCEL:
76 return ET_TOUCH_CANCELLED;
77 default:
78 return ET_UNKNOWN;
79 }
80 }
81
82 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698