Index: content/renderer/device_sensors/device_sensor_event_pump.h |
diff --git a/content/renderer/device_sensors/device_sensor_event_pump.h b/content/renderer/device_sensors/device_sensor_event_pump.h |
index 45e028d8679223b34ecde43ff1317bf7a7180592..fe2cc1ac35935ee47fa848800050ae5df424474d 100644 |
--- a/content/renderer/device_sensors/device_sensor_event_pump.h |
+++ b/content/renderer/device_sensors/device_sensor_event_pump.h |
@@ -8,82 +8,36 @@ |
#include "base/memory/shared_memory.h" |
#include "base/time/time.h" |
#include "base/timer/timer.h" |
-#include "content/public/renderer/platform_event_observer.h" |
+#include "content/common/content_export.h" |
+#include "device/device_sensors/device_sensors.mojom.h" |
+#include "device/device_sensors/type_converters.h" |
namespace content { |
-template <typename ListenerType> |
-class CONTENT_EXPORT DeviceSensorEventPump |
- : NON_EXPORTED_BASE(public PlatformEventObserver<ListenerType>) { |
+class CONTENT_EXPORT DeviceSensorEventPump { |
public: |
// Default rate for firing events. |
static const int kDefaultPumpFrequencyHz = 60; |
static const int kDefaultPumpDelayMicroseconds = |
base::Time::kMicrosecondsPerSecond / kDefaultPumpFrequencyHz; |
- // PlatformEventObserver |
- void Start(blink::WebPlatformEventListener* listener) override { |
- DVLOG(2) << "requested start"; |
- |
- if (state_ != STOPPED) |
- return; |
- |
- DCHECK(!timer_.IsRunning()); |
- |
- PlatformEventObserver<ListenerType>::Start(listener); |
- state_ = PENDING_START; |
- } |
- |
- void Stop() override { |
- DVLOG(2) << "stop"; |
- |
- if (state_ == STOPPED) |
- return; |
- |
- DCHECK((state_ == PENDING_START && !timer_.IsRunning()) || |
- (state_ == RUNNING && timer_.IsRunning())); |
- |
- if (timer_.IsRunning()) |
- timer_.Stop(); |
- PlatformEventObserver<ListenerType>::Stop(); |
- state_ = STOPPED; |
- } |
+ virtual void SendFakeDataForTesting(void* fake_data) = 0; |
protected: |
- explicit DeviceSensorEventPump(RenderThread* thread) |
- : PlatformEventObserver<ListenerType>(thread), |
- pump_delay_microseconds_(kDefaultPumpDelayMicroseconds), |
- state_(STOPPED) {} |
- |
- ~DeviceSensorEventPump() override { |
- PlatformEventObserver<ListenerType>::StopIfObserving(); |
- } |
+ explicit DeviceSensorEventPump(); |
- // The pump is a tri-state automaton with allowed transitions as follows: |
- // STOPPED -> PENDING_START |
- // PENDING_START -> RUNNING |
- // PENDING_START -> STOPPED |
- // RUNNING -> STOPPED |
- enum PumpState { |
- STOPPED, |
- RUNNING, |
- PENDING_START |
- }; |
+ virtual ~DeviceSensorEventPump(); |
- void OnDidStart(base::SharedMemoryHandle handle) { |
+ void OnDidStart(device::SharedMemoryPtr handle_ptr) { |
DVLOG(2) << "did start sensor event pump"; |
- if (state_ != PENDING_START) |
- return; |
- |
- DCHECK(!timer_.IsRunning()); |
- |
+ base::SharedMemoryHandle handle = handle_ptr.To<base::SharedMemoryHandle>(); |
if (InitializeReader(handle)) { |
+ LOG(INFO) << "DeviceSensorEventPump::OnDidStart, InitializeReader OK"; |
timer_.Start(FROM_HERE, |
base::TimeDelta::FromMicroseconds(pump_delay_microseconds_), |
this, |
&DeviceSensorEventPump::FireEvent); |
- state_ = RUNNING; |
} |
} |
@@ -91,7 +45,6 @@ class CONTENT_EXPORT DeviceSensorEventPump |
virtual bool InitializeReader(base::SharedMemoryHandle handle) = 0; |
int pump_delay_microseconds_; |
- PumpState state_; |
base::RepeatingTimer<DeviceSensorEventPump> timer_; |
DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump); |