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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Typemap IndexedDBDatabaseMetadata. Created 4 years, 2 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/array_traits_stl.h
diff --git a/mojo/public/cpp/bindings/array_traits_stl.h b/mojo/public/cpp/bindings/array_traits_stl.h
index c1aac00a7cd4686091ed5be927bc5fd886c2d7c0..679fd0d51a80b723285620860998308c307c0647 100644
--- a/mojo/public/cpp/bindings/array_traits_stl.h
+++ b/mojo/public/cpp/bindings/array_traits_stl.h
@@ -5,6 +5,8 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_
#define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_
+#include <map>
+#include <set>
#include <vector>
#include "mojo/public/cpp/bindings/array_traits.h"
@@ -85,6 +87,26 @@ struct ArrayTraits<std::set<T>> {
}
};
+// This ArrayTraits specialization is used only for serialization.
+template <typename K, typename V>
+struct ArrayTraits<std::map<K, V>> {
Ken Rockot(use gerrit already) 2016/10/14 21:50:47 I think this is probably a bit confusing to do. I
Reilly Grant (use Gerrit) 2016/10/15 00:13:42 Done. Let me know if there's a way to make usage o
+ using Element = V;
+ using ConstIterator = typename std::map<K, V>::const_iterator;
+
+ static bool IsNull(const std::map<K, V>& input) {
+ // std::map<> is always converted to non-null mojom array.
+ return false;
+ }
+
+ static size_t GetSize(const std::map<K, V>& input) { return input.size(); }
+
+ static ConstIterator GetBegin(const std::map<K, V>& input) {
+ return input.begin();
+ }
+ static void AdvanceIterator(ConstIterator& iterator) { ++iterator; }
+ static const V& GetValue(ConstIterator& iterator) { return iterator->second; }
+};
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_

Powered by Google App Engine
This is Rietveld 408576698