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/ActiveScriptWrappable.h" |
34 #include "bindings/core/v8/ScriptPromise.h" | 35 #include "bindings/core/v8/ScriptPromise.h" |
35 #include "core/dom/ActiveDOMObject.h" | 36 #include "core/dom/ActiveDOMObject.h" |
36 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
37 #include "modules/EventTargetModules.h" | 38 #include "modules/EventTargetModules.h" |
38 #include "modules/webmidi/MIDIAccessor.h" | 39 #include "modules/webmidi/MIDIAccessor.h" |
39 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 class MIDIAccess; | 44 class MIDIAccess; |
44 | 45 |
45 class MIDIPort : public RefCountedGarbageCollectedEventTargetWithInlineData<MIDI
Port>, public ActiveDOMObject { | 46 class MIDIPort : public RefCountedGarbageCollectedEventTargetWithInlineData<MIDI
Port>, public ActiveScriptWrappable, public ActiveDOMObject { |
46 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MIDIPort); | 47 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MIDIPort); |
47 DEFINE_WRAPPERTYPEINFO(); | 48 DEFINE_WRAPPERTYPEINFO(); |
48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MIDIPort); | 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MIDIPort); |
49 public: | 50 public: |
50 enum ConnectionState { | 51 enum ConnectionState { |
51 ConnectionStateOpen, | 52 ConnectionStateOpen, |
52 ConnectionStateClosed, | 53 ConnectionStateClosed, |
53 ConnectionStatePending | 54 ConnectionStatePending |
54 }; | 55 }; |
55 | 56 |
(...skipping 21 matching lines...) Expand all Loading... |
77 ConnectionState getConnection() const { return m_connection; } | 78 ConnectionState getConnection() const { return m_connection; } |
78 | 79 |
79 DECLARE_VIRTUAL_TRACE(); | 80 DECLARE_VIRTUAL_TRACE(); |
80 | 81 |
81 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 82 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
82 | 83 |
83 // EventTarget | 84 // EventTarget |
84 const AtomicString& interfaceName() const override { return EventTargetNames
::MIDIPort; } | 85 const AtomicString& interfaceName() const override { return EventTargetNames
::MIDIPort; } |
85 ExecutionContext* getExecutionContext() const final; | 86 ExecutionContext* getExecutionContext() const final; |
86 | 87 |
| 88 // ActiveScriptWrappable |
| 89 bool hasPendingActivity() const final; |
| 90 |
87 // ActiveDOMObject | 91 // ActiveDOMObject |
88 bool hasPendingActivity() const override; | |
89 void stop() override; | 92 void stop() override; |
90 | 93 |
91 protected: | 94 protected: |
92 MIDIPort(MIDIAccess*, const String& id, const String& manufacturer, const St
ring& name, TypeCode, const String& version, MIDIAccessor::MIDIPortState); | 95 MIDIPort(MIDIAccess*, const String& id, const String& manufacturer, const St
ring& name, TypeCode, const String& version, MIDIAccessor::MIDIPortState); |
93 | 96 |
94 void open(); | 97 void open(); |
95 | 98 |
96 private: | 99 private: |
97 ScriptPromise accept(ScriptState*); | 100 ScriptPromise accept(ScriptState*); |
98 ScriptPromise reject(ScriptState*, ExceptionCode, const String& message); | 101 ScriptPromise reject(ScriptState*, ExceptionCode, const String& message); |
99 | 102 |
100 void setStates(MIDIAccessor::MIDIPortState, ConnectionState); | 103 void setStates(MIDIAccessor::MIDIPortState, ConnectionState); |
101 | 104 |
102 String m_id; | 105 String m_id; |
103 String m_manufacturer; | 106 String m_manufacturer; |
104 String m_name; | 107 String m_name; |
105 TypeCode m_type; | 108 TypeCode m_type; |
106 String m_version; | 109 String m_version; |
107 Member<MIDIAccess> m_access; | 110 Member<MIDIAccess> m_access; |
108 MIDIAccessor::MIDIPortState m_state; | 111 MIDIAccessor::MIDIPortState m_state; |
109 ConnectionState m_connection; | 112 ConnectionState m_connection; |
110 }; | 113 }; |
111 | 114 |
112 } // namespace blink | 115 } // namespace blink |
113 | 116 |
114 #endif // MIDIPort_h | 117 #endif // MIDIPort_h |
OLD | NEW |