| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 allowed_origins.configurations); | 250 allowed_origins.configurations); |
| 251 return info; | 251 return info; |
| 252 } | 252 } |
| 253 | 253 |
| 254 // static | 254 // static |
| 255 device::usb::DeviceInfoPtr | 255 device::usb::DeviceInfoPtr |
| 256 TypeConverter<device::usb::DeviceInfoPtr, device::UsbDevice>::Convert( | 256 TypeConverter<device::usb::DeviceInfoPtr, device::UsbDevice>::Convert( |
| 257 const device::UsbDevice& device) { | 257 const device::UsbDevice& device) { |
| 258 device::usb::DeviceInfoPtr info = device::usb::DeviceInfo::New(); | 258 device::usb::DeviceInfoPtr info = device::usb::DeviceInfo::New(); |
| 259 info->guid = device.guid(); | 259 info->guid = device.guid(); |
| 260 info->usb_version_major = device.usb_version() >> 8; |
| 261 info->usb_version_minor = device.usb_version() >> 4 & 0xf; |
| 262 info->usb_version_subminor = device.usb_version() & 0xf; |
| 263 info->class_code = device.device_class(); |
| 264 info->subclass_code = device.device_subclass(); |
| 265 info->protocol_code = device.device_protocol(); |
| 260 info->vendor_id = device.vendor_id(); | 266 info->vendor_id = device.vendor_id(); |
| 261 info->product_id = device.product_id(); | 267 info->product_id = device.product_id(); |
| 268 info->device_version_major = device.device_version() >> 8; |
| 269 info->device_version_minor = device.device_version() >> 4 & 0xf; |
| 270 info->device_version_subminor = device.device_version() & 0xf; |
| 262 info->manufacturer_name = base::UTF16ToUTF8(device.manufacturer_string()); | 271 info->manufacturer_name = base::UTF16ToUTF8(device.manufacturer_string()); |
| 263 info->product_name = base::UTF16ToUTF8(device.product_string()); | 272 info->product_name = base::UTF16ToUTF8(device.product_string()); |
| 264 info->serial_number = base::UTF16ToUTF8(device.serial_number()); | 273 info->serial_number = base::UTF16ToUTF8(device.serial_number()); |
| 265 const device::UsbConfigDescriptor* config = device.GetActiveConfiguration(); | 274 const device::UsbConfigDescriptor* config = device.GetActiveConfiguration(); |
| 266 info->active_configuration = config ? config->configuration_value : 0; | 275 info->active_configuration = config ? config->configuration_value : 0; |
| 267 info->configurations = mojo::Array<device::usb::ConfigurationInfoPtr>::From( | 276 info->configurations = mojo::Array<device::usb::ConfigurationInfoPtr>::From( |
| 268 device.configurations()); | 277 device.configurations()); |
| 269 if (device.webusb_allowed_origins()) { | 278 if (device.webusb_allowed_origins()) { |
| 270 info->webusb_allowed_origins = device::usb::WebUsbDescriptorSet::From( | 279 info->webusb_allowed_origins = device::usb::WebUsbDescriptorSet::From( |
| 271 *device.webusb_allowed_origins()); | 280 *device.webusb_allowed_origins()); |
| 272 } | 281 } |
| 273 return info; | 282 return info; |
| 274 } | 283 } |
| 275 | 284 |
| 276 // static | 285 // static |
| 277 device::usb::IsochronousPacketPtr | 286 device::usb::IsochronousPacketPtr |
| 278 TypeConverter<device::usb::IsochronousPacketPtr, | 287 TypeConverter<device::usb::IsochronousPacketPtr, |
| 279 device::UsbDeviceHandle::IsochronousPacket>:: | 288 device::UsbDeviceHandle::IsochronousPacket>:: |
| 280 Convert(const device::UsbDeviceHandle::IsochronousPacket& packet) { | 289 Convert(const device::UsbDeviceHandle::IsochronousPacket& packet) { |
| 281 device::usb::IsochronousPacketPtr info = | 290 device::usb::IsochronousPacketPtr info = |
| 282 device::usb::IsochronousPacket::New(); | 291 device::usb::IsochronousPacket::New(); |
| 283 info->length = packet.length; | 292 info->length = packet.length; |
| 284 info->transferred_length = packet.transferred_length; | 293 info->transferred_length = packet.transferred_length; |
| 285 info->status = mojo::ConvertTo<device::usb::TransferStatus>(packet.status); | 294 info->status = mojo::ConvertTo<device::usb::TransferStatus>(packet.status); |
| 286 return info; | 295 return info; |
| 287 } | 296 } |
| 288 | 297 |
| 289 } // namespace mojo | 298 } // namespace mojo |
| OLD | NEW |