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

Unified Diff: mojo/public/cpp/bindings/wtf_array.h

Issue 1753543002: PaymentRequest Mojo bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interface
Patch Set: More general type converter. Created 4 years, 9 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/public/cpp/bindings/wtf_array.h
diff --git a/mojo/public/cpp/bindings/wtf_array.h b/mojo/public/cpp/bindings/wtf_array.h
index b5d1a30c36304ace290d60d6735919ec408083fd..becc0671b4ba9cacf7b098b9aa888be367c7e36e 100644
--- a/mojo/public/cpp/bindings/wtf_array.h
+++ b/mojo/public/cpp/bindings/wtf_array.h
@@ -230,6 +230,19 @@ class WTFArray {
bool is_null_;
};
+// A |TypeConverter| that will create a |WTFArray<T>| containing a copy of the
+// contents of a |WTF::Vector<E, c, A>|, using |TypeConverter<T, E>| to copy
+// each element. The returned array will always be non-null.
+template <typename T, typename E, size_t c, typename A>
+struct TypeConverter<WTFArray<T>, WTF::Vector<E, c, A>> {
+ static WTFArray<T> Convert(const WTF::Vector<E, c, A>& input) {
+ WTFArray<T> result(input.size());
+ for (size_t i = 0; i < input.size(); ++i)
+ result[i] = TypeConverter<T, E>::Convert(input[i]);
+ return std::move(result);
+ }
+};
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_

Powered by Google App Engine
This is Rietveld 408576698