Chromium Code Reviews| Index: device/usb/mojo/type_converters.h |
| diff --git a/device/usb/mojo/type_converters.h b/device/usb/mojo/type_converters.h |
| index d9031e2e06f76f9a86bfc5958e05b132be376637..92df665a524f21866b66d5db511fe0bf7398c105 100644 |
| --- a/device/usb/mojo/type_converters.h |
| +++ b/device/usb/mojo/type_converters.h |
| @@ -12,7 +12,6 @@ |
| #include "device/usb/usb_descriptors.h" |
| #include "device/usb/usb_device_filter.h" |
| #include "device/usb/usb_device_handle.h" |
| -#include "mojo/public/cpp/bindings/array.h" |
| #include "mojo/public/cpp/bindings/type_converter.h" |
| // Type converters to translate between internal device/usb data types and |
| @@ -82,9 +81,9 @@ struct TypeConverter<device::usb::AlternateInterfaceInfoPtr, |
| // settings, whereas InterfaceInfos contain their own sets of alternates with |
| // a different structure type. |
| template <> |
| -struct TypeConverter<mojo::Array<device::usb::InterfaceInfoPtr>, |
| +struct TypeConverter<std::vector<device::usb::InterfaceInfoPtr>, |
| std::vector<device::UsbInterfaceDescriptor>> { |
| - static mojo::Array<device::usb::InterfaceInfoPtr> Convert( |
| + static std::vector<device::usb::InterfaceInfoPtr> Convert( |
| const std::vector<device::UsbInterfaceDescriptor>& interfaces); |
| }; |
| @@ -107,6 +106,17 @@ struct TypeConverter<device::usb::IsochronousPacketPtr, |
| const device::UsbDeviceHandle::IsochronousPacket& packet); |
| }; |
| +template <typename A, typename B> |
|
dcheng
2016/08/15 21:41:28
The main thing I'm worried about is this leading t
|
| +struct TypeConverter<std::vector<A>, std::vector<B>> { |
| + static std::vector<A> Convert(const std::vector<B>& input) { |
| + std::vector<A> result; |
| + result.reserve(input.size()); |
| + for (const B& item : input) |
| + result.push_back(mojo::ConvertTo<A>(item)); |
| + return result; |
| + }; |
| +}; |
| + |
| } // namespace mojo |
| #endif // DEVICE_DEVICES_APP_USB_TYPE_CONVERTERS_H_ |