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" |
| 38 #include "core/platform/midi/MIDIAccessorClient.h" |
37 #include "modules/webmidi/MIDIInput.h" | 39 #include "modules/webmidi/MIDIInput.h" |
38 #include "modules/webmidi/MIDIOutput.h" | 40 #include "modules/webmidi/MIDIOutput.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 class MIDIAccessPromise; | 48 class MIDIAccessPromise; |
47 | 49 |
48 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget { | 50 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget, public MIDIAccessorClient { |
49 public: | 51 public: |
50 virtual ~MIDIAccess(); | 52 virtual ~MIDIAccess(); |
51 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*, MIDIAccessProm
ise*); | 53 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*, MIDIAccessProm
ise*); |
52 | 54 |
53 MIDIInputVector inputs() const { return m_inputs; } | 55 MIDIInputVector inputs() const { return m_inputs; } |
54 MIDIOutputVector outputs() const { return m_outputs; } | 56 MIDIOutputVector outputs() const { return m_outputs; } |
55 | 57 |
56 using RefCounted<MIDIAccess>::ref; | 58 using RefCounted<MIDIAccess>::ref; |
57 using RefCounted<MIDIAccess>::deref; | 59 using RefCounted<MIDIAccess>::deref; |
58 | 60 |
59 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
60 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 62 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
61 | 63 |
62 // EventTarget | 64 // EventTarget |
63 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } | 65 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } |
64 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } | 66 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } |
65 | 67 |
66 // ActiveDOMObject | 68 // ActiveDOMObject |
67 virtual bool canSuspend() const OVERRIDE { return true; } | 69 virtual bool canSuspend() const OVERRIDE { return true; } |
68 | 70 |
| 71 // MIDIAccessorClient |
| 72 virtual void didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) OVERRIDE; |
| 73 virtual void didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) OVERRIDE; |
| 74 virtual void didAllowAccess() OVERRIDE; |
| 75 virtual void didBlockAccess() OVERRIDE; |
| 76 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; |
| 77 |
69 private: | 78 private: |
70 explicit MIDIAccess(ScriptExecutionContext*, MIDIAccessPromise*); | 79 explicit MIDIAccess(ScriptExecutionContext*, MIDIAccessPromise*); |
71 | 80 |
72 // EventTarget | 81 // EventTarget |
73 virtual void refEventTarget() OVERRIDE { ref(); } | 82 virtual void refEventTarget() OVERRIDE { ref(); } |
74 virtual void derefEventTarget() OVERRIDE { deref(); } | 83 virtual void derefEventTarget() OVERRIDE { deref(); } |
75 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } | 84 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } |
76 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } | 85 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } |
77 | 86 |
78 MIDIInputVector m_inputs; | 87 MIDIInputVector m_inputs; |
79 MIDIOutputVector m_outputs; | 88 MIDIOutputVector m_outputs; |
80 EventTargetData m_eventTargetData; | 89 EventTargetData m_eventTargetData; |
81 MIDIAccessPromise* m_promise; | 90 MIDIAccessPromise* m_promise; |
| 91 |
| 92 OwnPtr<MIDIAccessor> m_accessor; |
| 93 bool m_hasAccess; |
82 }; | 94 }; |
83 | 95 |
84 } // namespace WebCore | 96 } // namespace WebCore |
85 | 97 |
86 #endif // MIDIAccess_h | 98 #endif // MIDIAccess_h |
OLD | NEW |