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 13 matching lines...) Expand all Loading... |
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 MIDIAccess_h | 31 #ifndef MIDIAccess_h |
32 #define MIDIAccess_h | 32 #define MIDIAccess_h |
33 | 33 |
| 34 #include "bindings/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/v8/ScriptPromise.h" |
| 36 #include "bindings/v8/ScriptPromiseResolver.h" |
34 #include "bindings/v8/ScriptWrappable.h" | 37 #include "bindings/v8/ScriptWrappable.h" |
35 #include "core/dom/ActiveDOMObject.h" | 38 #include "core/dom/ActiveDOMObject.h" |
36 #include "core/events/EventTarget.h" | 39 #include "core/events/EventTarget.h" |
37 #include "heap/Handle.h" | 40 #include "heap/Handle.h" |
38 #include "modules/webmidi/MIDIAccessor.h" | 41 #include "modules/webmidi/MIDIAccessor.h" |
39 #include "modules/webmidi/MIDIAccessorClient.h" | 42 #include "modules/webmidi/MIDIAccessorClient.h" |
40 #include "modules/webmidi/MIDIInput.h" | 43 #include "modules/webmidi/MIDIInput.h" |
| 44 #include "modules/webmidi/MIDIOptions.h" |
41 #include "modules/webmidi/MIDIOutput.h" | 45 #include "modules/webmidi/MIDIOutput.h" |
42 #include "wtf/RefCounted.h" | 46 #include "wtf/RefCounted.h" |
43 #include "wtf/RefPtr.h" | 47 #include "wtf/RefPtr.h" |
44 #include "wtf/Vector.h" | 48 #include "wtf/Vector.h" |
45 | 49 |
46 namespace WebCore { | 50 namespace WebCore { |
47 | 51 |
48 class ExecutionContext; | 52 class ExecutionContext; |
49 class MIDIAccessPromise; | |
50 | 53 |
51 class MIDIAccess FINAL : public RefCountedWillBeRefCountedGarbageCollected<MIDIA
ccess>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithIn
lineData, public MIDIAccessorClient { | 54 class MIDIAccess FINAL : public RefCountedWillBeRefCountedGarbageCollected<MIDIA
ccess>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithIn
lineData, public MIDIAccessorClient { |
52 DECLARE_GC_INFO; | 55 DECLARE_GC_INFO; |
53 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<M
IDIAccess>); | 56 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<M
IDIAccess>); |
54 public: | 57 public: |
55 virtual ~MIDIAccess(); | 58 virtual ~MIDIAccess(); |
56 static PassRefPtrWillBeRawPtr<MIDIAccess> create(ExecutionContext*, MIDIAcce
ssPromise*); | 59 static PassRefPtrWillBeRawPtr<MIDIAccess> create(const MIDIOptions&, Executi
onContext*); |
57 | 60 |
58 MIDIInputVector inputs() const { return m_inputs; } | 61 MIDIInputVector inputs() const { return m_inputs; } |
59 MIDIOutputVector outputs() const { return m_outputs; } | 62 MIDIOutputVector outputs() const { return m_outputs; } |
60 | 63 |
61 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 64 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
62 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 65 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
63 | 66 |
64 void setSysExEnabled(bool); | 67 void setSysExEnabled(bool); |
65 bool sysExEnabled() const { return m_sysExEnabled; } | 68 bool sysExEnabled() const { return m_sysExEnabled; } |
66 | 69 |
67 // EventTarget | 70 // EventTarget |
68 virtual const AtomicString& interfaceName() const OVERRIDE { return EventTar
getNames::MIDIAccess; } | 71 virtual const AtomicString& interfaceName() const OVERRIDE { return EventTar
getNames::MIDIAccess; } |
69 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } | 72 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } |
70 | 73 |
71 // ActiveDOMObject | 74 // ActiveDOMObject |
72 virtual void stop() OVERRIDE; | 75 virtual void stop() OVERRIDE; |
73 | 76 |
74 // MIDIAccessorClient | 77 // MIDIAccessorClient |
75 virtual void didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) OVERRIDE; | 78 virtual void didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) OVERRIDE; |
76 virtual void didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) OVERRIDE; | 79 virtual void didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) OVERRIDE; |
77 virtual void didStartSession(bool success) OVERRIDE; | 80 virtual void didStartSession(bool success) OVERRIDE; |
78 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; | 81 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; |
79 | 82 |
80 // |timeStampInMilliseconds| is in the same time coordinate system as perfor
mance.now(). | 83 // |timeStampInMilliseconds| is in the same time coordinate system as perfor
mance.now(). |
81 void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t leng
th, double timeStampInMilliseconds); | 84 void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t leng
th, double timeStampInMilliseconds); |
82 | 85 |
83 void trace(Visitor*); | 86 void trace(Visitor*); |
| 87 ScriptPromise startRequest(); |
84 | 88 |
85 private: | 89 private: |
86 MIDIAccess(ExecutionContext*, MIDIAccessPromise*); | 90 MIDIAccess(const MIDIOptions&, ExecutionContext*); |
87 | 91 |
88 void startRequest(); | |
89 void permissionDenied(); | 92 void permissionDenied(); |
90 | 93 |
| 94 // This method can delete |this| object. |
| 95 void resolve(); |
| 96 // This method can delete |this| object. |
| 97 void reject(PassRefPtr<DOMError>); |
| 98 |
91 MIDIInputVector m_inputs; | 99 MIDIInputVector m_inputs; |
92 MIDIOutputVector m_outputs; | 100 MIDIOutputVector m_outputs; |
93 RawPtrWillBeMember<MIDIAccessPromise> m_promise; | |
94 | 101 |
95 OwnPtr<MIDIAccessor> m_accessor; | 102 OwnPtr<MIDIAccessor> m_accessor; |
| 103 RefPtr<DOMWrapperWorld> m_world; |
| 104 RefPtr<ScriptPromiseResolver> m_resolver; |
| 105 MIDIOptions m_options; |
96 bool m_hasAccess; | 106 bool m_hasAccess; |
97 bool m_sysExEnabled; | 107 bool m_sysExEnabled; |
98 bool m_requesting; | 108 bool m_requesting; |
99 }; | 109 }; |
100 | 110 |
101 } // namespace WebCore | 111 } // namespace WebCore |
102 | 112 |
103 #endif // MIDIAccess_h | 113 #endif // MIDIAccess_h |
OLD | NEW |