Commit 2ba4ca05 authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

[mojo][bindings] Do not generate Serialize method for structs with

handles

This change removes generation of the Serialize() method for structs
that contain handles since such handles would not be deserialized
correctly outside of IPC sendind context.

Bug: 1147520
Change-Id: Ia9bfa29075d5610b21089bccc4f27015c83dc05c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538370Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828233}
parent bfb9625c
...@@ -69,11 +69,13 @@ class {{export_attribute}} {{struct.name}} { ...@@ -69,11 +69,13 @@ class {{export_attribute}} {{struct.name}} {
{%- set serialization_result_type = "WTF::Vector<uint8_t>" {%- set serialization_result_type = "WTF::Vector<uint8_t>"
if for_blink else "std::vector<uint8_t>" %} if for_blink else "std::vector<uint8_t>" %}
{%- if not struct|contains_handles_or_interfaces %}
template <typename UserType> template <typename UserType>
static {{serialization_result_type}} Serialize(UserType* input) { static {{serialization_result_type}} Serialize(UserType* input) {
return mojo::internal::SerializeImpl< return mojo::internal::SerializeImpl<
{{struct.name}}::DataView, {{serialization_result_type}}>(input); {{struct.name}}::DataView, {{serialization_result_type}}>(input);
} }
{%- endif %}
template <typename UserType> template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) { static mojo::Message SerializeAsMessage(UserType* input) {
......
...@@ -17,7 +17,8 @@ namespace ui { ...@@ -17,7 +17,8 @@ namespace ui {
namespace { namespace {
bool EchoCursor(const ui::Cursor& in, ui::Cursor* out) { bool EchoCursor(const ui::Cursor& in, ui::Cursor* out) {
return mojom::Cursor::Deserialize(mojom::Cursor::Serialize(&in), out); return mojom::Cursor::DeserializeFromMessage(
mojom::Cursor::SerializeAsMessage(&in), out);
} }
using CursorStructTraitsTest = testing::Test; using CursorStructTraitsTest = testing::Test;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment