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

Side by Side Diff: ui/events/base_event_utils.h

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: Fix macOS test 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef UI_EVENTS_BASE_EVENT_UTILS_H_ 5 #ifndef UI_EVENTS_BASE_EVENT_UTILS_H_
6 #define UI_EVENTS_BASE_EVENT_UTILS_H_ 6 #define UI_EVENTS_BASE_EVENT_UTILS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory>
sadrul 2016/06/23 16:38:37 sort
majidvp 2016/06/24 19:40:56 Done.
9 10
11 #include "base/time/tick_clock.h"
10 #include "ui/events/events_base_export.h" 12 #include "ui/events/events_base_export.h"
11 13
12 namespace base { 14 namespace base {
13 class TimeTicks; 15 class TimeTicks;
14 } 16 }
15 17
16 // Common functions to be used for all platforms. 18 // Common functions to be used for all platforms.
17 namespace ui { 19 namespace ui {
18 20
19 // Generate an unique identifier for events. 21 // Generate an unique identifier for events.
20 EVENTS_BASE_EXPORT uint32_t GetNextTouchEventId(); 22 EVENTS_BASE_EXPORT uint32_t GetNextTouchEventId();
21 23
22 // Checks if |flags| contains system key modifiers. 24 // Checks if |flags| contains system key modifiers.
23 EVENTS_BASE_EXPORT bool IsSystemKeyModifier(int flags); 25 EVENTS_BASE_EXPORT bool IsSystemKeyModifier(int flags);
24 26
27 // Create a timestamp based on the current time.
28 EVENTS_BASE_EXPORT base::TimeTicks EventTimeForNow();
29
30 EVENTS_BASE_EXPORT void SetEventTickClockForTesting(
31 std::unique_ptr<base::TickClock> tick_clock);
32
25 // Converts an event timestamp ticks to seconds (floating point representation). 33 // Converts an event timestamp ticks to seconds (floating point representation).
26 // WARNING: This should only be used when interfacing with platform code that 34 // WARNING: This should only be used when interfacing with platform code that
27 // does not use base::Time* types. 35 // does not use base::Time* types.
28 EVENTS_BASE_EXPORT double EventTimeStampToSeconds(base::TimeTicks time_stamp); 36 EVENTS_BASE_EXPORT double EventTimeStampToSeconds(base::TimeTicks time_stamp);
29 37
30 // Converts an event timestamp in seconds to TimeTicks. 38 // Converts an event timestamp in seconds to TimeTicks.
31 // WARNING: This should only be used when interfacing with platform code that 39 // WARNING: This should only be used when interfacing with platform code that
32 // does not use base::Time* types. 40 // does not use base::Time* types.
33 EVENTS_BASE_EXPORT base::TimeTicks EventTimeStampFromSeconds( 41 EVENTS_BASE_EXPORT base::TimeTicks EventTimeStampFromSeconds(
34 double time_stamp_seconds); 42 double time_stamp_seconds);
35 43
36 } // namespace ui 44 } // namespace ui
37 45
38 #endif // UI_EVENTS_BASE_EVENT_UTILS_H_ 46 #endif // UI_EVENTS_BASE_EVENT_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698