| 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 "content/renderer/device_sensors/device_sensor_event_pump.h" | 9 #include "content/renderer/device_sensors/device_sensor_event_pump.h" |
| 10 #include "content/renderer/shared_memory_seqlock_reader.h" | 10 #include "content/renderer/shared_memory_seqlock_reader.h" |
| 11 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | 11 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 class WebDeviceOrientationListener; | 14 class WebDeviceOrientationListener; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData> | 19 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData> |
| 20 DeviceOrientationSharedMemoryReader; | 20 DeviceOrientationSharedMemoryReader; |
| 21 | 21 |
| 22 class CONTENT_EXPORT DeviceOrientationEventPump | 22 class CONTENT_EXPORT DeviceOrientationEventPump |
| 23 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> { | 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(RenderThread* thread); |
| 30 virtual ~DeviceOrientationEventPump(); | 30 ~DeviceOrientationEventPump() override; |
| 31 | 31 |
| 32 // PlatformEventObserver. | 32 // PlatformEventObserver. |
| 33 virtual bool OnControlMessageReceived(const IPC::Message& message) override; | 33 bool OnControlMessageReceived(const IPC::Message& message) override; |
| 34 virtual void SendFakeDataForTesting(void* data) override; | 34 void SendFakeDataForTesting(void* data) override; |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 virtual void FireEvent() override; | 37 void FireEvent() override; |
| 38 virtual bool InitializeReader(base::SharedMemoryHandle handle) override; | 38 bool InitializeReader(base::SharedMemoryHandle handle) override; |
| 39 | 39 |
| 40 // PlatformEventObserver. | 40 // PlatformEventObserver. |
| 41 virtual void SendStartMessage() override; | 41 void SendStartMessage() override; |
| 42 virtual void SendStopMessage() override; | 42 void SendStopMessage() override; |
| 43 | 43 |
| 44 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; | 44 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const; |
| 45 | 45 |
| 46 blink::WebDeviceOrientationData data_; | 46 blink::WebDeviceOrientationData data_; |
| 47 scoped_ptr<DeviceOrientationSharedMemoryReader> reader_; | 47 scoped_ptr<DeviceOrientationSharedMemoryReader> reader_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPump); | 49 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPump); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace content | 52 } // namespace content |
| 53 | 53 |
| 54 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ | 54 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_ |
| OLD | NEW |