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

Side by Side Diff: media/midi/midi_manager_usb.cc

Issue 907793002: MidiManagerUsb should not trust indices provided by renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | media/midi/midi_manager_usb_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/midi/midi_manager_usb.h" 5 #include "media/midi/midi_manager_usb.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 25 matching lines...) Expand all
36 device_factory_->EnumerateDevices( 36 device_factory_->EnumerateDevices(
37 this, 37 this,
38 base::Bind(&MidiManagerUsb::OnEnumerateDevicesDone, 38 base::Bind(&MidiManagerUsb::OnEnumerateDevicesDone,
39 base::Unretained(this))); 39 base::Unretained(this)));
40 } 40 }
41 41
42 void MidiManagerUsb::DispatchSendMidiData(MidiManagerClient* client, 42 void MidiManagerUsb::DispatchSendMidiData(MidiManagerClient* client,
43 uint32_t port_index, 43 uint32_t port_index,
44 const std::vector<uint8>& data, 44 const std::vector<uint8>& data,
45 double timestamp) { 45 double timestamp) {
46 DCHECK_LT(port_index, output_streams_.size()); 46 if (port_index >= output_streams_.size()) {
47 // |port_index| is provided by a renderer so we can't believe that it is
48 // in the valid range.
49 // TODO(toyoshim): Move this check to MidiHost and kill the renderer when
50 // it fails.
51 return;
52 }
47 output_streams_[port_index]->Send(data); 53 output_streams_[port_index]->Send(data);
48 client->AccumulateMidiBytesSent(data.size()); 54 client->AccumulateMidiBytesSent(data.size());
49 } 55 }
50 56
51 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, 57 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device,
52 int endpoint_number, 58 int endpoint_number,
53 const uint8* data, 59 const uint8* data,
54 size_t size, 60 size_t size,
55 base::TimeTicks time) { 61 base::TimeTicks time) {
56 if (!input_stream_) 62 if (!input_stream_)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 static_cast<long>(j)); 120 static_cast<long>(j));
115 AddInputPort(port); 121 AddInputPort(port);
116 } 122 }
117 } 123 }
118 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); 124 input_stream_.reset(new UsbMidiInputStream(input_jacks, this));
119 } 125 }
120 initialize_callback_.Run(MIDI_OK); 126 initialize_callback_.Run(MIDI_OK);
121 } 127 }
122 128
123 } // namespace media 129 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/midi/midi_manager_usb_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698