| 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_LIGHT_EVENT_PUMP_H_ | 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ |
| 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ | 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/device_sensors/device_light_data.h" | 9 #include "content/common/device_sensors/device_light_data.h" |
| 10 #include "content/renderer/device_sensors/device_sensor_event_pump.h" | 10 #include "content/renderer/device_sensors/device_sensor_event_pump.h" |
| 11 #include "content/renderer/shared_memory_seqlock_reader.h" | 11 #include "content/renderer/shared_memory_seqlock_reader.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 class WebDeviceLightListener; | 14 class WebDeviceLightListener; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 typedef SharedMemorySeqLockReader<DeviceLightData> | 19 typedef SharedMemorySeqLockReader<DeviceLightData> |
| 20 DeviceLightSharedMemoryReader; | 20 DeviceLightSharedMemoryReader; |
| 21 | 21 |
| 22 class CONTENT_EXPORT DeviceLightEventPump | 22 class CONTENT_EXPORT DeviceLightEventPump : public DeviceSensorEventPump { |
| 23 : public DeviceSensorEventPump<blink::WebDeviceLightListener> { | |
| 24 public: | 23 public: |
| 25 explicit DeviceLightEventPump(RenderThread* thread); | 24 DeviceLightEventPump(); |
| 25 explicit DeviceLightEventPump(int pump_delay_millis); |
| 26 virtual ~DeviceLightEventPump(); | 26 virtual ~DeviceLightEventPump(); |
| 27 | 27 |
| 28 // Sets the listener to receive updates for device light data at | 28 // Sets the listener to receive updates for device light data at |
| 29 // regular intervals. Returns true if the registration was successful. | 29 // regular intervals. Returns true if the registration was successful. |
| 30 bool SetListener(blink::WebDeviceLightListener* listener); | 30 bool SetListener(blink::WebDeviceLightListener* listener); |
| 31 | 31 |
| 32 // PlatformEventObserver implementation. | 32 // RenderProcessObserver implementation. |
| 33 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 33 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
| 34 virtual void SendFakeDataForTesting(void* data) OVERRIDE; | |
| 35 | 34 |
| 36 protected: | 35 protected: |
| 37 // Methods overriden from base class DeviceSensorEventPump | 36 // Methods overriden from base class DeviceSensorEventPump |
| 38 virtual void FireEvent() OVERRIDE; | 37 virtual void FireEvent() OVERRIDE; |
| 39 virtual bool InitializeReader(base::SharedMemoryHandle handle) OVERRIDE; | 38 virtual bool InitializeReader(base::SharedMemoryHandle handle) OVERRIDE; |
| 39 virtual bool SendStartMessage() OVERRIDE; |
| 40 virtual bool SendStopMessage() OVERRIDE; |
| 40 | 41 |
| 41 // PlatformEventObserver implementation. | 42 blink::WebDeviceLightListener* listener_; |
| 42 virtual void SendStartMessage() OVERRIDE; | |
| 43 virtual void SendStopMessage() OVERRIDE; | |
| 44 | |
| 45 scoped_ptr<DeviceLightSharedMemoryReader> reader_; | 43 scoped_ptr<DeviceLightSharedMemoryReader> reader_; |
| 46 double last_seen_data_; | 44 double last_seen_data_; |
| 47 | 45 |
| 48 DISALLOW_COPY_AND_ASSIGN(DeviceLightEventPump); | 46 DISALLOW_COPY_AND_ASSIGN(DeviceLightEventPump); |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 } // namespace content | 49 } // namespace content |
| 52 | 50 |
| 53 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ | 51 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_LIGHT_EVENT_PUMP_H_ |
| OLD | NEW |