| 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/usb/mojo/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> |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 info->interface_number = interfaces[i].interface_number; | 188 info->interface_number = interfaces[i].interface_number; |
| 189 info->first_interface = interfaces[i].first_interface; |
| 189 iter = interface_map | 190 iter = interface_map |
| 190 .insert( | 191 .insert( |
| 191 std::make_pair(interfaces[i].interface_number, info.get())) | 192 std::make_pair(interfaces[i].interface_number, info.get())) |
| 192 .first; | 193 .first; |
| 193 infos.push_back(std::move(info)); | 194 infos.push_back(std::move(info)); |
| 194 } | 195 } |
| 195 iter->second->alternates.push_back(std::move(alternate)); | 196 iter->second->alternates.push_back(std::move(alternate)); |
| 196 } | 197 } |
| 197 | 198 |
| 198 return infos; | 199 return infos; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 Convert(const device::UsbDeviceHandle::IsochronousPacket& packet) { | 280 Convert(const device::UsbDeviceHandle::IsochronousPacket& packet) { |
| 280 device::usb::IsochronousPacketPtr info = | 281 device::usb::IsochronousPacketPtr info = |
| 281 device::usb::IsochronousPacket::New(); | 282 device::usb::IsochronousPacket::New(); |
| 282 info->length = packet.length; | 283 info->length = packet.length; |
| 283 info->transferred_length = packet.transferred_length; | 284 info->transferred_length = packet.transferred_length; |
| 284 info->status = mojo::ConvertTo<device::usb::TransferStatus>(packet.status); | 285 info->status = mojo::ConvertTo<device::usb::TransferStatus>(packet.status); |
| 285 return info; | 286 return info; |
| 286 } | 287 } |
| 287 | 288 |
| 288 } // namespace mojo | 289 } // namespace mojo |
| OLD | NEW |