| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_USB_TYPE_CONVERTERS_H_ | |
| 6 #define DEVICE_USB_TYPE_CONVERTERS_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "device/usb/public/interfaces/device.mojom.h" | |
| 11 #include "device/usb/public/interfaces/device_manager.mojom.h" | |
| 12 #include "device/usb/usb_descriptors.h" | |
| 13 #include "device/usb/usb_device_filter.h" | |
| 14 #include "device/usb/usb_device_handle.h" | |
| 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" | |
| 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h" | |
| 17 | |
| 18 // Type converters to convert objects between internal device/usb data types and | |
| 19 // public Mojo interface data types. | |
| 20 | |
| 21 namespace device { | |
| 22 class UsbDevice; | |
| 23 } | |
| 24 | |
| 25 namespace mojo { | |
| 26 | |
| 27 template <> | |
| 28 struct TypeConverter<device::UsbDeviceFilter, device::usb::DeviceFilterPtr> { | |
| 29 static device::UsbDeviceFilter Convert( | |
| 30 const device::usb::DeviceFilterPtr& mojo_filter); | |
| 31 }; | |
| 32 | |
| 33 template <> | |
| 34 struct TypeConverter<device::usb::TransferDirection, | |
| 35 device::UsbEndpointDirection> { | |
| 36 static device::usb::TransferDirection Convert( | |
| 37 const device::UsbEndpointDirection& direction); | |
| 38 }; | |
| 39 | |
| 40 template <> | |
| 41 struct TypeConverter<device::usb::TransferStatus, device::UsbTransferStatus> { | |
| 42 static device::usb::TransferStatus Convert( | |
| 43 const device::UsbTransferStatus& status); | |
| 44 }; | |
| 45 | |
| 46 template <> | |
| 47 struct TypeConverter<device::UsbDeviceHandle::TransferRequestType, | |
| 48 device::usb::ControlTransferType> { | |
| 49 static device::UsbDeviceHandle::TransferRequestType Convert( | |
| 50 const device::usb::ControlTransferType& type); | |
| 51 }; | |
| 52 | |
| 53 template <> | |
| 54 struct TypeConverter<device::UsbDeviceHandle::TransferRecipient, | |
| 55 device::usb::ControlTransferRecipient> { | |
| 56 static device::UsbDeviceHandle::TransferRecipient Convert( | |
| 57 const device::usb::ControlTransferRecipient& recipient); | |
| 58 }; | |
| 59 | |
| 60 template <> | |
| 61 struct TypeConverter<device::usb::EndpointType, device::UsbTransferType> { | |
| 62 static device::usb::EndpointType Convert(const device::UsbTransferType& type); | |
| 63 }; | |
| 64 | |
| 65 template <> | |
| 66 struct TypeConverter<device::usb::EndpointInfoPtr, | |
| 67 device::UsbEndpointDescriptor> { | |
| 68 static device::usb::EndpointInfoPtr Convert( | |
| 69 const device::UsbEndpointDescriptor& endpoint); | |
| 70 }; | |
| 71 | |
| 72 template <> | |
| 73 struct TypeConverter<device::usb::AlternateInterfaceInfoPtr, | |
| 74 device::UsbInterfaceDescriptor> { | |
| 75 static device::usb::AlternateInterfaceInfoPtr Convert( | |
| 76 const device::UsbInterfaceDescriptor& interface); | |
| 77 }; | |
| 78 | |
| 79 // Note that this is an explicit vector-to-array conversion, as | |
| 80 // UsbInterfaceDescriptor collections are flattened to contain all alternate | |
| 81 // settings, whereas InterfaceInfos contain their own sets of alternates with | |
| 82 // a different structure type. | |
| 83 template <> | |
| 84 struct TypeConverter<mojo::Array<device::usb::InterfaceInfoPtr>, | |
| 85 std::vector<device::UsbInterfaceDescriptor>> { | |
| 86 static mojo::Array<device::usb::InterfaceInfoPtr> Convert( | |
| 87 const std::vector<device::UsbInterfaceDescriptor>& interfaces); | |
| 88 }; | |
| 89 | |
| 90 template <> | |
| 91 struct TypeConverter<device::usb::ConfigurationInfoPtr, | |
| 92 device::UsbConfigDescriptor> { | |
| 93 static device::usb::ConfigurationInfoPtr Convert( | |
| 94 const device::UsbConfigDescriptor& config); | |
| 95 }; | |
| 96 | |
| 97 template <> | |
| 98 struct TypeConverter<device::usb::DeviceInfoPtr, device::UsbDevice> { | |
| 99 static device::usb::DeviceInfoPtr Convert(const device::UsbDevice& device); | |
| 100 }; | |
| 101 | |
| 102 } // namespace mojo | |
| 103 | |
| 104 #endif // DEVICE_USB_TYPE_CONVERTERS_H_ | |
| OLD | NEW |