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

Unified Diff: mojo/public/cpp/bindings/lib/map_serialization.h

Issue 2034273002: Mojo C++ bindings: introduce mojo::WTFMap for blink bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed the code of adding enum key support to WTF::HashMap; which turned out to be non-trivial; wi… Created 4 years, 6 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/lib/map_serialization.h
diff --git a/mojo/public/cpp/bindings/lib/map_serialization.h b/mojo/public/cpp/bindings/lib/map_serialization.h
index 5df94cd7f230bf229bba7e2a639d7f748b297be8..7bf61a8984bc8b74af93964b3ee1cc727c2100ea 100644
--- a/mojo/public/cpp/bindings/lib/map_serialization.h
+++ b/mojo/public/cpp/bindings/lib/map_serialization.h
@@ -6,6 +6,7 @@
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_
#include <type_traits>
+#include <vector>
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/lib/array_serialization.h"
@@ -84,11 +85,11 @@ struct Serializer<Map<Key, Value>, MaybeConstUserType> {
using UserValue = typename Traits::Value;
using Data = typename Map<Key, Value>::Data_;
using KeyArraySerializer = ArraySerializer<Array<Key>,
- Array<UserKey>,
+ std::vector<UserKey>,
MapKeyReader<MaybeConstUserType>>;
using ValueArraySerializer =
ArraySerializer<Array<Value>,
- Array<UserValue>,
+ std::vector<UserValue>,
MapValueReader<MaybeConstUserType>>;
static size_t PrepareToSerialize(MaybeConstUserType& input,
@@ -147,8 +148,8 @@ struct Serializer<Map<Key, Value>, MaybeConstUserType> {
if (!input)
return CallSetToNullIfExists<Traits>(output);
- Array<UserKey> keys;
- Array<UserValue> values;
+ std::vector<UserKey> keys;
+ std::vector<UserValue> values;
if (!KeyArraySerializer::DeserializeElements(input->keys.ptr, &keys,
context) ||
@@ -161,8 +162,10 @@ struct Serializer<Map<Key, Value>, MaybeConstUserType> {
size_t size = keys.size();
Traits::SetToEmpty(output);
- for (size_t i = 0; i < size; ++i)
- Traits::Insert(*output, std::move(keys[i]), std::move(values[i]));
+ for (size_t i = 0; i < size; ++i) {
+ if (!Traits::Insert(*output, std::move(keys[i]), std::move(values[i])))
+ return false;
+ }
return true;
}
};
« no previous file with comments | « mojo/public/cpp/bindings/lib/array_serialization.h ('k') | mojo/public/cpp/bindings/lib/wtf_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698