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

Unified Diff: content/browser/renderer_host/media/midi_host.cc

Issue 107513012: [WebMIDI] Introduce UsbMidi{Input, Output}Stream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-midi-parser
Patch Set: Created 6 years, 11 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 | « no previous file | media/media.gyp » ('j') | media/midi/usb_midi_device.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/midi_host.cc
diff --git a/content/browser/renderer_host/media/midi_host.cc b/content/browser/renderer_host/media/midi_host.cc
index 2eb5ec6ff3b5fee9d17ed3c3fb31d82e2def8060..216f16c20373071483353543ed721e7b4e01cd86 100644
--- a/content/browser/renderer_host/media/midi_host.cc
+++ b/content/browser/renderer_host/media/midi_host.cc
@@ -35,9 +35,6 @@ const size_t kMaxInFlightBytes = 10 * 1024 * 1024; // 10 MB.
// how many bytes will be sent before reporting back to the renderer.
const size_t kAcknowledgementThresholdBytes = 1024 * 1024; // 1 MB.
-const uint8 kSysExMessage = 0xf0;
-const uint8 kEndOfSysExMessage = 0xf7;
-
bool IsDataByte(uint8 data) {
return (data & 0x80) == 0;
}
@@ -48,6 +45,9 @@ bool IsSystemRealTimeMessage(uint8 data) {
} // namespace
+using media::kSysExByte;
+using media::kEndOfSysExByte;
+
MIDIHost::MIDIHost(int renderer_process_id, media::MIDIManager* midi_manager)
: renderer_process_id_(renderer_process_id),
has_sys_ex_permission_(false),
@@ -119,7 +119,8 @@ void MIDIHost::OnSendData(uint32 port,
// in JavaScript. The actual permission check for security purposes
// happens here in the browser process.
if (!has_sys_ex_permission_ &&
- (std::find(data.begin(), data.end(), kSysExMessage) != data.end())) {
+ (std::find(data.begin(), data.end(), kSysExByte)
scherkus (not reviewing) 2014/01/16 21:55:52 looks like you can drop the extra ()'s around std:
yhirano 2014/01/20 09:12:19 Done.
+ != data.end())) {
RecordAction(base::UserMetricsAction("BadMessageTerminate_MIDI"));
BadMessageReceived();
return;
@@ -162,7 +163,7 @@ void MIDIHost::ReceiveMIDIData(
// MIDI devices may send a system exclusive messages even if the renderer
// doesn't have a permission to receive it. Don't kill the renderer as
// OnSendData() does.
- if (message[0] == kSysExMessage && !has_sys_ex_permission_)
+ if (message[0] == kSysExByte && !has_sys_ex_permission_)
continue;
// Send to the renderer.
@@ -204,13 +205,13 @@ bool MIDIHost::IsValidWebMIDIData(const std::vector<uint8>& data) {
continue; // Found data byte as expected.
}
if (in_sysex) {
- if (data[i] == kEndOfSysExMessage)
+ if (data[i] == kEndOfSysExByte)
in_sysex = false;
else if (!IsDataByte(current))
return false; // Error: |current| should have been data byte.
continue; // Found data byte as expected.
}
- if (current == kSysExMessage) {
+ if (current == kSysExByte) {
in_sysex = true;
continue; // Found SysEX
}
« no previous file with comments | « no previous file | media/media.gyp » ('j') | media/midi/usb_midi_device.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698