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

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()) {
Takashi Toyoshima 2015/02/09 06:34:41 Can you add TODO(toyoshim) here? I think we should
yhirano 2015/02/09 08:41:12 Done.
47 // |port_index| is provided by a renderer so we can't believe that it is
48 // in the valid range.
49 return;
50 }
47 output_streams_[port_index]->Send(data); 51 output_streams_[port_index]->Send(data);
48 client->AccumulateMidiBytesSent(data.size()); 52 client->AccumulateMidiBytesSent(data.size());
49 } 53 }
50 54
51 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, 55 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device,
52 int endpoint_number, 56 int endpoint_number,
53 const uint8* data, 57 const uint8* data,
54 size_t size, 58 size_t size,
55 base::TimeTicks time) { 59 base::TimeTicks time) {
56 if (!input_stream_) 60 if (!input_stream_)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 static_cast<long>(j)); 118 static_cast<long>(j));
115 AddInputPort(port); 119 AddInputPort(port);
116 } 120 }
117 } 121 }
118 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); 122 input_stream_.reset(new UsbMidiInputStream(input_jacks, this));
119 } 123 }
120 initialize_callback_.Run(MIDI_OK); 124 initialize_callback_.Run(MIDI_OK);
121 } 125 }
122 126
123 } // namespace media 127 } // 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