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

Side by Side Diff: content/browser/renderer_host/media/midi_host.cc

Issue 23983004: Web MIDI: implement right sysex handling for received messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/midi_host.h" 5 #include "content/browser/renderer_host/media/midi_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 sent_bytes_in_flight_ += data.size(); 129 sent_bytes_in_flight_ += data.size();
130 } 130 }
131 131
132 void MIDIHost::ReceiveMIDIData( 132 void MIDIHost::ReceiveMIDIData(
133 uint32 port, 133 uint32 port,
134 const uint8* data, 134 const uint8* data,
135 size_t length, 135 size_t length,
136 double timestamp) { 136 double timestamp) {
137 TRACE_EVENT0("midi", "MIDIHost::ReceiveMIDIData"); 137 TRACE_EVENT0("midi", "MIDIHost::ReceiveMIDIData");
138 138
139 // For now disallow all System Exclusive messages even if we 139 // Check a process security policy to receive a system exclusive message.
140 // have permission. 140 if (length > 0 && data[0] >= kSysExMessage) {
141 // TODO(toyoshim): allow System Exclusive if browser has granted 141 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanSendMIDISysExMessage(
142 // this client access. We'll likely need to pass a GURL 142 renderer_process_id_)) {
143 // here to compare against our permissions. 143 // MIDI devices may send a system exclusive messages even if the renderer
144 if (length > 0 && data[0] >= kSysExMessage) 144 // doesn't have a permission to receive it. Don't kill the renderer as
145 // OnSendData() does.
145 return; 146 return;
147 }
148 }
146 149
147 // Send to the renderer. 150 // Send to the renderer.
148 std::vector<uint8> v(data, data + length); 151 std::vector<uint8> v(data, data + length);
149 Send(new MIDIMsg_DataReceived(port, v, timestamp)); 152 Send(new MIDIMsg_DataReceived(port, v, timestamp));
150 } 153 }
151 154
152 void MIDIHost::AccumulateMIDIBytesSent(size_t n) { 155 void MIDIHost::AccumulateMIDIBytesSent(size_t n) {
153 { 156 {
154 base::AutoLock auto_lock(in_flight_lock_); 157 base::AutoLock auto_lock(in_flight_lock_);
155 if (n <= sent_bytes_in_flight_) 158 if (n <= sent_bytes_in_flight_)
156 sent_bytes_in_flight_ -= n; 159 sent_bytes_in_flight_ -= n;
157 } 160 }
158 161
159 if (bytes_sent_since_last_acknowledgement_ + n >= 162 if (bytes_sent_since_last_acknowledgement_ + n >=
160 bytes_sent_since_last_acknowledgement_) 163 bytes_sent_since_last_acknowledgement_)
161 bytes_sent_since_last_acknowledgement_ += n; 164 bytes_sent_since_last_acknowledgement_ += n;
162 165
163 if (bytes_sent_since_last_acknowledgement_ >= 166 if (bytes_sent_since_last_acknowledgement_ >=
164 kAcknowledgementThresholdBytes) { 167 kAcknowledgementThresholdBytes) {
165 Send(new MIDIMsg_AcknowledgeSentData( 168 Send(new MIDIMsg_AcknowledgeSentData(
166 bytes_sent_since_last_acknowledgement_)); 169 bytes_sent_since_last_acknowledgement_));
167 bytes_sent_since_last_acknowledgement_ = 0; 170 bytes_sent_since_last_acknowledgement_ = 0;
168 } 171 }
169 } 172 }
170 173
171 } // namespace content 174 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698