| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 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 |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 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 CloseEvent_h | 31 #ifndef MIDIMessageEvent_h |
| 32 #define CloseEvent_h | 32 #define MIDIMessageEvent_h |
| 33 | 33 |
| 34 #include "Event.h" | 34 #include "Event.h" |
| 35 #include "EventNames.h" | 35 #include <wtf/Uint8Array.h> |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 struct CloseEventInit : public EventInit { | 39 struct MIDIMessageEventInit : public EventInit { |
| 40 CloseEventInit() | 40 MIDIMessageEventInit() |
| 41 : wasClean(false) | 41 : receivedTime(0.0) |
| 42 , code(0) | |
| 43 { | 42 { |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 bool wasClean; | 45 double receivedTime; |
| 47 unsigned short code; | 46 RefPtr<Uint8Array> data; |
| 48 String reason; | |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 class CloseEvent : public Event { | 49 class MIDIMessageEvent : public Event { |
| 52 public: | 50 public: |
| 53 static PassRefPtr<CloseEvent> create() | 51 static PassRefPtr<MIDIMessageEvent> create() |
| 54 { | 52 { |
| 55 return adoptRef(new CloseEvent()); | 53 return adoptRef(new MIDIMessageEvent()); |
| 56 } | 54 } |
| 57 | 55 |
| 58 static PassRefPtr<CloseEvent> create(bool wasClean, unsigned short code, con
st String& reason) | 56 static PassRefPtr<MIDIMessageEvent> create(double receivedTime, PassRefPtr<U
int8Array> data) |
| 59 { | 57 { |
| 60 return adoptRef(new CloseEvent(wasClean, code, reason)); | 58 return adoptRef(new MIDIMessageEvent(receivedTime, data)); |
| 61 } | 59 } |
| 62 | 60 |
| 63 static PassRefPtr<CloseEvent> create(const AtomicString& type, const CloseEv
entInit& initializer) | 61 static PassRefPtr<MIDIMessageEvent> create(const AtomicString& type, const M
IDIMessageEventInit& initializer) |
| 64 { | 62 { |
| 65 return adoptRef(new CloseEvent(type, initializer)); | 63 return adoptRef(new MIDIMessageEvent(type, initializer)); |
| 66 } | 64 } |
| 67 | 65 |
| 68 bool wasClean() const { return m_wasClean; } | 66 double receivedTime() { return m_receivedTime; } |
| 69 unsigned short code() const { return m_code; } | 67 PassRefPtr<Uint8Array> data() { return m_data; } |
| 70 String reason() const { return m_reason; } | |
| 71 | |
| 72 // Event function. | |
| 73 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForCloseEvent; } | |
| 74 | 68 |
| 75 private: | 69 private: |
| 76 CloseEvent() | 70 MIDIMessageEvent() |
| 77 : Event(eventNames().closeEvent, false, false) | 71 : m_receivedTime(0.0) |
| 78 , m_wasClean(false) | |
| 79 , m_code(0) | |
| 80 { | 72 { |
| 81 ScriptWrappable::init(this); | 73 ScriptWrappable::init(this); |
| 82 } | 74 } |
| 83 | 75 |
| 84 CloseEvent(bool wasClean, int code, const String& reason) | 76 MIDIMessageEvent(double receivedTime, PassRefPtr<Uint8Array> data) |
| 85 : Event(eventNames().closeEvent, false, false) | 77 : m_receivedTime(receivedTime) |
| 86 , m_wasClean(wasClean) | 78 , m_data(data) |
| 87 , m_code(code) | |
| 88 , m_reason(reason) | |
| 89 { | 79 { |
| 90 ScriptWrappable::init(this); | 80 ScriptWrappable::init(this); |
| 91 } | 81 } |
| 92 | 82 |
| 93 CloseEvent(const AtomicString& type, const CloseEventInit& initializer) | 83 MIDIMessageEvent(const AtomicString& type, const MIDIMessageEventInit& initi
alizer) |
| 94 : Event(type, initializer) | 84 : Event(type, initializer) |
| 95 , m_wasClean(initializer.wasClean) | 85 , m_receivedTime(initializer.receivedTime) |
| 96 , m_code(initializer.code) | 86 , m_data(initializer.data) |
| 97 , m_reason(initializer.reason) | |
| 98 { | 87 { |
| 99 ScriptWrappable::init(this); | 88 ScriptWrappable::init(this); |
| 100 } | 89 } |
| 101 | 90 |
| 102 bool m_wasClean; | 91 double m_receivedTime; |
| 103 unsigned short m_code; | 92 RefPtr<Uint8Array> m_data; |
| 104 String m_reason; | |
| 105 }; | 93 }; |
| 106 | 94 |
| 107 } // namespace WebCore | 95 } // namespace WebCore |
| 108 | 96 |
| 109 #endif // CloseEvent_h | 97 #endif // MIDIMessageEvent_h |
| OLD | NEW |