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

Unified Diff: device/usb/mojo/type_converters.h

Issue 2234443002: Mojo C++ binding: make device/usb mojom targets use STD string/vector types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move the vector converter into a private header. Created 4 years, 4 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« 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