OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/evdev/libgestures_glue/gesture_timer_provider.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" |
6 | 6 |
7 #include <gestures/gestures.h> | 7 #include <gestures/gestures.h> |
8 | 8 |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 delay * base::Time::kMicrosecondsPerSecond), | 22 delay * base::Time::kMicrosecondsPerSecond), |
23 this, | 23 this, |
24 &GesturesTimer::OnTimerExpired); | 24 &GesturesTimer::OnTimerExpired); |
25 } | 25 } |
26 | 26 |
27 void Cancel() { timer_.Stop(); } | 27 void Cancel() { timer_.Stop(); } |
28 | 28 |
29 private: | 29 private: |
30 void OnTimerExpired() { | 30 void OnTimerExpired() { |
31 struct timespec ts; | 31 struct timespec ts; |
32 DCHECK(!clock_gettime(CLOCK_MONOTONIC, &ts)); | 32 int fail = clock_gettime(CLOCK_MONOTONIC, &ts); |
| 33 DCHECK(!fail); |
| 34 |
| 35 // Run the callback and reschedule the next run if requested. |
33 stime_t next_delay = callback_(StimeFromTimespec(&ts), callback_data_); | 36 stime_t next_delay = callback_(StimeFromTimespec(&ts), callback_data_); |
34 if (next_delay >= 0) { | 37 if (next_delay >= 0) { |
35 timer_.Start(FROM_HERE, | 38 timer_.Start(FROM_HERE, |
36 base::TimeDelta::FromMicroseconds( | 39 base::TimeDelta::FromMicroseconds( |
37 next_delay * base::Time::kMicrosecondsPerSecond), | 40 next_delay * base::Time::kMicrosecondsPerSecond), |
38 this, | 41 this, |
39 &GesturesTimer::OnTimerExpired); | 42 &GesturesTimer::OnTimerExpired); |
40 } | 43 } |
41 } | 44 } |
42 | 45 |
(...skipping 20 matching lines...) Expand all Loading... |
63 | 66 |
64 void GesturesTimerFree(void* data, GesturesTimer* timer) { delete timer; } | 67 void GesturesTimerFree(void* data, GesturesTimer* timer) { delete timer; } |
65 | 68 |
66 } // namespace | 69 } // namespace |
67 | 70 |
68 const GesturesTimerProvider kGestureTimerProvider = { | 71 const GesturesTimerProvider kGestureTimerProvider = { |
69 GesturesTimerCreate, GesturesTimerSet, GesturesTimerCancel, | 72 GesturesTimerCreate, GesturesTimerSet, GesturesTimerCancel, |
70 GesturesTimerFree}; | 73 GesturesTimerFree}; |
71 | 74 |
72 } // namespace ui | 75 } // namespace ui |
OLD | NEW |