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 #ifndef DEVICE_USB_MOJO_TYPE_CONVERTERS_H_ | 5 #ifndef DEVICE_USB_MOJO_TYPE_CONVERTERS_H_ |
6 #define DEVICE_USB_MOJO_TYPE_CONVERTERS_H_ | 6 #define DEVICE_USB_MOJO_TYPE_CONVERTERS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "device/usb/public/interfaces/device.mojom.h" | 10 #include "device/usb/public/interfaces/device.mojom.h" |
11 #include "device/usb/public/interfaces/device_manager.mojom.h" | 11 #include "device/usb/public/interfaces/device_manager.mojom.h" |
12 #include "device/usb/usb_descriptors.h" | 12 #include "device/usb/usb_descriptors.h" |
13 #include "device/usb/usb_device_filter.h" | 13 #include "device/usb/usb_device_filter.h" |
14 #include "device/usb/usb_device_handle.h" | 14 #include "device/usb/usb_device_handle.h" |
15 #include "mojo/public/cpp/bindings/type_converter.h" | 15 #include "mojo/public/cpp/bindings/type_converter.h" |
16 | 16 |
17 // Type converters to translate between internal device/usb data types and | 17 // Type converters to translate between internal device/usb data types and |
18 // public Mojo interface data types. This must be included by any source file | 18 // public Mojo interface data types. This must be included by any source file |
19 // that uses these conversions explicitly or implicitly. | 19 // that uses these conversions explicitly or implicitly. |
20 | 20 |
21 namespace device { | 21 namespace device { |
22 class UsbDevice; | 22 class UsbDevice; |
23 } | 23 } |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 | 26 |
27 template <> | 27 template <> |
28 struct TypeConverter<device::mojom::UsbTransferDirection, | |
29 device::UsbEndpointDirection> { | |
30 static device::mojom::UsbTransferDirection Convert( | |
31 const device::UsbEndpointDirection& direction); | |
32 }; | |
33 | |
34 template <> | |
35 struct TypeConverter<device::mojom::UsbTransferStatus, | |
36 device::UsbTransferStatus> { | |
37 static device::mojom::UsbTransferStatus Convert( | |
38 const device::UsbTransferStatus& status); | |
39 }; | |
40 | |
41 template <> | |
42 struct TypeConverter<device::UsbDeviceHandle::TransferRequestType, | |
43 device::mojom::UsbControlTransferType> { | |
44 static device::UsbDeviceHandle::TransferRequestType Convert( | |
45 const device::mojom::UsbControlTransferType& type); | |
46 }; | |
47 | |
48 template <> | |
49 struct TypeConverter<device::UsbDeviceHandle::TransferRecipient, | |
50 device::mojom::UsbControlTransferRecipient> { | |
51 static device::UsbDeviceHandle::TransferRecipient Convert( | |
52 const device::mojom::UsbControlTransferRecipient& recipient); | |
53 }; | |
54 | |
55 template <> | |
56 struct TypeConverter<device::mojom::UsbEndpointType, device::UsbTransferType> { | |
57 static device::mojom::UsbEndpointType Convert( | |
58 const device::UsbTransferType& type); | |
59 }; | |
60 | |
61 template <> | |
62 struct TypeConverter<device::mojom::UsbEndpointInfoPtr, | 28 struct TypeConverter<device::mojom::UsbEndpointInfoPtr, |
63 device::UsbEndpointDescriptor> { | 29 device::UsbEndpointDescriptor> { |
64 static device::mojom::UsbEndpointInfoPtr Convert( | 30 static device::mojom::UsbEndpointInfoPtr Convert( |
65 const device::UsbEndpointDescriptor& endpoint); | 31 const device::UsbEndpointDescriptor& endpoint); |
66 }; | 32 }; |
67 | 33 |
68 template <> | 34 template <> |
69 struct TypeConverter<device::mojom::UsbAlternateInterfaceInfoPtr, | 35 struct TypeConverter<device::mojom::UsbAlternateInterfaceInfoPtr, |
70 device::UsbInterfaceDescriptor> { | 36 device::UsbInterfaceDescriptor> { |
71 static device::mojom::UsbAlternateInterfaceInfoPtr Convert( | 37 static device::mojom::UsbAlternateInterfaceInfoPtr Convert( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 result.reserve(input.size()); | 76 result.reserve(input.size()); |
111 for (const B& item : input) | 77 for (const B& item : input) |
112 result.push_back(mojo::ConvertTo<A>(item)); | 78 result.push_back(mojo::ConvertTo<A>(item)); |
113 return result; | 79 return result; |
114 }; | 80 }; |
115 }; | 81 }; |
116 | 82 |
117 } // namespace mojo | 83 } // namespace mojo |
118 | 84 |
119 #endif // DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_ | 85 #endif // DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_ |
OLD | NEW |