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

Unified Diff: Source/modules/webmidi/MIDIInput.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: setonmidi..., public 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
Index: Source/modules/webmidi/MIDIInput.cpp
diff --git a/Source/modules/webmidi/MIDIInput.cpp b/Source/modules/webmidi/MIDIInput.cpp
index 45da45e39b8ac4e5cc3e3584de1e75edfc0726e7..41d17cf3aa706e00ae7f47b27e92c5ba7cbfcaf0 100644
--- a/Source/modules/webmidi/MIDIInput.cpp
+++ b/Source/modules/webmidi/MIDIInput.cpp
@@ -50,6 +50,19 @@ MIDIInput::MIDIInput(MIDIAccess* access, const String& id, const String& manufac
{
}
+EventListener* MIDIInput::onmidimessage()
+{
+ return getAttributeEventListener(EventTypeNames::midimessage);
+}
+
+void MIDIInput::setOnmidimessage(PassRefPtr<EventListener> listener)
+{
+ // Implicit open. It does nothing if the port is already opened.
kouhei (in TOK) 2015/04/02 05:10:52 Please add a link to the spec for "spec" behaviour
Takashi Toyoshima 2015/04/02 05:25:41 Done.
+ open();
+
+ setAttributeEventListener(EventTypeNames::midimessage, listener);
+}
+
void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp)
{
ASSERT(isMainThread());
@@ -57,6 +70,9 @@ void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data
if (!length)
return;
+ if (getConnection() != ConnectionStateOpen)
+ return;
+
// Drop sysex message here when the client does not request it. Note that this is not a security check but an
// automatic filtering for clients that do not want sysex message. Also note that sysex message will never be sent
// unless the current process has an explicit permission to handle sysex message.

Powered by Google App Engine
This is Rietveld 408576698