Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: content/renderer/device_orientation/device_motion_event_pump.h

Issue 14678012: Implement the content/renderer and content/browser part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compilation: peer_handle -> PeerHandle() Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/timer/timer.h"
11 #include "content/public/renderer/render_process_observer.h"
12 #include "content/renderer/shared_memory_seqlock_reader.h"
13 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h"
14
15 namespace WebKit {
16 class WebDeviceMotionListener;
17 }
18
19 namespace content {
20 class RenderThread;
21
22 typedef SharedMemorySeqLockReader<WebKit::WebDeviceMotionData>
23 DeviceMotionSharedMemoryReader;
24
25 class CONTENT_EXPORT DeviceMotionEventPump : public RenderProcessObserver {
26 public:
27 DeviceMotionEventPump();
28 virtual ~DeviceMotionEventPump();
29
30 static double GetDelayMillis();
31
32 // Sets the listener to receive updates for device motion data at
33 // regular intervals.
34 // Returns true if the registration was successful.
35 bool SetListener(WebKit::WebDeviceMotionListener*);
36
37 void SetDeviceMotionReader(scoped_ptr<DeviceMotionSharedMemoryReader>);
38
39 void Attach(RenderThread* thread);
40
41 // RenderProcessObserver implementation.
42 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
43
44 protected:
45 // Delay between subsequent firing of events.
46 static const double kPumpDelayMillis;
47
48 // The pump is a tri-state automaton with allowed transitions as follows:
49 // STOPPED -> PENDING_START
50 // PENDING_START -> RUNNING
51 // PENDING_START -> STOPPED
52 // RUNNING -> STOPPED
53 enum PumpState {
54 STOPPED,
55 RUNNING,
56 PENDING_START
57 };
58
59 bool StartFetchingDeviceMotion();
60 bool StopFetchingDeviceMotion();
61 void OnDidStartDeviceMotion(base::SharedMemoryHandle renderer_handle);
62 void FireEvent();
63
64 WebKit::WebDeviceMotionListener* listener_;
65 scoped_ptr<DeviceMotionSharedMemoryReader> reader_;
66 base::RepeatingTimer<DeviceMotionEventPump> timer_;
67 PumpState state_;
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_RENDERER_DEVICE_MOTION_EVENT_PUMP_H_
OLDNEW
« no previous file with comments | « content/renderer/device_orientation/OWNERS ('k') | content/renderer/device_orientation/device_motion_event_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698