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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/interface_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
Index: mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
index 9889f8b8bcd0cd274306538a0d8fa5a3365c27e5..a4453131d4d701044ebef897da016f69da852661 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
@@ -7,10 +7,13 @@
{%- set namespace_as_string = "%s"|format(namespace|replace(".","::")) %}
{%- macro alloc_params(struct, serialization_context) %}
+ bool success = true;
{%- for param in struct.packed.packed_fields_in_ordinal_order %}
{{param.field.kind|cpp_result_type}} p_{{param.field.name}}{};
{%- endfor %}
- {{struct_macros.deserialize(struct, "params", "p_%s", serialization_context)}}
+ {{struct_macros.deserialize(struct, "params", "p_%s", serialization_context, "success")}}
+ if (!success)
+ return false;
{%- endmacro %}
{%- macro pass_params(parameters) %}
@@ -224,11 +227,11 @@ bool {{class_name}}Stub::AcceptWithResponder(
message->mutable_payload());
params->DecodePointersAndHandles(message->mutable_handles());
+ {{alloc_params(method.param_struct, "&serialization_context_")|indent(4)}}
{{class_name}}::{{method.name}}Callback::Runnable* runnable =
new {{class_name}}_{{method.name}}_ProxyToResponder(
message->request_id(), responder);
{{class_name}}::{{method.name}}Callback callback(runnable);
- {{alloc_params(method.param_struct, "&serialization_context_")|indent(4)}}
// A null |sink_| means no implementation was bound.
assert(sink_);
TRACE_EVENT0("mojom", "{{class_name}}::{{method.name}}");

Powered by Google App Engine
This is Rietveld 408576698