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

Side by Side Diff: Source/core/platform/midi/MIDIAccessorChromium.h

Issue 16288002: Web MIDI API (work in progress) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add accessApproved() Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef DeviceMotionDispatcher_h 31 #ifndef MIDIAccessorChromium_h
32 #define DeviceMotionDispatcher_h 32 #define MIDIAccessorChromium_h
33 33
34 #include "DeviceMotionData.h" 34 #include "core/platform/midi/MIDIAccessor.h"
35 #include "wtf/RefPtr.h" 35 #include "wtf/OwnPtr.h"
36 #include "wtf/Vector.h" 36 #include "public/platform/WebMIDIAccessor.h"
37 #include "public/platform/WebDeviceMotionListener.h" 37 #include "public/platform/WebString.h"
38 38
39 namespace WebKit { 39 namespace WebCore {
40 class WebDeviceMotionData;
41 }
42 40
43 namespace WebCore { 41 class MIDIAccessorChromium : public MIDIAccessor, public WebKit::WebMIDIAccessor ::Client {
42 public:
43 MIDIAccessorChromium(MIDIAccessorClient*);
44 virtual ~MIDIAccessorChromium() { }
44 45
45 class DeviceMotionController; 46 // MIDIAccessor
46 class DeviceMotionData; 47 virtual void requestAccess(int access) OVERRIDE;
48 virtual void sendMIDIData(unsigned portIndex, const unsigned char* data, siz e_t length, double timeStamp) OVERRIDE;
47 49
48 // This class listens to device motion data and dispatches it to all 50 // WebKit::WebMIDIAccessor::Client
49 // listening controllers. 51 virtual void addInputPort(const WebKit::WebString& id, const WebKit::WebStri ng& manufacturer, const WebKit::WebString& name, const WebKit::WebString& versio n) OVERRIDE;
50 class DeviceMotionDispatcher : public WebKit::WebDeviceMotionListener { 52 virtual void addOutputPort(const WebKit::WebString& id, const WebKit::WebStr ing& manufacturer, const WebKit::WebString& name, const WebKit::WebString& versi on) OVERRIDE;
51 public: 53 virtual void accessApproved(bool approved) OVERRIDE;
52 static DeviceMotionDispatcher& instance(); 54 virtual void receiveMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp) OVERRIDE;
53
54 void addController(DeviceMotionController*);
55 void removeController(DeviceMotionController*);
56
57 // Note that the returned object is owned by this class.
58 // FIXME: make the return value const, see crbug.com/233174.
59 DeviceMotionData* latestDeviceMotionData();
60
61 // This method is called every time new device motion data is available.
62 virtual void didChangeDeviceMotion(const WebKit::WebDeviceMotionData&) OVERR IDE;
63 55
64 private: 56 private:
65 DeviceMotionDispatcher(); 57 MIDIAccessorClient* m_client;
66 ~DeviceMotionDispatcher();
67 58
68 void startListening(); 59 OwnPtr<WebKit::WebMIDIAccessor> m_accessor;
69 void stopListening();
70
71 void purgeControllers();
72
73 RefPtr<DeviceMotionData> m_lastDeviceMotionData;
74 Vector<DeviceMotionController*> m_controllers;
75 }; 60 };
76 61
77 } // namespace WebCore 62 } // namespace WebCore
78 63
79 #endif // DeviceMotionDispatcher_h 64 #endif // MIDIAccessorChromium_h
OLDNEW
« no previous file with comments | « Source/core/platform/midi/MIDIAccessor.h ('k') | Source/core/platform/midi/MIDIAccessorChromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698