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

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: 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/MIDIInput.h ('k') | Source/modules/webmidi/MIDIOutput.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIInput.cpp
diff --git a/Source/modules/webmidi/MIDIInput.cpp b/Source/modules/webmidi/MIDIInput.cpp
index 45da45e39b8ac4e5cc3e3584de1e75edfc0726e7..68317d04edce5c95dd3e6759c775d5b592c5884e 100644
--- a/Source/modules/webmidi/MIDIInput.cpp
+++ b/Source/modules/webmidi/MIDIInput.cpp
@@ -50,6 +50,20 @@ 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.
+ // See http://www.w3.org/TR/webmidi/#widl-MIDIPort-open-Promise-MIDIPort
+ open();
+
+ setAttributeEventListener(EventTypeNames::midimessage, listener);
+}
+
void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp)
{
ASSERT(isMainThread());
@@ -57,6 +71,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.
« no previous file with comments | « Source/modules/webmidi/MIDIInput.h ('k') | Source/modules/webmidi/MIDIOutput.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698