| 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 "third_party/mojo/src/mojo/public/cpp/bindings/array.h" | |
| 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h" | |
| 16 | |
| 17 // Type converters to convert objects between internal device/usb data types and | |
| 18 // public Mojo interface data types. | |
| 19 | |
| 20 namespace device { | |
| 21 class UsbDevice; | |
| 22 } | |
| 23 | |
| 24 namespace mojo { | |
| 25 | |
| 26 template <> | |
| 27 struct TypeConverter<device::UsbDeviceFilter, device::usb::DeviceFilterPtr> { | |
| 28 static device::UsbDeviceFilter Convert( | |
| 29 const device::usb::DeviceFilterPtr& mojo_filter); | |
| 30 }; | |
| 31 | |
| 32 template <> | |
| 33 struct TypeConverter<device::usb::TransferDirection, | |
| 34 device::UsbEndpointDirection> { | |
| 35 static device::usb::TransferDirection Convert( | |
| 36 const device::UsbEndpointDirection& direction); | |
| 37 }; | |
| 38 | |
| 39 template <> | |
| 40 struct TypeConverter<device::usb::EndpointType, device::UsbTransferType> { | |
| 41 static device::usb::EndpointType Convert(const device::UsbTransferType& type); | |
| 42 }; | |
| 43 | |
| 44 template <> | |
| 45 struct TypeConverter<device::usb::EndpointInfoPtr, | |
| 46 device::UsbEndpointDescriptor> { | |
| 47 static device::usb::EndpointInfoPtr Convert( | |
| 48 const device::UsbEndpointDescriptor& endpoint); | |
| 49 }; | |
| 50 | |
| 51 template <> | |
| 52 struct TypeConverter<device::usb::AlternateInterfaceInfoPtr, | |
| 53 device::UsbInterfaceDescriptor> { | |
| 54 static device::usb::AlternateInterfaceInfoPtr Convert( | |
| 55 const device::UsbInterfaceDescriptor& interface); | |
| 56 }; | |
| 57 | |
| 58 // Note that this is an explicit vector-to-array conversion, as | |
| 59 // UsbInterfaceDescriptor collections are flattened to contain all alternate | |
| 60 // settings, whereas InterfaceInfos contain their own sets of alternates with | |
| 61 // a different structure type. | |
| 62 template <> | |
| 63 struct TypeConverter<mojo::Array<device::usb::InterfaceInfoPtr>, | |
| 64 std::vector<device::UsbInterfaceDescriptor>> { | |
| 65 static mojo::Array<device::usb::InterfaceInfoPtr> Convert( | |
| 66 const std::vector<device::UsbInterfaceDescriptor>& interfaces); | |
| 67 }; | |
| 68 | |
| 69 template <> | |
| 70 struct TypeConverter<device::usb::ConfigurationInfoPtr, | |
| 71 device::UsbConfigDescriptor> { | |
| 72 static device::usb::ConfigurationInfoPtr Convert( | |
| 73 const device::UsbConfigDescriptor& config); | |
| 74 }; | |
| 75 | |
| 76 template <> | |
| 77 struct TypeConverter<device::usb::DeviceInfoPtr, device::UsbDevice> { | |
| 78 static device::usb::DeviceInfoPtr Convert(const device::UsbDevice& device); | |
| 79 }; | |
| 80 | |
| 81 } // namespace mojo | |
| 82 | |
| 83 #endif // DEVICE_USB_TYPE_CONVERTERS_H_ | |
| OLD | NEW |