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