| OLD | NEW |
| 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 <memory> |
| 8 #include <stdint.h> | 9 #include <stdint.h> |
| 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_ |
| OLD | NEW |