| 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_ORIENTATION_EVENT_PUMP_H_ | 5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ |
| 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ | 6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/shared_memory_seqlock/shared_memory_seqlock_reader.h" |
| 9 #include "content/renderer/device_sensors/device_sensor_event_pump.h" | 10 #include "content/renderer/device_sensors/device_sensor_event_pump.h" |
| 10 #include "content/renderer/shared_memory_seqlock_reader.h" | 11 #include "device/device_sensors/device_sensors.mojom.h" |
| 11 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" | 12 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 class WebDeviceOrientationListener; | 15 class WebDeviceOrientationListener; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData> | 20 typedef shared_memory_seqlock::SharedMemorySeqLockReader< |
| 20 DeviceOrientationSharedMemoryReader; | 21 blink::WebDeviceOrientationData> DeviceOrientationSharedMemoryReader; |
| 21 | 22 |
| 22 class CONTENT_EXPORT DeviceOrientationEventPump | 23 class CONTENT_EXPORT DeviceOrientationEventPump : public DeviceSensorEventPump { |
| 23 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> { | |
| 24 public: | 24 public: |
| 25 // Angle threshold beyond which two orientation events are considered | 25 // Angle threshold beyond which two orientation events are considered |
| 26 // sufficiently different. | 26 // sufficiently different. |
| 27 static const double kOrientationThreshold; | 27 static const double kOrientationThreshold; |
| 28 | 28 |
| 29 explicit DeviceOrientationEventPump(RenderThread* thread); | 29 explicit DeviceOrientationEventPump( |
| 30 blink::WebDeviceOrientationListener* listener); |
| 30 ~DeviceOrientationEventPump() override; | 31 ~DeviceOrientationEventPump() override; |
| 31 | 32 |
| 32 // PlatformEventObserver. | |
| 33 bool OnControlMessageReceived(const IPC::Message& message) override; | |
| 34 void SendFakeDataForTesting(void* data) override; | 33 void SendFakeDataForTesting(void* data) override; |
| 35 | 34 |
| 36 protected: | 35 protected: |
| 37 void FireEvent() override; | 36 void FireEvent() override; |
| 38 bool InitializeReader(base::SharedMemoryHandle handle) override; | 37 bool InitializeReader(base::SharedMemoryHandle handle) override; |
| 39 | 38 |
| 40 // PlatformEventObserver. | |
| 41 void SendStartMessage() override; | |
| 42 void SendStopMessage() override; | |
| 43 | |
| 44 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; | 39 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; |
| 45 | 40 |
| 46 blink::WebDeviceOrientationData data_; | 41 blink::WebDeviceOrientationData data_; |
| 47 scoped_ptr<DeviceOrientationSharedMemoryReader> reader_; | 42 scoped_ptr<DeviceOrientationSharedMemoryReader> reader_; |
| 43 blink::WebDeviceOrientationListener* listener_; |
| 44 device::DeviceSensorsOrientationPtr service_; |
| 48 | 45 |
| 49 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPump); | 46 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPump); |
| 50 }; | 47 }; |
| 51 | 48 |
| 52 } // namespace content | 49 } // namespace content |
| 53 | 50 |
| 54 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ | 51 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ |
| OLD | NEW |