| 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 16 matching lines...) Expand all Loading... |
| 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 MIDIAccess_h | 31 #ifndef MIDIAccess_h |
| 32 #define MIDIAccess_h | 32 #define MIDIAccess_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptWrappable.h" | 34 #include "bindings/v8/ScriptWrappable.h" |
| 35 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
| 36 #include "core/dom/EventTarget.h" | 36 #include "core/dom/EventTarget.h" |
| 37 #include "core/platform/midi/MIDIAccessor.h" |
| 37 #include "modules/webmidi/MIDIInput.h" | 38 #include "modules/webmidi/MIDIInput.h" |
| 38 #include "modules/webmidi/MIDIOutput.h" | 39 #include "modules/webmidi/MIDIOutput.h" |
| 40 #include "wtf/OwnPtr.h" |
| 39 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
| 40 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
| 41 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 42 | 44 |
| 43 namespace WebCore { | 45 namespace WebCore { |
| 44 | 46 |
| 45 class ScriptExecutionContext; | 47 class ScriptExecutionContext; |
| 46 | 48 |
| 47 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget { | 49 class MIDIAccess : public ActiveDOMObject, public RefCounted<MIDIAccess>, public
EventTarget, public MIDIAccessorClient { |
| 48 public: | 50 public: |
| 49 virtual ~MIDIAccess(); | 51 virtual ~MIDIAccess(); |
| 50 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*); | 52 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*); |
| 51 | 53 |
| 52 MIDIInputVector inputs() const { return m_inputs; } | 54 MIDIInputVector inputs() const { return m_inputs; } |
| 53 MIDIOutputVector outputs() const { return m_outputs; } | 55 MIDIOutputVector outputs() const { return m_outputs; } |
| 54 | 56 |
| 55 using RefCounted<MIDIAccess>::ref; | 57 using RefCounted<MIDIAccess>::ref; |
| 56 using RefCounted<MIDIAccess>::deref; | 58 using RefCounted<MIDIAccess>::deref; |
| 57 | 59 |
| 58 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| 59 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
| 60 | 62 |
| 61 // EventTarget | 63 // EventTarget |
| 62 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } | 64 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } |
| 63 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } | 65 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } |
| 64 | 66 |
| 65 // ActiveDOMObject | 67 // ActiveDOMObject |
| 66 virtual bool canSuspend() const OVERRIDE { return true; } | 68 virtual bool canSuspend() const OVERRIDE { return true; } |
| 67 | 69 |
| 70 // MIDIAccessorClient |
| 71 virtual void addInputPort(const String& id, const String& manufacturer, cons
t String& name, const String& version) OVERRIDE; |
| 72 virtual void addOutputPort(const String& id, const String& manufacturer, con
st String& name, const String& version) OVERRIDE; |
| 73 virtual void accessApproved(bool approved) OVERRIDE; |
| 74 virtual void receiveMIDIData(unsigned portIndex, const unsigned char* data,
size_t length, double timeStamp) OVERRIDE; |
| 75 |
| 68 private: | 76 private: |
| 69 explicit MIDIAccess(ScriptExecutionContext*); | 77 explicit MIDIAccess(ScriptExecutionContext*); |
| 70 | 78 |
| 71 // EventTarget | 79 // EventTarget |
| 72 virtual void refEventTarget() OVERRIDE { ref(); } | 80 virtual void refEventTarget() OVERRIDE { ref(); } |
| 73 virtual void derefEventTarget() OVERRIDE { deref(); } | 81 virtual void derefEventTarget() OVERRIDE { deref(); } |
| 74 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } | 82 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } |
| 75 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } | 83 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } |
| 76 | 84 |
| 77 MIDIInputVector m_inputs; | 85 MIDIInputVector m_inputs; |
| 78 MIDIOutputVector m_outputs; | 86 MIDIOutputVector m_outputs; |
| 79 EventTargetData m_eventTargetData; | 87 EventTargetData m_eventTargetData; |
| 88 |
| 89 OwnPtr<MIDIAccessor> m_midiAccessor; |
| 80 }; | 90 }; |
| 81 | 91 |
| 82 } // namespace WebCore | 92 } // namespace WebCore |
| 83 | 93 |
| 84 #endif // MIDIAccess_h | 94 #endif // MIDIAccess_h |
| OLD | NEW |