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

Side by Side Diff: ui/events/event_utils.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « ui/events/event_utils.h ('k') | ui/events/events_default.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/events/event_utils.h" 5 #include "ui/events/event_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "ui/display/display.h" 10 #include "ui/display/display.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 default: 54 default:
55 break; 55 break;
56 } 56 }
57 return event; 57 return event;
58 } 58 }
59 59
60 int RegisterCustomEventType() { 60 int RegisterCustomEventType() {
61 return ++g_custom_event_types; 61 return ++g_custom_event_types;
62 } 62 }
63 63
64 base::TimeDelta EventTimeForNow() { 64 base::TimeTicks EventTimeForNow() {
65 return base::TimeDelta::FromInternalValue( 65 return base::TimeTicks::Now();
66 base::TimeTicks::Now().ToInternalValue());
67 } 66 }
68 67
69 bool ShouldDefaultToNaturalScroll() { 68 bool ShouldDefaultToNaturalScroll() {
70 return GetInternalDisplayTouchSupport() == 69 return GetInternalDisplayTouchSupport() ==
71 display::Display::TOUCH_SUPPORT_AVAILABLE; 70 display::Display::TOUCH_SUPPORT_AVAILABLE;
72 } 71 }
73 72
74 display::Display::TouchSupport GetInternalDisplayTouchSupport() { 73 display::Display::TouchSupport GetInternalDisplayTouchSupport() {
75 display::Screen* screen = display::Screen::GetScreen(); 74 display::Screen* screen = display::Screen::GetScreen();
76 // No screen in some unit tests. 75 // No screen in some unit tests.
77 if (!screen) 76 if (!screen)
78 return display::Display::TOUCH_SUPPORT_UNKNOWN; 77 return display::Display::TOUCH_SUPPORT_UNKNOWN;
79 const std::vector<display::Display>& displays = screen->GetAllDisplays(); 78 const std::vector<display::Display>& displays = screen->GetAllDisplays();
80 for (std::vector<display::Display>::const_iterator it = displays.begin(); 79 for (std::vector<display::Display>::const_iterator it = displays.begin();
81 it != displays.end(); ++it) { 80 it != displays.end(); ++it) {
82 if (it->IsInternal()) 81 if (it->IsInternal())
83 return it->touch_support(); 82 return it->touch_support();
84 } 83 }
85 return display::Display::TOUCH_SUPPORT_UNAVAILABLE; 84 return display::Display::TOUCH_SUPPORT_UNAVAILABLE;
86 } 85 }
87 86
88 void ComputeEventLatencyOS(const base::NativeEvent& native_event) { 87 void ComputeEventLatencyOS(const base::NativeEvent& native_event) {
89 base::TimeDelta current_time = EventTimeForNow(); 88 base::TimeTicks current_time = EventTimeForNow();
90 base::TimeDelta time_stamp = EventTimeFromNative(native_event); 89 base::TimeTicks time_stamp = EventTimeFromNative(native_event);
91 base::TimeDelta delta = current_time - time_stamp; 90 base::TimeDelta delta = current_time - time_stamp;
92 91
93 EventType type = EventTypeFromNative(native_event); 92 EventType type = EventTypeFromNative(native_event);
94 switch (type) { 93 switch (type) {
95 case ET_MOUSEWHEEL: 94 case ET_MOUSEWHEEL:
96 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.MOUSE_WHEEL", 95 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.MOUSE_WHEEL",
97 delta.InMicroseconds(), 1, 1000000, 50); 96 delta.InMicroseconds(), 1, 1000000, 50);
98 return; 97 return;
99 case ET_TOUCH_MOVED: 98 case ET_TOUCH_MOVED:
100 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_MOVED", 99 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_MOVED",
101 delta.InMicroseconds(), 1, 1000000, 50); 100 delta.InMicroseconds(), 1, 1000000, 50);
102 return; 101 return;
103 case ET_TOUCH_PRESSED: 102 case ET_TOUCH_PRESSED:
104 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_PRESSED", 103 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_PRESSED",
105 delta.InMicroseconds(), 1, 1000000, 50); 104 delta.InMicroseconds(), 1, 1000000, 50);
106 return; 105 return;
107 case ET_TOUCH_RELEASED: 106 case ET_TOUCH_RELEASED:
108 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 107 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
109 delta.InMicroseconds(), 1, 1000000, 50); 108 delta.InMicroseconds(), 1, 1000000, 50);
110 return; 109 return;
111 default: 110 default:
112 return; 111 return;
113 } 112 }
114 } 113 }
115 114
116 } // namespace ui 115 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_utils.h ('k') | ui/events/events_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698