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

Unified Diff: mojo/common/common_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: Fix android build. 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
Index: mojo/common/common_type_converters.h
diff --git a/mojo/common/common_type_converters.h b/mojo/common/common_type_converters.h
index a065f050791d71a72d11cf9f88e648019839a31c..ac6c0c9e483cfbed95f8ff4c269632d1f91af444 100644
--- a/mojo/common/common_type_converters.h
+++ b/mojo/common/common_type_converters.h
@@ -6,6 +6,7 @@
#define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
#include <stdint.h>
+#include <vector>
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
@@ -61,6 +62,17 @@ struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, base::string16> {
static Array<uint8_t> Convert(const base::string16& input);
};
+template <typename A, typename B>
+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;
+ };
+};
dcheng 2016/08/15 18:18:15 Actually, let's not add this type converter please
Reilly Grant (use Gerrit) 2016/08/15 21:39:02 As discussed OOB I've moved this to a more private
+
} // namespace mojo
#endif // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_

Powered by Google App Engine
This is Rietveld 408576698