| 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 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ | 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ |
| 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ | 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ |
| 7 | 7 |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 state_ = STOPPED; | 49 state_ = STOPPED; |
| 50 } | 50 } |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 explicit DeviceSensorEventPump(RenderThread* thread) | 53 explicit DeviceSensorEventPump(RenderThread* thread) |
| 54 : PlatformEventObserver<ListenerType>(thread), | 54 : PlatformEventObserver<ListenerType>(thread), |
| 55 pump_delay_microseconds_(kDefaultPumpDelayMicroseconds), | 55 pump_delay_microseconds_(kDefaultPumpDelayMicroseconds), |
| 56 state_(STOPPED) {} | 56 state_(STOPPED) {} |
| 57 | 57 |
| 58 virtual ~DeviceSensorEventPump() { | 58 virtual ~DeviceSensorEventPump() { |
| 59 PlatformEventObserver<ListenerType>::StopIfObserving(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 // The pump is a tri-state automaton with allowed transitions as follows: | 62 // The pump is a tri-state automaton with allowed transitions as follows: |
| 62 // STOPPED -> PENDING_START | 63 // STOPPED -> PENDING_START |
| 63 // PENDING_START -> RUNNING | 64 // PENDING_START -> RUNNING |
| 64 // PENDING_START -> STOPPED | 65 // PENDING_START -> STOPPED |
| 65 // RUNNING -> STOPPED | 66 // RUNNING -> STOPPED |
| 66 enum PumpState { | 67 enum PumpState { |
| 67 STOPPED, | 68 STOPPED, |
| 68 RUNNING, | 69 RUNNING, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 int pump_delay_microseconds_; | 93 int pump_delay_microseconds_; |
| 93 PumpState state_; | 94 PumpState state_; |
| 94 base::RepeatingTimer<DeviceSensorEventPump> timer_; | 95 base::RepeatingTimer<DeviceSensorEventPump> timer_; |
| 95 | 96 |
| 96 DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump); | 97 DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 } // namespace content | 100 } // namespace content |
| 100 | 101 |
| 101 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ | 102 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_SENSOR_EVENT_PUMP_H_ |
| OLD | NEW |