Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1838)

Unified Diff: Source/modules/webmidi/MIDIPort.cpp

Issue 1051903002: Web MIDI: implement implicit open() on send() and setOnmidimessage() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: kouhei review Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webmidi/MIDIPort.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIPort.cpp
diff --git a/Source/modules/webmidi/MIDIPort.cpp b/Source/modules/webmidi/MIDIPort.cpp
index 4664eacf578c1c8652d811e0e37333136cf0b25a..35b05b0746addefafc6a1a2752bd116b20b5fd0f 100644
--- a/Source/modules/webmidi/MIDIPort.cpp
+++ b/Source/modules/webmidi/MIDIPort.cpp
@@ -99,22 +99,7 @@ String MIDIPort::type() const
ScriptPromise MIDIPort::open(ScriptState* scriptState)
{
- if (m_connection == ConnectionStateClosed) {
- switch (m_state) {
- case PortState::MIDIPortStateDisconnected:
- setStates(m_state, ConnectionStatePending);
- break;
- case PortState::MIDIPortStateConnected:
- // TODO(toyoshim): Add blink API to perform a real open and close
- // operation.
- setStates(m_state, ConnectionStateOpen);
- break;
- case PortState::MIDIPortStateOpened:
- // TODO(toyoshim): Remove PortState::MIDIPortStateOpened.
- ASSERT_NOT_REACHED();
- break;
- }
- }
+ open();
return accept(scriptState);
}
@@ -144,6 +129,26 @@ DEFINE_TRACE(MIDIPort)
RefCountedGarbageCollectedEventTargetWithInlineData<MIDIPort>::trace(visitor);
}
+void MIDIPort::open()
+{
+ if (m_connection == ConnectionStateClosed) {
+ switch (m_state) {
+ case PortState::MIDIPortStateDisconnected:
+ setStates(m_state, ConnectionStatePending);
+ break;
+ case PortState::MIDIPortStateConnected:
+ // TODO(toyoshim): Add blink API to perform a real open and close
+ // operation.
+ setStates(m_state, ConnectionStateOpen);
+ break;
+ case PortState::MIDIPortStateOpened:
+ // TODO(toyoshim): Remove PortState::MIDIPortStateOpened.
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+}
+
ScriptPromise MIDIPort::accept(ScriptState* scriptState)
{
return ScriptPromise::cast(scriptState, toV8(this, scriptState->context()->Global(), scriptState->isolate()));
« no previous file with comments | « Source/modules/webmidi/MIDIPort.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698