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

Unified Diff: chrome/browser/usb/usb_device.cc

Issue 10823081: Resize control transfer buffers so users don't have to. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing order bug. Created 8 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/usb/usb_device.cc
diff --git a/chrome/browser/usb/usb_device.cc b/chrome/browser/usb/usb_device.cc
index 1f97e88dcd2f7867b925fd56726f0c2164978490..d6bba6126759b6a4c38959668891cffeba249055 100644
--- a/chrome/browser/usb/usb_device.cc
+++ b/chrome/browser/usb/usb_device.cc
@@ -128,15 +128,20 @@ void UsbDevice::ControlTransfer(const TransferDirection direction,
const UsbTransferCallback& callback) {
CheckDevice();
+ scoped_refptr<net::IOBuffer> resized_buffer(new net::IOBufferWithSize(
+ LIBUSB_CONTROL_SETUP_SIZE + length));
+ memcpy(resized_buffer->data() + LIBUSB_CONTROL_SETUP_SIZE, buffer->data(),
+ length);
+
struct libusb_transfer* const transfer = libusb_alloc_transfer(0);
const uint8 converted_type = CreateRequestType(direction, request_type,
recipient);
- libusb_fill_control_setup(reinterpret_cast<uint8*>(buffer->data()),
+ libusb_fill_control_setup(reinterpret_cast<uint8*>(resized_buffer->data()),
converted_type, request, value, index, length);
libusb_fill_control_transfer(transfer, handle_, reinterpret_cast<uint8*>(
- buffer->data()), reinterpret_cast<libusb_transfer_cb_fn>(
+ resized_buffer->data()), reinterpret_cast<libusb_transfer_cb_fn>(
&HandleTransferCompletion), this, timeout);
- SubmitTransfer(transfer, buffer, callback);
+ SubmitTransfer(transfer, resized_buffer, callback);
}
void UsbDevice::BulkTransfer(const TransferDirection direction,
« 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