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

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

Issue 1520153002: [mojo] Allow value deserialization to fail (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-3-misc-support
Patch Set: merge Created 5 years 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 6874fbe5aeda80318f07eca8280157804930823a..b3268720a23eded608f58072a7d62a3e65683763 100644
--- a/mojo/public/cpp/bindings/lib/map_serialization.h
+++ b/mojo/public/cpp/bindings/lib/map_serialization.h
@@ -162,20 +162,27 @@ template <typename MapKey,
typename MapValue,
typename DataKey,
typename DataValue>
-inline void Deserialize_(internal::Map_Data<DataKey, DataValue>* input,
+inline bool Deserialize_(internal::Map_Data<DataKey, DataValue>* input,
Map<MapKey, MapValue>* output,
internal::SerializationContext* context) {
+ bool success = true;
if (input) {
Array<MapKey> keys;
Array<MapValue> values;
- Deserialize_(input->keys.ptr, &keys, context);
- Deserialize_(input->values.ptr, &values, context);
+ // Note that we rely on complete deserialization taking place in order to
+ // transfer ownership of all encoded handles. Therefore we don't
+ // short-circuit on failure here.
+ if (!Deserialize_(input->keys.ptr, &keys, context))
+ success = false;
+ if (!Deserialize_(input->values.ptr, &values, context))
+ success = false;
*output = Map<MapKey, MapValue>(keys.Pass(), values.Pass());
} else {
output->reset();
}
+ return success;
}
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/array_serialization.h ('k') | mojo/public/cpp/bindings/lib/string_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698