OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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. | |
4 | |
5 #ifndef CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_ | |
6 #define CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/shared_memory.h" | |
10 #include "base/time.h" | |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebDeviceMotionHand ler.h" | |
12 | |
13 namespace WebKit { | |
14 class WebDeviceMotionData; | |
15 class WebDeviceMotionListener; | |
16 } | |
17 | |
18 namespace content { | |
19 | |
20 class DeviceMotionSharedMemoryReader; | |
21 | |
22 class DeviceMotionEventPump : public WebKit::WebDeviceMotionHandler { | |
23 public: | |
24 DeviceMotionEventPump(); | |
25 virtual ~DeviceMotionEventPump(); | |
26 | |
27 // Delay between subsequent firing of events. | |
28 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.
| |
29 | |
30 // Sets the listener to receive updates for device motion data at | |
31 // regular intervals. | |
32 virtual void startListeningToDeviceMotion( | |
33 WebKit::WebDeviceMotionListener*) OVERRIDE; | |
34 | |
35 // Removes the current listener after which it will not receive any updates. | |
36 virtual void stopListeningToDeviceMotion() OVERRIDE; | |
37 | |
38 private: | |
39 WebKit::WebDeviceMotionListener* listener_; | |
40 | |
41 void fire(); | |
42 bool shouldFireEvent(WebKit::WebDeviceMotionData&); | |
43 | |
44 bool fire_pending_; | |
45 base::TimeTicks last_fire_event_time_; | |
46 scoped_ptr<DeviceMotionSharedMemoryReader> reader_; | |
47 base::TimeDelta pump_delay_; | |
48 }; | |
49 | |
50 } // namespace content | |
51 | |
52 #endif // CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_ | |
OLD | NEW |