| 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 f36992871a3313eb8886676585a71af0c15ea77a..0c66e54035d2fa598ec9f7767b92ba7024858a0b 100644
|
| --- a/content/renderer/device_sensors/device_sensor_event_pump.h
|
| +++ b/content/renderer/device_sensors/device_sensor_event_pump.h
|
| @@ -7,54 +7,28 @@
|
|
|
| #include "base/memory/shared_memory.h"
|
| #include "base/timer/timer.h"
|
| -#include "content/public/renderer/platform_event_observer.h"
|
| +#include "content/public/renderer/render_process_observer.h"
|
|
|
| namespace content {
|
| +class RenderThread;
|
|
|
| -template <typename ListenerType>
|
| -class CONTENT_EXPORT DeviceSensorEventPump
|
| - : NON_EXPORTED_BASE(public PlatformEventObserver<ListenerType>) {
|
| +class CONTENT_EXPORT DeviceSensorEventPump : public RenderProcessObserver {
|
| public:
|
| // Default delay between subsequent firing of events.
|
| - static const int kDefaultPumpDelayMillis = 50;
|
| + static const int kDefaultPumpDelayMillis;
|
|
|
| - // PlatformEventObserver
|
| - virtual void Start(blink::WebPlatformEventListener* listener) OVERRIDE {
|
| - DVLOG(2) << "requested start";
|
| + int GetDelayMillis() const;
|
|
|
| - if (state_ != STOPPED)
|
| - return;
|
| -
|
| - DCHECK(!timer_.IsRunning());
|
| -
|
| - PlatformEventObserver<ListenerType>::Start(listener);
|
| - state_ = PENDING_START;
|
| - }
|
| -
|
| - virtual 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;
|
| - }
|
| + void Attach(RenderThread* thread);
|
| + virtual bool OnControlMessageReceived(const IPC::Message& message) = 0;
|
|
|
| protected:
|
| - explicit DeviceSensorEventPump(RenderThread* thread)
|
| - : PlatformEventObserver<ListenerType>(thread),
|
| - pump_delay_millis_(kDefaultPumpDelayMillis),
|
| - state_(STOPPED) {
|
| - }
|
| + // Constructor for a pump with default delay.
|
| + DeviceSensorEventPump();
|
|
|
| - virtual ~DeviceSensorEventPump() {
|
| - }
|
| + // Constructor for a pump with a given delay.
|
| + explicit DeviceSensorEventPump(int pump_delay_millis);
|
| + virtual ~DeviceSensorEventPump();
|
|
|
| // The pump is a tri-state automaton with allowed transitions as follows:
|
| // STOPPED -> PENDING_START
|
| @@ -67,30 +41,18 @@ class CONTENT_EXPORT DeviceSensorEventPump
|
| PENDING_START
|
| };
|
|
|
| - void OnDidStart(base::SharedMemoryHandle handle) {
|
| - DVLOG(2) << "did start sensor event pump";
|
| -
|
| - if (state_ != PENDING_START)
|
| - return;
|
| -
|
| - DCHECK(!timer_.IsRunning());
|
| -
|
| - if (InitializeReader(handle)) {
|
| - timer_.Start(FROM_HERE,
|
| - base::TimeDelta::FromMilliseconds(pump_delay_millis_),
|
| - this, &DeviceSensorEventPump::FireEvent);
|
| - state_ = RUNNING;
|
| - }
|
| - }
|
| + bool RequestStart();
|
| + void OnDidStart(base::SharedMemoryHandle handle);
|
| + bool Stop();
|
|
|
| virtual void FireEvent() = 0;
|
| virtual bool InitializeReader(base::SharedMemoryHandle handle) = 0;
|
| + virtual bool SendStartMessage() = 0;
|
| + virtual bool SendStopMessage() = 0;
|
|
|
| int pump_delay_millis_;
|
| PumpState state_;
|
| base::RepeatingTimer<DeviceSensorEventPump> timer_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(DeviceSensorEventPump);
|
| };
|
|
|
| } // namespace content
|
|
|