Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: device/usb/mojo/type_converters.h

Issue 2821723002: Move classes in the device.usb Mojo namespace to device.mojom (Closed)
Patch Set: mcasas@ nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/mojo/device_manager_impl_unittest.cc ('k') | device/usb/mojo/type_converters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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::usb::TransferDirection, 28 struct TypeConverter<device::mojom::UsbTransferDirection,
29 device::UsbEndpointDirection> { 29 device::UsbEndpointDirection> {
30 static device::usb::TransferDirection Convert( 30 static device::mojom::UsbTransferDirection Convert(
31 const device::UsbEndpointDirection& direction); 31 const device::UsbEndpointDirection& direction);
32 }; 32 };
33 33
34 template <> 34 template <>
35 struct TypeConverter<device::usb::TransferStatus, device::UsbTransferStatus> { 35 struct TypeConverter<device::mojom::UsbTransferStatus,
36 static device::usb::TransferStatus Convert( 36 device::UsbTransferStatus> {
37 static device::mojom::UsbTransferStatus Convert(
37 const device::UsbTransferStatus& status); 38 const device::UsbTransferStatus& status);
38 }; 39 };
39 40
40 template <> 41 template <>
41 struct TypeConverter<device::UsbDeviceHandle::TransferRequestType, 42 struct TypeConverter<device::UsbDeviceHandle::TransferRequestType,
42 device::usb::ControlTransferType> { 43 device::mojom::UsbControlTransferType> {
43 static device::UsbDeviceHandle::TransferRequestType Convert( 44 static device::UsbDeviceHandle::TransferRequestType Convert(
44 const device::usb::ControlTransferType& type); 45 const device::mojom::UsbControlTransferType& type);
45 }; 46 };
46 47
47 template <> 48 template <>
48 struct TypeConverter<device::UsbDeviceHandle::TransferRecipient, 49 struct TypeConverter<device::UsbDeviceHandle::TransferRecipient,
49 device::usb::ControlTransferRecipient> { 50 device::mojom::UsbControlTransferRecipient> {
50 static device::UsbDeviceHandle::TransferRecipient Convert( 51 static device::UsbDeviceHandle::TransferRecipient Convert(
51 const device::usb::ControlTransferRecipient& recipient); 52 const device::mojom::UsbControlTransferRecipient& recipient);
52 }; 53 };
53 54
54 template <> 55 template <>
55 struct TypeConverter<device::usb::EndpointType, device::UsbTransferType> { 56 struct TypeConverter<device::mojom::UsbEndpointType, device::UsbTransferType> {
56 static device::usb::EndpointType Convert(const device::UsbTransferType& type); 57 static device::mojom::UsbEndpointType Convert(
58 const device::UsbTransferType& type);
57 }; 59 };
58 60
59 template <> 61 template <>
60 struct TypeConverter<device::usb::EndpointInfoPtr, 62 struct TypeConverter<device::mojom::UsbEndpointInfoPtr,
61 device::UsbEndpointDescriptor> { 63 device::UsbEndpointDescriptor> {
62 static device::usb::EndpointInfoPtr Convert( 64 static device::mojom::UsbEndpointInfoPtr Convert(
63 const device::UsbEndpointDescriptor& endpoint); 65 const device::UsbEndpointDescriptor& endpoint);
64 }; 66 };
65 67
66 template <> 68 template <>
67 struct TypeConverter<device::usb::AlternateInterfaceInfoPtr, 69 struct TypeConverter<device::mojom::UsbAlternateInterfaceInfoPtr,
68 device::UsbInterfaceDescriptor> { 70 device::UsbInterfaceDescriptor> {
69 static device::usb::AlternateInterfaceInfoPtr Convert( 71 static device::mojom::UsbAlternateInterfaceInfoPtr Convert(
70 const device::UsbInterfaceDescriptor& iface); 72 const device::UsbInterfaceDescriptor& iface);
71 }; 73 };
72 74
73 // Note that this is an explicit vector-to-array conversion, as 75 // Note that this is an explicit vector-to-array conversion, as
74 // UsbInterfaceDescriptor collections are flattened to contain all alternate 76 // UsbInterfaceDescriptor collections are flattened to contain all alternate
75 // settings, whereas InterfaceInfos contain their own sets of alternates with 77 // settings, whereas InterfaceInfos contain their own sets of alternates with
76 // a different structure type. 78 // a different structure type.
77 template <> 79 template <>
78 struct TypeConverter<std::vector<device::usb::InterfaceInfoPtr>, 80 struct TypeConverter<std::vector<device::mojom::UsbInterfaceInfoPtr>,
79 std::vector<device::UsbInterfaceDescriptor>> { 81 std::vector<device::UsbInterfaceDescriptor>> {
80 static std::vector<device::usb::InterfaceInfoPtr> Convert( 82 static std::vector<device::mojom::UsbInterfaceInfoPtr> Convert(
81 const std::vector<device::UsbInterfaceDescriptor>& interfaces); 83 const std::vector<device::UsbInterfaceDescriptor>& interfaces);
82 }; 84 };
83 85
84 template <> 86 template <>
85 struct TypeConverter<device::usb::ConfigurationInfoPtr, 87 struct TypeConverter<device::mojom::UsbConfigurationInfoPtr,
86 device::UsbConfigDescriptor> { 88 device::UsbConfigDescriptor> {
87 static device::usb::ConfigurationInfoPtr Convert( 89 static device::mojom::UsbConfigurationInfoPtr Convert(
88 const device::UsbConfigDescriptor& config); 90 const device::UsbConfigDescriptor& config);
89 }; 91 };
90 92
91 template <> 93 template <>
92 struct TypeConverter<device::usb::DeviceInfoPtr, device::UsbDevice> { 94 struct TypeConverter<device::mojom::UsbDeviceInfoPtr, device::UsbDevice> {
93 static device::usb::DeviceInfoPtr Convert(const device::UsbDevice& device); 95 static device::mojom::UsbDeviceInfoPtr Convert(
96 const device::UsbDevice& device);
94 }; 97 };
95 98
96 template <> 99 template <>
97 struct TypeConverter<device::usb::IsochronousPacketPtr, 100 struct TypeConverter<device::mojom::UsbIsochronousPacketPtr,
98 device::UsbDeviceHandle::IsochronousPacket> { 101 device::UsbDeviceHandle::IsochronousPacket> {
99 static device::usb::IsochronousPacketPtr Convert( 102 static device::mojom::UsbIsochronousPacketPtr Convert(
100 const device::UsbDeviceHandle::IsochronousPacket& packet); 103 const device::UsbDeviceHandle::IsochronousPacket& packet);
101 }; 104 };
102 105
103 template <typename A, typename B> 106 template <typename A, typename B>
104 struct TypeConverter<std::vector<A>, std::vector<B>> { 107 struct TypeConverter<std::vector<A>, std::vector<B>> {
105 static std::vector<A> Convert(const std::vector<B>& input) { 108 static std::vector<A> Convert(const std::vector<B>& input) {
106 std::vector<A> result; 109 std::vector<A> result;
107 result.reserve(input.size()); 110 result.reserve(input.size());
108 for (const B& item : input) 111 for (const B& item : input)
109 result.push_back(mojo::ConvertTo<A>(item)); 112 result.push_back(mojo::ConvertTo<A>(item));
110 return result; 113 return result;
111 }; 114 };
112 }; 115 };
113 116
114 } // namespace mojo 117 } // namespace mojo
115 118
116 #endif // DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_ 119 #endif // DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_
OLDNEW
« no previous file with comments | « device/usb/mojo/device_manager_impl_unittest.cc ('k') | device/usb/mojo/type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698