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 MIDIPort_h | 31 #ifndef MIDIPort_h |
32 #define MIDIPort_h | 32 #define MIDIPort_h |
33 | 33 |
| 34 #include "bindings/core/v8/ScriptPromise.h" |
34 #include "modules/EventTargetModules.h" | 35 #include "modules/EventTargetModules.h" |
| 36 #include "modules/webmidi/MIDIAccessor.h" |
35 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
36 | 38 |
37 namespace blink { | 39 namespace blink { |
38 | 40 |
39 class MIDIAccess; | 41 class MIDIAccess; |
40 | 42 |
41 class MIDIPort : public RefCountedGarbageCollectedEventTargetWithInlineData<MIDI
Port> { | 43 class MIDIPort : public RefCountedGarbageCollectedEventTargetWithInlineData<MIDI
Port> { |
42 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<M
IDIPort>); | 44 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<M
IDIPort>); |
43 DEFINE_WRAPPERTYPEINFO(); | 45 DEFINE_WRAPPERTYPEINFO(); |
44 public: | 46 public: |
45 enum MIDIPortTypeCode { | 47 enum MIDIPortTypeCode { |
46 MIDIPortTypeInput, | 48 MIDIPortTypeInput, |
47 MIDIPortTypeOutput | 49 MIDIPortTypeOutput |
48 }; | 50 }; |
49 | 51 |
50 virtual ~MIDIPort() { } | 52 virtual ~MIDIPort() { } |
51 | 53 |
52 String id() const { return m_id; } | 54 String id() const { return m_id; } |
53 String manufacturer() const { return m_manufacturer; } | 55 String manufacturer() const { return m_manufacturer; } |
54 String name() const { return m_name; } | 56 String name() const { return m_name; } |
55 String state() const; | 57 String state() const; |
56 String type() const; | 58 String type() const; |
57 String version() const { return m_version; } | 59 String version() const { return m_version; } |
58 | 60 |
| 61 ScriptPromise open(ScriptState*); |
| 62 ScriptPromise close(ScriptState*); |
| 63 |
59 MIDIAccess* midiAccess() const { return m_access; } | 64 MIDIAccess* midiAccess() const { return m_access; } |
60 bool isActive() const { return m_isActive; } | 65 MIDIAccessor::MIDIPortState getState() const { return m_state; } |
61 void setActiveState(bool isActive); | 66 void setState(MIDIAccessor::MIDIPortState); |
62 | 67 |
63 DECLARE_VIRTUAL_TRACE(); | 68 DECLARE_VIRTUAL_TRACE(); |
64 | 69 |
65 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 70 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
66 | 71 |
67 // EventTarget | 72 // EventTarget |
68 virtual const AtomicString& interfaceName() const override { return EventTar
getNames::MIDIPort; } | 73 virtual const AtomicString& interfaceName() const override { return EventTar
getNames::MIDIPort; } |
69 virtual ExecutionContext* executionContext() const override final; | 74 virtual ExecutionContext* executionContext() const override final; |
70 | 75 |
71 protected: | 76 protected: |
72 MIDIPort(MIDIAccess*, const String& id, const String& manufacturer, const St
ring& name, MIDIPortTypeCode, const String& version, bool isActive); | 77 MIDIPort(MIDIAccess*, const String& id, const String& manufacturer, const St
ring& name, MIDIPortTypeCode, const String& version, MIDIAccessor::MIDIPortState
); |
73 | 78 |
74 private: | 79 private: |
| 80 ScriptPromise accept(ScriptState*); |
| 81 ScriptPromise reject(ScriptState*, const String& name, const String& message
); |
| 82 |
75 String m_id; | 83 String m_id; |
76 String m_manufacturer; | 84 String m_manufacturer; |
77 String m_name; | 85 String m_name; |
78 MIDIPortTypeCode m_type; | 86 MIDIPortTypeCode m_type; |
79 String m_version; | 87 String m_version; |
80 Member<MIDIAccess> m_access; | 88 Member<MIDIAccess> m_access; |
81 bool m_isActive; | 89 MIDIAccessor::MIDIPortState m_state; |
82 }; | 90 }; |
83 | 91 |
84 } // namespace blink | 92 } // namespace blink |
85 | 93 |
86 #endif // MIDIPort_h | 94 #endif // MIDIPort_h |
OLD | NEW |