Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / renderer / device_sensors / device_orientation_event_pump.h
blob9f97e91e343e6b393b667a4d1668d31d2f761f51
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_
6 #define CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/renderer/device_sensors/device_sensor_event_pump.h"
10 #include "content/renderer/shared_memory_seqlock_reader.h"
11 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h"
13 namespace blink {
14 class WebDeviceOrientationListener;
17 namespace content {
19 typedef SharedMemorySeqLockReader<blink::WebDeviceOrientationData>
20 DeviceOrientationSharedMemoryReader;
22 class CONTENT_EXPORT DeviceOrientationEventPump
23 : public DeviceSensorEventPump<blink::WebDeviceOrientationListener> {
24 public:
25 // Angle threshold beyond which two orientation events are considered
26 // sufficiently different.
27 static const double kOrientationThreshold;
29 explicit DeviceOrientationEventPump(RenderThread* thread);
30 virtual ~DeviceOrientationEventPump();
32 // PlatformEventObserver.
33 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
34 virtual void SendFakeDataForTesting(void* data) OVERRIDE;
36 protected:
37 virtual void FireEvent() OVERRIDE;
38 virtual bool InitializeReader(base::SharedMemoryHandle handle) OVERRIDE;
40 // PlatformEventObserver.
41 virtual void SendStartMessage() OVERRIDE;
42 virtual void SendStopMessage() OVERRIDE;
44 bool ShouldFireEvent(const blink::WebDeviceOrientationData& data) const;
46 blink::WebDeviceOrientationData data_;
47 scoped_ptr<DeviceOrientationSharedMemoryReader> reader_;
49 DISALLOW_COPY_AND_ASSIGN(DeviceOrientationEventPump);
52 } // namespace content
54 #endif // CONTENT_RENDERER_DEVICE_SENSORS_DEVICE_ORIENTATION_EVENT_PUMP_H_