| 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 CHECK(!clock_gettime(CLOCK_MONOTONIC, &ts)); | 32 DCHECK(!clock_gettime(CLOCK_MONOTONIC, &ts)); |
| 33 stime_t next_delay = callback_(StimeFromTimespec(&ts), callback_data_); | 33 stime_t next_delay = callback_(StimeFromTimespec(&ts), callback_data_); |
| 34 if (next_delay >= 0) { | 34 if (next_delay >= 0) { |
| 35 timer_.Start(FROM_HERE, | 35 timer_.Start(FROM_HERE, |
| 36 base::TimeDelta::FromMicroseconds( | 36 base::TimeDelta::FromMicroseconds( |
| 37 next_delay * base::Time::kMicrosecondsPerSecond), | 37 next_delay * base::Time::kMicrosecondsPerSecond), |
| 38 this, | 38 this, |
| 39 &GesturesTimer::OnTimerExpired); | 39 &GesturesTimer::OnTimerExpired); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 | 63 |
| 64 void GesturesTimerFree(void* data, GesturesTimer* timer) { delete timer; } | 64 void GesturesTimerFree(void* data, GesturesTimer* timer) { delete timer; } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 const GesturesTimerProvider kGestureTimerProvider = { | 68 const GesturesTimerProvider kGestureTimerProvider = { |
| 69 GesturesTimerCreate, GesturesTimerSet, GesturesTimerCancel, | 69 GesturesTimerCreate, GesturesTimerSet, GesturesTimerCancel, |
| 70 GesturesTimerFree}; | 70 GesturesTimerFree}; |
| 71 | 71 |
| 72 } // namespace ui | 72 } // namespace ui |
| OLD | NEW |