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/interfaces/orientation.mojom.h" |
13 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" | 14 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 class WebDeviceOrientationListener; | 17 class WebDeviceOrientationListener; |
17 } | 18 } |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData> | 22 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData> |
22 DeviceOrientationSharedMemoryReader; | 23 DeviceOrientationSharedMemoryReader; |
23 | 24 |
24 class CONTENT_EXPORT DeviceOrientationEventPump | 25 class CONTENT_EXPORT DeviceOrientationEventPumpBase |
25 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> { | 26 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> { |
26 public: | 27 public: |
27 // Angle threshold beyond which two orientation events are considered | 28 // Angle threshold beyond which two orientation events are considered |
28 // sufficiently different. | 29 // sufficiently different. |
29 static const double kOrientationThreshold; | 30 static const double kOrientationThreshold; |
30 | 31 |
31 explicit DeviceOrientationEventPump(RenderThread* thread); | 32 explicit DeviceOrientationEventPumpBase(RenderThread* thread); |
32 ~DeviceOrientationEventPump() override; | 33 ~DeviceOrientationEventPumpBase() override; |
33 | 34 |
34 // PlatformEventObserver. | 35 // PlatformEventObserver. |
35 bool OnControlMessageReceived(const IPC::Message& message) override; | |
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 // PlatformEventObserver. | |
43 void SendStartMessage() override; | |
44 void SendStopMessage() override; | |
45 | |
46 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; | 42 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; |
47 | 43 |
48 blink::WebDeviceOrientationData data_; | 44 blink::WebDeviceOrientationData data_; |
49 std::unique_ptr<DeviceOrientationSharedMemoryReader> reader_; | 45 std::unique_ptr<DeviceOrientationSharedMemoryReader> reader_; |
50 | 46 |
51 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPump); | 47 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPumpBase); |
52 }; | 48 }; |
53 | 49 |
| 50 using DeviceOrientationEventPump = |
| 51 DeviceSensorMojoClientMixin<DeviceOrientationEventPumpBase, |
| 52 device::mojom::OrientationSensor>; |
| 53 |
| 54 using DeviceOrientationAbsoluteEventPump = |
| 55 DeviceSensorMojoClientMixin<DeviceOrientationEventPumpBase, |
| 56 device::mojom::OrientationAbsoluteSensor>; |
| 57 |
54 } // namespace content | 58 } // namespace content |
55 | 59 |
56 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ | 60 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ |
OLD | NEW |