| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "content/renderer/device_sensors/device_sensor_event_pump.h" | 11 #include "content/renderer/device_sensors/device_sensor_event_pump.h" |
| 12 #include "content/renderer/shared_memory_seqlock_reader.h" | 12 #include "content/renderer/shared_memory_seqlock_reader.h" |
| 13 #include "device/sensors/public/cpp/orientation_data.h" |
| 13 #include "device/sensors/public/interfaces/orientation.mojom.h" | 14 #include "device/sensors/public/interfaces/orientation.mojom.h" |
| 14 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" | |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 class WebDeviceOrientationListener; | 17 class WebDeviceOrientationListener; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData> | 22 typedef SharedMemorySeqLockReader<device::OrientationData> |
| 23 DeviceOrientationSharedMemoryReader; | 23 DeviceOrientationSharedMemoryReader; |
| 24 | 24 |
| 25 class CONTENT_EXPORT DeviceOrientationEventPumpBase | 25 class CONTENT_EXPORT DeviceOrientationEventPumpBase |
| 26 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> { | 26 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> { |
| 27 public: | 27 public: |
| 28 // Angle threshold beyond which two orientation events are considered | 28 // Angle threshold beyond which two orientation events are considered |
| 29 // sufficiently different. | 29 // sufficiently different. |
| 30 static const double kOrientationThreshold; | 30 static const double kOrientationThreshold; |
| 31 | 31 |
| 32 explicit DeviceOrientationEventPumpBase(RenderThread* thread); | 32 explicit DeviceOrientationEventPumpBase(RenderThread* thread); |
| 33 ~DeviceOrientationEventPumpBase() override; | 33 ~DeviceOrientationEventPumpBase() override; |
| 34 | 34 |
| 35 // PlatformEventObserver. | 35 // PlatformEventObserver. |
| 36 void SendFakeDataForTesting(void* data) override; | 36 void SendFakeDataForTesting(void* data) override; |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 void FireEvent() override; | 39 void FireEvent() override; |
| 40 bool InitializeReader(base::SharedMemoryHandle handle) override; | 40 bool InitializeReader(base::SharedMemoryHandle handle) override; |
| 41 | 41 |
| 42 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; | 42 bool ShouldFireEvent(const device::OrientationData& data) const; |
| 43 | 43 |
| 44 blink::WebDeviceOrientationData data_; | 44 device::OrientationData data_; |
| 45 std::unique_ptr<DeviceOrientationSharedMemoryReader> reader_; | 45 std::unique_ptr<DeviceOrientationSharedMemoryReader> reader_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPumpBase); | 47 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPumpBase); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 using DeviceOrientationEventPump = | 50 using DeviceOrientationEventPump = |
| 51 DeviceSensorMojoClientMixin<DeviceOrientationEventPumpBase, | 51 DeviceSensorMojoClientMixin<DeviceOrientationEventPumpBase, |
| 52 device::mojom::OrientationSensor>; | 52 device::mojom::OrientationSensor>; |
| 53 | 53 |
| 54 using DeviceOrientationAbsoluteEventPump = | 54 using DeviceOrientationAbsoluteEventPump = |
| 55 DeviceSensorMojoClientMixin<DeviceOrientationEventPumpBase, | 55 DeviceSensorMojoClientMixin<DeviceOrientationEventPumpBase, |
| 56 device::mojom::OrientationAbsoluteSensor>; | 56 device::mojom::OrientationAbsoluteSensor>; |
| 57 | 57 |
| 58 } // namespace content | 58 } // namespace content |
| 59 | 59 |
| 60 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ | 60 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ |
| OLD | NEW |