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

Side by Side Diff: Source/modules/webmidi/MIDIConnectionEvent.h

Issue 14358032: Web MIDI: implement MIDIConnectionEvent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: (rebase) Created 7 years, 8 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 MIDIMessageEvent_h 31 #ifndef MIDIConnectionEvent_h
32 #define MIDIMessageEvent_h 32 #define MIDIConnectionEvent_h
33 33
34 #include "core/dom/Event.h" 34 #include "core/dom/Event.h"
35 #include "wtf/Uint8Array.h" 35 #include "modules/webmidi/MIDIPort.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 struct MIDIMessageEventInit : public EventInit { 39 struct MIDIConnectionEventInit : public EventInit {
40 MIDIMessageEventInit() 40 MIDIConnectionEventInit()
41 : receivedTime(0.0) 41 : port(0)
42 { 42 {
43 }; 43 };
44 44
45 double receivedTime; 45 RefPtr<MIDIPort> port;
46 RefPtr<Uint8Array> data;
47 }; 46 };
48 47
49 class MIDIMessageEvent : public Event { 48 class MIDIConnectionEvent : public Event {
50 public: 49 public:
51 static PassRefPtr<MIDIMessageEvent> create() 50 static PassRefPtr<MIDIConnectionEvent> create()
52 { 51 {
53 return adoptRef(new MIDIMessageEvent()); 52 return adoptRef(new MIDIConnectionEvent());
54 } 53 }
55 54
56 static PassRefPtr<MIDIMessageEvent> create(double receivedTime, PassRefPtr<U int8Array> data) 55 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, Pass RefPtr<MIDIPort> port)
57 { 56 {
58 return adoptRef(new MIDIMessageEvent(receivedTime, data)); 57 return adoptRef(new MIDIConnectionEvent(type, port));
59 } 58 }
60 59
61 static PassRefPtr<MIDIMessageEvent> create(const AtomicString& type, const M IDIMessageEventInit& initializer) 60 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, cons t MIDIConnectionEventInit& initializer)
62 { 61 {
63 return adoptRef(new MIDIMessageEvent(type, initializer)); 62 return adoptRef(new MIDIConnectionEvent(type, initializer));
64 } 63 }
65 64
66 double receivedTime() { return m_receivedTime; } 65 RefPtr<MIDIPort> port() { return m_port; }
67 PassRefPtr<Uint8Array> data() { return m_data; } 66
67 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam es().interfaceForMIDIConnectionEvent; }
68 68
69 private: 69 private:
70 MIDIMessageEvent() 70 MIDIConnectionEvent()
71 : m_receivedTime(0.0)
72 { 71 {
73 ScriptWrappable::init(this); 72 ScriptWrappable::init(this);
74 } 73 }
75 74
76 MIDIMessageEvent(double receivedTime, PassRefPtr<Uint8Array> data) 75 MIDIConnectionEvent(const AtomicString& type, PassRefPtr<MIDIPort> port)
77 : m_receivedTime(receivedTime) 76 : Event(type, false, false)
78 , m_data(data) 77 , m_port(port)
79 { 78 {
80 ScriptWrappable::init(this); 79 ScriptWrappable::init(this);
81 } 80 }
82 81
83 MIDIMessageEvent(const AtomicString& type, const MIDIMessageEventInit& initi alizer) 82 MIDIConnectionEvent(const AtomicString& type, const MIDIConnectionEventInit& initializer)
84 : Event(type, initializer) 83 : Event(type, initializer)
85 , m_receivedTime(initializer.receivedTime) 84 , m_port(initializer.port)
86 , m_data(initializer.data)
87 { 85 {
88 ScriptWrappable::init(this); 86 ScriptWrappable::init(this);
89 } 87 }
90 88
91 double m_receivedTime; 89 RefPtr<MIDIPort> m_port;
92 RefPtr<Uint8Array> m_data;
93 }; 90 };
94 91
95 } // namespace WebCore 92 } // namespace WebCore
96 93
97 #endif // MIDIMessageEvent_h 94 #endif // MIDIConnectionEvent_h
OLDNEW
« no previous file with comments | « Source/modules/webmidi/DOMWindowWebMIDI.idl ('k') | Source/modules/webmidi/MIDIConnectionEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698