| 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 "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 Loading... |
| 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(); |
| 73 if (delta < 0 || delta > 60 * 1000) { | 70 bool has_valid_timebase = delta >= 0 && delta <= 60 * 1000; |
| 74 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase", false); | 71 UMA_HISTOGRAM_BOOLEAN("Event.TimestampHasValidTimebase.Browser", |
| 72 has_valid_timebase); |
| 73 |
| 75 #if defined(USE_X11) | 74 #if defined(USE_X11) |
| 75 // Restrict this correction to X11 which is known to provide bogus timestamps |
| 76 // that require correction (crbug.com/611950). |
| 77 if (!has_valid_timebase) |
| 76 *timestamp = now; | 78 *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 | 79 #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(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |