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

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

Issue 2295923003: Expand event timestamp validation check to more platforms (Closed)
Patch Set: Add Browser/Renderer to histogram Created 4 years, 2 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void ValidateEventTimeClock(base::TimeTicks* timestamp) { 64 void ValidateEventTimeClock(base::TimeTicks* timestamp) {
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()) 65 if (base::debug::BeingDebugged())
69 return; 66 return;
70 67
71 base::TimeTicks now = EventTimeForNow(); 68 base::TimeTicks now = EventTimeForNow();
72 int64_t delta = (now - *timestamp).InMilliseconds(); 69 int64_t delta = (now - *timestamp).InMilliseconds();
Ilya Sherman 2016/09/26 19:04:44 nit: Please write this as bool has_valid_timebase
majidvp 2016/10/11 16:02:07 Done.
73 if (delta < 0 || delta > 60 * 1000) { 70 if (delta < 0 || delta > 60 * 1000) {
74 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase", false); 71 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase.Browser", false);
Ilya Sherman 2016/09/26 19:04:44 Where is the .Renderer version of this histogram?
majidvp 2016/10/11 16:02:07 It is more involved so I am working on adding it i
Ilya Sherman 2016/10/11 23:54:08 In general, it's best to modify histograms.xml in
majidvp 2016/10/12 13:44:21 I thought it will be odd to have a histogram_suffi
Ilya Sherman 2016/10/13 00:40:17 It's acceptable, yeah. It's not a big deal either
75 #if defined(USE_X11) 72 #if defined(USE_X11)
73 // Restrict this correction to X11 which is known to provide bogus
74 // timestamps that require correction (crbug.com/611950).
76 *timestamp = now; 75 *timestamp = now;
77 #else
78 NOTREACHED() << "Unexpected event timestamp, now:" << now
79 << " event timestamp:" << *timestamp;
80 #endif 76 #endif
77 } else {
78 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase.Browser", true);
81 } 79 }
82
83 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase", true);
84 #endif
85 } 80 }
86 81
87 bool ShouldDefaultToNaturalScroll() { 82 bool ShouldDefaultToNaturalScroll() {
88 return GetInternalDisplayTouchSupport() == 83 return GetInternalDisplayTouchSupport() ==
89 display::Display::TOUCH_SUPPORT_AVAILABLE; 84 display::Display::TOUCH_SUPPORT_AVAILABLE;
90 } 85 }
91 86
92 display::Display::TouchSupport GetInternalDisplayTouchSupport() { 87 display::Display::TouchSupport GetInternalDisplayTouchSupport() {
93 display::Screen* screen = display::Screen::GetScreen(); 88 display::Screen* screen = display::Screen::GetScreen();
94 // No screen in some unit tests. 89 // No screen in some unit tests.
(...skipping 30 matching lines...) Expand all
125 case ET_TOUCH_RELEASED: 120 case ET_TOUCH_RELEASED:
126 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 121 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
127 delta.InMicroseconds(), 1, 1000000, 50); 122 delta.InMicroseconds(), 1, 1000000, 50);
128 return; 123 return;
129 default: 124 default:
130 return; 125 return;
131 } 126 }
132 } 127 }
133 128
134 } // namespace ui 129 } // namespace ui
OLDNEW
« tools/metrics/histograms/histograms.xml ('K') | « tools/metrics/histograms/histograms.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698