| OLD | NEW |
| 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 <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/barrier_closure.h" | 13 #include "base/barrier_closure.h" |
| 13 #include "base/bind.h" | 14 #include "base/bind.h" |
| 14 #include "device/usb/usb_device_handle.h" | 15 #include "device/usb/usb_device_handle.h" |
| 15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 16 | 17 |
| 17 namespace device { | 18 namespace device { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 using IndexMap = std::map<uint8_t, base::string16>; | 22 using IndexMap = std::map<uint8_t, base::string16>; |
| 22 using IndexMapPtr = scoped_ptr<IndexMap>; | 23 using IndexMapPtr = std::unique_ptr<IndexMap>; |
| 23 | 24 |
| 24 // Standard USB requests and descriptor types: | 25 // Standard USB requests and descriptor types: |
| 25 const uint8_t kGetDescriptorRequest = 0x06; | 26 const uint8_t kGetDescriptorRequest = 0x06; |
| 26 const uint8_t kStringDescriptorType = 0x03; | 27 const uint8_t kStringDescriptorType = 0x03; |
| 27 | 28 |
| 28 const int kControlTransferTimeout = 60000; // 1 minute | 29 const int kControlTransferTimeout = 60000; // 1 minute |
| 29 | 30 |
| 30 struct UsbInterfaceAssociationDescriptor { | 31 struct UsbInterfaceAssociationDescriptor { |
| 31 UsbInterfaceAssociationDescriptor(uint8_t first_interface, | 32 UsbInterfaceAssociationDescriptor(uint8_t first_interface, |
| 32 uint8_t interface_count) | 33 uint8_t interface_count) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 callback.Run(std::move(index_map)); | 251 callback.Run(std::move(index_map)); |
| 251 return; | 252 return; |
| 252 } | 253 } |
| 253 | 254 |
| 254 ReadStringDescriptor(device_handle, 0, 0, | 255 ReadStringDescriptor(device_handle, 0, 0, |
| 255 base::Bind(&OnReadLanguageIds, device_handle, | 256 base::Bind(&OnReadLanguageIds, device_handle, |
| 256 base::Passed(&index_map), callback)); | 257 base::Passed(&index_map), callback)); |
| 257 } | 258 } |
| 258 | 259 |
| 259 } // namespace device | 260 } // namespace device |
| OLD | NEW |