OLD | NEW |
---|---|
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 Loading... | |
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() |
haraken
2013/04/25 06:33:00
You need to initialize port to 0.
Takashi Toyoshima
2013/04/25 07:20:27
Done.
| |
41 : receivedTime(0.0) | |
42 { | 41 { |
43 }; | 42 }; |
44 | 43 |
45 double receivedTime; | 44 RefPtr<MIDIPort> port; |
46 RefPtr<Uint8Array> data; | |
47 }; | 45 }; |
48 | 46 |
49 class MIDIMessageEvent : public Event { | 47 class MIDIConnectionEvent : public Event { |
50 public: | 48 public: |
51 static PassRefPtr<MIDIMessageEvent> create() | 49 static PassRefPtr<MIDIConnectionEvent> create() |
52 { | 50 { |
53 return adoptRef(new MIDIMessageEvent()); | 51 return adoptRef(new MIDIConnectionEvent()); |
54 } | 52 } |
55 | 53 |
56 static PassRefPtr<MIDIMessageEvent> create(double receivedTime, PassRefPtr<U int8Array> data) | 54 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type) |
57 { | 55 { |
58 return adoptRef(new MIDIMessageEvent(receivedTime, data)); | 56 return adoptRef(new MIDIConnectionEvent(type)); |
59 } | 57 } |
60 | 58 |
61 static PassRefPtr<MIDIMessageEvent> create(const AtomicString& type, const M IDIMessageEventInit& initializer) | 59 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, Pass RefPtr<MIDIPort> port) |
62 { | 60 { |
63 return adoptRef(new MIDIMessageEvent(type, initializer)); | 61 return adoptRef(new MIDIConnectionEvent(type, port)); |
64 } | 62 } |
65 | 63 |
66 double receivedTime() { return m_receivedTime; } | 64 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, cons t MIDIConnectionEventInit& initializer) |
67 PassRefPtr<Uint8Array> data() { return m_data; } | 65 { |
66 return adoptRef(new MIDIConnectionEvent(type, initializer)); | |
67 } | |
68 | |
69 RefPtr<MIDIPort> port() { return m_port; } | |
70 | |
71 // Event: | |
haraken
2013/04/25 06:33:00
Nit: Remove the comment.
Takashi Toyoshima
2013/04/25 07:20:27
Done.
| |
72 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam es().interfaceForMIDIConnectionEvent; } | |
68 | 73 |
69 private: | 74 private: |
70 MIDIMessageEvent() | 75 MIDIConnectionEvent() |
71 : m_receivedTime(0.0) | |
72 { | 76 { |
73 ScriptWrappable::init(this); | 77 ScriptWrappable::init(this); |
74 } | 78 } |
75 | 79 |
76 MIDIMessageEvent(double receivedTime, PassRefPtr<Uint8Array> data) | 80 MIDIConnectionEvent(const AtomicString& type) |
77 : m_receivedTime(receivedTime) | 81 : Event(type, false, false) |
78 , m_data(data) | |
79 { | 82 { |
80 ScriptWrappable::init(this); | 83 ScriptWrappable::init(this); |
81 } | 84 } |
82 | 85 |
83 MIDIMessageEvent(const AtomicString& type, const MIDIMessageEventInit& initi alizer) | 86 MIDIConnectionEvent(const AtomicString& type, PassRefPtr<MIDIPort> port) |
haraken
2013/04/25 06:33:00
Do you really need all of MIDIConnectionEvent(), M
Takashi Toyoshima
2013/04/25 07:20:27
First one is used by auto-generated code.
The seco
| |
84 : Event(type, initializer) | 87 : Event(type, false, false) |
85 , m_receivedTime(initializer.receivedTime) | 88 , m_port(port) |
86 , m_data(initializer.data) | |
87 { | 89 { |
88 ScriptWrappable::init(this); | 90 ScriptWrappable::init(this); |
89 } | 91 } |
90 | 92 |
91 double m_receivedTime; | 93 MIDIConnectionEvent(const AtomicString& type, const MIDIConnectionEventInit& initializer) |
92 RefPtr<Uint8Array> m_data; | 94 : Event(type, initializer) |
95 , m_port(initializer.port) | |
96 { | |
97 ScriptWrappable::init(this); | |
98 } | |
99 | |
100 RefPtr<MIDIPort> m_port; | |
93 }; | 101 }; |
94 | 102 |
95 } // namespace WebCore | 103 } // namespace WebCore |
96 | 104 |
97 #endif // MIDIMessageEvent_h | 105 #endif // MIDIConnectionEvent_h |
OLD | NEW |