OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/devices_app/usb/device_impl.h" | 5 #include "device/devices_app/usb/device_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "device/devices_app/usb/type_converters.h" | 10 #include "device/devices_app/usb/type_converters.h" |
11 #include "device/usb/usb_descriptors.h" | |
12 #include "device/usb/usb_device.h" | 11 #include "device/usb/usb_device.h" |
13 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
14 | 13 |
15 namespace device { | 14 namespace device { |
16 namespace usb { | 15 namespace usb { |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 template <typename... Args> | 19 template <typename... Args> |
21 void CallMojoCallback(const mojo::Callback<void(Args...)>& callback, | 20 void CallMojoCallback(const mojo::Callback<void(Args...)>& callback, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if (!device_handle_) { | 115 if (!device_handle_) { |
117 callback.Run(DeviceInfoPtr()); | 116 callback.Run(DeviceInfoPtr()); |
118 return; | 117 return; |
119 } | 118 } |
120 | 119 |
121 // TODO(rockot/reillyg): Support more than just the current configuration. | 120 // TODO(rockot/reillyg): Support more than just the current configuration. |
122 // Also, converting configuration info should be done in the TypeConverter, | 121 // Also, converting configuration info should be done in the TypeConverter, |
123 // but GetConfiguration() is non-const so we do it here for now. | 122 // but GetConfiguration() is non-const so we do it here for now. |
124 DeviceInfoPtr info = DeviceInfo::From(*device_handle_->GetDevice()); | 123 DeviceInfoPtr info = DeviceInfo::From(*device_handle_->GetDevice()); |
125 const UsbConfigDescriptor* config = | 124 const UsbConfigDescriptor* config = |
126 device_handle_->GetDevice()->GetConfiguration(); | 125 device_handle_->GetDevice()->GetActiveConfiguration(); |
127 info->configurations = mojo::Array<ConfigurationInfoPtr>::New(0); | 126 info->configurations = mojo::Array<ConfigurationInfoPtr>::New(0); |
128 if (config) | 127 if (config) |
129 info->configurations.push_back(ConfigurationInfo::From(*config)); | 128 info->configurations.push_back(ConfigurationInfo::From(*config)); |
130 callback.Run(info.Pass()); | 129 callback.Run(info.Pass()); |
131 } | 130 } |
132 | 131 |
133 void DeviceImpl::SetConfiguration(uint8_t value, | 132 void DeviceImpl::SetConfiguration(uint8_t value, |
134 const SetConfigurationCallback& callback) { | 133 const SetConfigurationCallback& callback) { |
135 if (!device_handle_) { | 134 if (!device_handle_) { |
136 callback.Run(false); | 135 callback.Run(false); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 338 } |
340 device_handle_->IsochronousTransfer( | 339 device_handle_->IsochronousTransfer( |
341 USB_DIRECTION_OUTBOUND, endpoint_number, buffer, transfer_size, | 340 USB_DIRECTION_OUTBOUND, endpoint_number, buffer, transfer_size, |
342 static_cast<uint32_t>(packets.size()), packet_size, timeout, | 341 static_cast<uint32_t>(packets.size()), packet_size, timeout, |
343 base::Bind(&DeviceImpl::OnIsochronousTransferOut, | 342 base::Bind(&DeviceImpl::OnIsochronousTransferOut, |
344 weak_factory_.GetWeakPtr(), callback)); | 343 weak_factory_.GetWeakPtr(), callback)); |
345 } | 344 } |
346 | 345 |
347 } // namespace usb | 346 } // namespace usb |
348 } // namespace device | 347 } // namespace device |
OLD | NEW |