| 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/type_converters.h" | 5 #include "device/usb/mojo/type_converters.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "device/usb/usb_device.h" | 15 #include "device/usb/usb_device.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Aggregate each alternate setting into an InterfaceInfo corresponding to its | 178 // Aggregate each alternate setting into an InterfaceInfo corresponding to its |
| 179 // interface number. | 179 // interface number. |
| 180 std::map<uint8_t, device::usb::InterfaceInfo*> interface_map; | 180 std::map<uint8_t, device::usb::InterfaceInfo*> interface_map; |
| 181 for (size_t i = 0; i < interfaces.size(); ++i) { | 181 for (size_t i = 0; i < interfaces.size(); ++i) { |
| 182 auto alternate = device::usb::AlternateInterfaceInfo::From(interfaces[i]); | 182 auto alternate = device::usb::AlternateInterfaceInfo::From(interfaces[i]); |
| 183 auto iter = interface_map.find(interfaces[i].interface_number); | 183 auto iter = interface_map.find(interfaces[i].interface_number); |
| 184 if (iter == interface_map.end()) { | 184 if (iter == interface_map.end()) { |
| 185 // This is the first time we're seeing an alternate with this interface | 185 // This is the first time we're seeing an alternate with this interface |
| 186 // number, so add a new InterfaceInfo to the array and map the number. | 186 // number, so add a new InterfaceInfo to the array and map the number. |
| 187 auto info = device::usb::InterfaceInfo::New(); | 187 auto info = device::usb::InterfaceInfo::New(); |
| 188 iter = interface_map.insert(std::make_pair(interfaces[i].interface_number, | 188 iter = interface_map |
| 189 info.get())).first; | 189 .insert( |
| 190 std::make_pair(interfaces[i].interface_number, info.get())) |
| 191 .first; |
| 190 infos.push_back(std::move(info)); | 192 infos.push_back(std::move(info)); |
| 191 } | 193 } |
| 192 iter->second->alternates.push_back(std::move(alternate)); | 194 iter->second->alternates.push_back(std::move(alternate)); |
| 193 } | 195 } |
| 194 | 196 |
| 195 return infos; | 197 return infos; |
| 196 } | 198 } |
| 197 | 199 |
| 198 // static | 200 // static |
| 199 device::usb::ConfigurationInfoPtr | 201 device::usb::ConfigurationInfoPtr |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 Convert(const device::UsbDeviceHandle::IsochronousPacket& packet) { | 276 Convert(const device::UsbDeviceHandle::IsochronousPacket& packet) { |
| 275 device::usb::IsochronousPacketPtr info = | 277 device::usb::IsochronousPacketPtr info = |
| 276 device::usb::IsochronousPacket::New(); | 278 device::usb::IsochronousPacket::New(); |
| 277 info->length = packet.length; | 279 info->length = packet.length; |
| 278 info->transferred_length = packet.transferred_length; | 280 info->transferred_length = packet.transferred_length; |
| 279 info->status = mojo::ConvertTo<device::usb::TransferStatus>(packet.status); | 281 info->status = mojo::ConvertTo<device::usb::TransferStatus>(packet.status); |
| 280 return info; | 282 return info; |
| 281 } | 283 } |
| 282 | 284 |
| 283 } // namespace mojo | 285 } // namespace mojo |
| OLD | NEW |