OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/usb/usb_device.h" | 5 #include "chrome/browser/usb/usb_device.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 memcpy(resized_buffer->data() + LIBUSB_CONTROL_SETUP_SIZE, buffer->data(), | 253 memcpy(resized_buffer->data() + LIBUSB_CONTROL_SETUP_SIZE, buffer->data(), |
254 length); | 254 length); |
255 | 255 |
256 struct libusb_transfer* const transfer = libusb_alloc_transfer(0); | 256 struct libusb_transfer* const transfer = libusb_alloc_transfer(0); |
257 const uint8 converted_type = CreateRequestType(direction, request_type, | 257 const uint8 converted_type = CreateRequestType(direction, request_type, |
258 recipient); | 258 recipient); |
259 libusb_fill_control_setup(reinterpret_cast<uint8*>(resized_buffer->data()), | 259 libusb_fill_control_setup(reinterpret_cast<uint8*>(resized_buffer->data()), |
260 converted_type, request, value, index, length); | 260 converted_type, request, value, index, length); |
261 libusb_fill_control_transfer(transfer, handle_, reinterpret_cast<uint8*>( | 261 libusb_fill_control_transfer(transfer, handle_, reinterpret_cast<uint8*>( |
262 resized_buffer->data()), HandleTransferCompletion, this, timeout); | 262 resized_buffer->data()), HandleTransferCompletion, this, timeout); |
263 SubmitTransfer(transfer, USB_TRANSFER_CONTROL, resized_buffer, resized_length, | 263 SubmitTransfer(transfer, |
| 264 USB_TRANSFER_CONTROL, |
| 265 resized_buffer.get(), |
| 266 resized_length, |
264 callback); | 267 callback); |
265 } | 268 } |
266 | 269 |
267 void UsbDevice::BulkTransfer(const UsbEndpointDirection direction, | 270 void UsbDevice::BulkTransfer(const UsbEndpointDirection direction, |
268 const uint8 endpoint, net::IOBuffer* buffer, const size_t length, | 271 const uint8 endpoint, net::IOBuffer* buffer, const size_t length, |
269 const unsigned int timeout, const UsbTransferCallback& callback) { | 272 const unsigned int timeout, const UsbTransferCallback& callback) { |
270 CheckDevice(); | 273 CheckDevice(); |
271 | 274 |
272 struct libusb_transfer* const transfer = libusb_alloc_transfer(0); | 275 struct libusb_transfer* const transfer = libusb_alloc_transfer(0); |
273 const uint8 new_endpoint = ConvertTransferDirection(direction) | endpoint; | 276 const uint8 new_endpoint = ConvertTransferDirection(direction) | endpoint; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 transfer.buffer = buffer; | 332 transfer.buffer = buffer; |
330 transfer.length = length; | 333 transfer.length = length; |
331 transfer.callback = callback; | 334 transfer.callback = callback; |
332 | 335 |
333 { | 336 { |
334 base::AutoLock lock(lock_); | 337 base::AutoLock lock(lock_); |
335 transfers_[handle] = transfer; | 338 transfers_[handle] = transfer; |
336 libusb_submit_transfer(handle); | 339 libusb_submit_transfer(handle); |
337 } | 340 } |
338 } | 341 } |
OLD | NEW |