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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl

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
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/union_serialization_declaration.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
index 3471932b6818d57bc872b80797486be1e731527d..73f6c95865fb763d5c2f25440c85fbbae7fb448b 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl
@@ -93,9 +93,10 @@ void SerializeUnion_({{union.name}}Ptr input, mojo::internal::Buffer* buf,
*output = result;
}
-void Deserialize_(internal::{{union.name}}_Data* input,
+bool Deserialize_(internal::{{union.name}}_Data* input,
{{union.name}}Ptr* output,
mojo::internal::SerializationContext* context) {
+ bool success = true;
if (input && !input->is_null()) {
{{union.name}}Ptr result({{union.name}}::New());
mojo::internal::UnionAccessor<{{union.name}}> result_acc(result.get());
@@ -104,7 +105,8 @@ void Deserialize_(internal::{{union.name}}_Data* input,
case {{union.name}}::Tag::{{field.name|upper}}: {
{% if field.kind|is_object_kind %}
result_acc.SwitchActive({{union.name}}::Tag::{{field.name|upper}});
- Deserialize_(input->data.f_{{field.name}}.ptr, result_acc.data()->{{field.name}}, context);
+ if (!Deserialize_(input->data.f_{{field.name}}.ptr, result_acc.data()->{{field.name}}, context))
+ success = false;
{% elif field.kind|is_any_handle_kind %}
{{field.kind|cpp_wrapper_type}}* {{field.name}} =
reinterpret_cast<{{field.kind|cpp_wrapper_type}}*>(&input->data.f_{{field.name}});
@@ -132,4 +134,5 @@ void Deserialize_(internal::{{union.name}}_Data* input,
} else {
output->reset();
}
+ return success;
}
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/union_serialization_declaration.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698