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

Side by Side Diff: device/usb/usb_descriptors.cc

Issue 2689323006: Read USB device configurations from index 0. (Closed)
Patch Set: Created 3 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 | device/usb/usb_descriptors_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 "device/usb/usb_descriptors.h" 5 #include "device/usb/usb_descriptors.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 callback.Run(std::move(desc)); 142 callback.Run(std::move(desc));
143 return; 143 return;
144 } 144 }
145 145
146 uint8_t num_configurations = desc->num_configurations; 146 uint8_t num_configurations = desc->num_configurations;
147 UsbDeviceDescriptor* desc_ptr = desc.get(); 147 UsbDeviceDescriptor* desc_ptr = desc.get();
148 base::Closure closure = base::BarrierClosure( 148 base::Closure closure = base::BarrierClosure(
149 num_configurations, 149 num_configurations,
150 base::Bind(OnDoneReadingConfigDescriptors, device_handle, 150 base::Bind(OnDoneReadingConfigDescriptors, device_handle,
151 base::Passed(&desc), callback)); 151 base::Passed(&desc), callback));
152 for (uint8_t i = 1; i <= num_configurations; ++i) { 152 for (uint8_t i = 0; i < num_configurations; ++i) {
153 scoped_refptr<IOBufferWithSize> header = new IOBufferWithSize(4); 153 scoped_refptr<IOBufferWithSize> header = new IOBufferWithSize(4);
154 device_handle->ControlTransfer( 154 device_handle->ControlTransfer(
155 USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD, 155 USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD,
156 UsbDeviceHandle::DEVICE, kGetDescriptorRequest, 156 UsbDeviceHandle::DEVICE, kGetDescriptorRequest,
157 kConfigurationDescriptorType << 8 | i, 0, header, header->size(), 157 kConfigurationDescriptorType << 8 | i, 0, header, header->size(),
158 kControlTransferTimeout, 158 kControlTransferTimeout,
159 base::Bind(&OnReadConfigDescriptorHeader, device_handle, desc_ptr, i, 159 base::Bind(&OnReadConfigDescriptorHeader, device_handle, desc_ptr, i,
160 closure)); 160 closure));
161 } 161 }
162 } 162 }
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 callback.Run(std::move(index_map)); 518 callback.Run(std::move(index_map));
519 return; 519 return;
520 } 520 }
521 521
522 ReadStringDescriptor(device_handle, 0, 0, 522 ReadStringDescriptor(device_handle, 0, 0,
523 base::Bind(&OnReadLanguageIds, device_handle, 523 base::Bind(&OnReadLanguageIds, device_handle,
524 base::Passed(&index_map), callback)); 524 base::Passed(&index_map), callback));
525 } 525 }
526 526
527 } // namespace device 527 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/usb/usb_descriptors_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698