Index: content/renderer/device_motion_event_pump.h |
diff --git a/content/renderer/device_motion_event_pump.h b/content/renderer/device_motion_event_pump.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f118fd2abe47e59333d7c4fdabc8da660c38215e |
--- /dev/null |
+++ b/content/renderer/device_motion_event_pump.h |
@@ -0,0 +1,52 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_ |
+#define CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "base/shared_memory.h" |
+#include "base/time.h" |
+#include "third_party/WebKit/Source/Platform/chromium/public/WebDeviceMotionHandler.h" |
+ |
+namespace WebKit { |
+class WebDeviceMotionData; |
+class WebDeviceMotionListener; |
+} |
+ |
+namespace content { |
+ |
+class DeviceMotionSharedMemoryReader; |
+ |
+class DeviceMotionEventPump : public WebKit::WebDeviceMotionHandler { |
+ public: |
+ DeviceMotionEventPump(); |
+ virtual ~DeviceMotionEventPump(); |
+ |
+ // Delay between subsequent firing of events. |
+ const static double pump_delay_millis = 40; |
jamesr
2013/05/16 19:53:06
put the definition in a translation unit or you'll
timvolodine
2013/05/20 18:18:48
Done.
|
+ |
+ // Sets the listener to receive updates for device motion data at |
+ // regular intervals. |
+ virtual void startListeningToDeviceMotion( |
+ WebKit::WebDeviceMotionListener*) OVERRIDE; |
+ |
+ // Removes the current listener after which it will not receive any updates. |
+ virtual void stopListeningToDeviceMotion() OVERRIDE; |
+ |
+ private: |
+ WebKit::WebDeviceMotionListener* listener_; |
+ |
+ void fire(); |
+ bool shouldFireEvent(WebKit::WebDeviceMotionData&); |
+ |
+ bool fire_pending_; |
+ base::TimeTicks last_fire_event_time_; |
+ scoped_ptr<DeviceMotionSharedMemoryReader> reader_; |
+ base::TimeDelta pump_delay_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_ |