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

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

Issue 2007083002: Validate that ui::Event::time_stamp comes from the same clock as TimeTicks::Now (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@453559-use-timeticks-ui-event
Patch Set: Address feedback Created 4 years, 5 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/test/event_generator.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::TimeTicks EventTimeForNow() { 64 void ValidateEventTimeClock(base::TimeTicks* timestamp) {
65 return base::TimeTicks::Now(); 65 // Restrict this validation to DCHECK builds except when using X11 which is
66 // known to provide bogus timestamps that require correction (crbug.com/611950).
67 #if defined(USE_X11) || DCHECK_IS_ON()
68 if (base::debug::BeingDebugged())
69 return;
70
71 base::TimeTicks now = EventTimeForNow();
72 int64_t delta = (now - *timestamp).InMilliseconds();
73 if (delta < 0 || delta > 60 * 1000) {
74 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase", false);
75 #if defined(USE_X11)
76 *timestamp = now;
77 #else
78 NOTREACHED() << "Unexpected event timestamp, now:" << now
79 << " event timestamp:" << *timestamp;
80 #endif
81 }
82
83 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase", true);
84 #endif
66 } 85 }
67 86
68 bool ShouldDefaultToNaturalScroll() { 87 bool ShouldDefaultToNaturalScroll() {
69 return GetInternalDisplayTouchSupport() == 88 return GetInternalDisplayTouchSupport() ==
70 display::Display::TOUCH_SUPPORT_AVAILABLE; 89 display::Display::TOUCH_SUPPORT_AVAILABLE;
71 } 90 }
72 91
73 display::Display::TouchSupport GetInternalDisplayTouchSupport() { 92 display::Display::TouchSupport GetInternalDisplayTouchSupport() {
74 display::Screen* screen = display::Screen::GetScreen(); 93 display::Screen* screen = display::Screen::GetScreen();
75 // No screen in some unit tests. 94 // No screen in some unit tests.
(...skipping 30 matching lines...) Expand all
106 case ET_TOUCH_RELEASED: 125 case ET_TOUCH_RELEASED:
107 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 126 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
108 delta.InMicroseconds(), 1, 1000000, 50); 127 delta.InMicroseconds(), 1, 1000000, 50);
109 return; 128 return;
110 default: 129 default:
111 return; 130 return;
112 } 131 }
113 } 132 }
114 133
115 } // namespace ui 134 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_utils.h ('k') | ui/events/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698