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 22 matching lines...) Expand all Loading... |
33 #include "bindings/core/v8/ScriptPromise.h" | 33 #include "bindings/core/v8/ScriptPromise.h" |
34 #include "core/dom/DOMException.h" | 34 #include "core/dom/DOMException.h" |
35 #include "modules/webmidi/MIDIAccess.h" | 35 #include "modules/webmidi/MIDIAccess.h" |
36 #include "modules/webmidi/MIDIConnectionEvent.h" | 36 #include "modules/webmidi/MIDIConnectionEvent.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 using PortState = MIDIAccessor::MIDIPortState; | 40 using PortState = MIDIAccessor::MIDIPortState; |
41 | 41 |
42 MIDIPort::MIDIPort(MIDIAccess* access, const String& id, const String& manufactu
rer, const String& name, TypeCode type, const String& version, PortState state) | 42 MIDIPort::MIDIPort(MIDIAccess* access, const String& id, const String& manufactu
rer, const String& name, TypeCode type, const String& version, PortState state) |
43 : ActiveDOMObject(access->executionContext()) | 43 : ActiveDOMObject(access->getExecutionContext()) |
44 , m_id(id) | 44 , m_id(id) |
45 , m_manufacturer(manufacturer) | 45 , m_manufacturer(manufacturer) |
46 , m_name(name) | 46 , m_name(name) |
47 , m_type(type) | 47 , m_type(type) |
48 , m_version(version) | 48 , m_version(version) |
49 , m_access(access) | 49 , m_access(access) |
50 , m_connection(ConnectionStateClosed) | 50 , m_connection(ConnectionStateClosed) |
51 { | 51 { |
52 ASSERT(access); | 52 ASSERT(access); |
53 ASSERT(type == TypeInput || type == TypeOutput); | 53 ASSERT(type == TypeInput || type == TypeOutput); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 open(); | 134 open(); |
135 break; | 135 break; |
136 case ConnectionStateClosed: | 136 case ConnectionStateClosed: |
137 setStates(PortState::MIDIPortStateConnected, ConnectionStateClosed); | 137 setStates(PortState::MIDIPortStateConnected, ConnectionStateClosed); |
138 break; | 138 break; |
139 } | 139 } |
140 break; | 140 break; |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 ExecutionContext* MIDIPort::executionContext() const | 144 ExecutionContext* MIDIPort::getExecutionContext() const |
145 { | 145 { |
146 return m_access->executionContext(); | 146 return m_access->getExecutionContext(); |
147 } | 147 } |
148 | 148 |
149 bool MIDIPort::hasPendingActivity() const | 149 bool MIDIPort::hasPendingActivity() const |
150 { | 150 { |
151 // MIDIPort should survive if ConnectionState is "open" or can be "open" via | 151 // MIDIPort should survive if ConnectionState is "open" or can be "open" via |
152 // a MIDIConnectionEvent even if there are no references from JavaScript. | 152 // a MIDIConnectionEvent even if there are no references from JavaScript. |
153 return m_connection != ConnectionStateClosed; | 153 return m_connection != ConnectionStateClosed; |
154 } | 154 } |
155 | 155 |
156 void MIDIPort::stop() | 156 void MIDIPort::stop() |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 ASSERT(state != PortState::MIDIPortStateDisconnected || connection != Connec
tionStateOpen); | 195 ASSERT(state != PortState::MIDIPortStateDisconnected || connection != Connec
tionStateOpen); |
196 if (m_state == state && m_connection == connection) | 196 if (m_state == state && m_connection == connection) |
197 return; | 197 return; |
198 m_state = state; | 198 m_state = state; |
199 m_connection = connection; | 199 m_connection = connection; |
200 dispatchEvent(MIDIConnectionEvent::create(this)); | 200 dispatchEvent(MIDIConnectionEvent::create(this)); |
201 m_access->dispatchEvent(MIDIConnectionEvent::create(this)); | 201 m_access->dispatchEvent(MIDIConnectionEvent::create(this)); |
202 } | 202 } |
203 | 203 |
204 } // namespace blink | 204 } // namespace blink |
OLD | NEW |