#ifndef CONTENT_RENDERER_DEVICE_SENSOR_EVENT_PUMP_H_
#define CONTENT_RENDERER_DEVICE_SENSOR_EVENT_PUMP_H_
#include "base/memory/shared_memory.h"
#include "base/timer/timer.h"
#include "content/public/renderer/render_process_observer.h"
namespace content {
class RenderThread;
class CONTENT_EXPORT DeviceSensorEventPump : public RenderProcessObserver {
public:
static const int kDefaultPumpDelayMillis;
int GetDelayMillis() const;
void Attach(RenderThread* thread);
virtual bool OnControlMessageReceived(const IPC::Message& message) = 0;
protected:
DeviceSensorEventPump();
explicit DeviceSensorEventPump(int pump_delay_millis);
virtual ~DeviceSensorEventPump();
enum PumpState {
STOPPED,
RUNNING,
PENDING_START
};
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_;
};
}
#endif