Commit ea330473 authored by Karel Král's avatar Karel Král Committed by Commit Bot

Enable the method AsValueInto on mojo

Stop hiding the mojo auto-generated method AsValueInto behind the build flag MOJO_TRACE_ENABLED to allow emitting traces from non-generated code. Thus there would be no need to write custom trace methods by hand and to keep them up-to-date.

Bug: 1103623
Change-Id: Ibdc45d15e21c9edc9324fe1f9614f4435d00e2d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351999Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Karel Král <karelkral@google.com>
Cr-Commit-Position: refs/heads/master@{#798057}
parent 48701743
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
#include "base/hash/md5_constexpr.h" #include "base/hash/md5_constexpr.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/common/task_annotator.h" #include "base/task/common/task_annotator.h"
#include "base/trace_event/trace_conversion_helper.h"
#include "base/trace_event/traced_value.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h" #include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h" #include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h" #include "mojo/public/cpp/bindings/lib/serialization_util.h"
......
...@@ -51,11 +51,8 @@ namespace {{variant}} { ...@@ -51,11 +51,8 @@ namespace {{variant}} {
#include "mojo/public/cpp/bindings/mojo_buildflags.h" #include "mojo/public/cpp/bindings/mojo_buildflags.h"
#if BUILDFLAG(MOJO_TRACE_ENABLED) #if BUILDFLAG(MOJO_TRACE_ENABLED)
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_conversion_helper.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h" #endif // BUILDFLAG(MOJO_TRACE_ENABLED)
#endif
#include "mojo/public/cpp/bindings/clone_traits.h" #include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h" #include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h" #include "mojo/public/cpp/bindings/lib/serialization.h"
...@@ -144,6 +141,14 @@ namespace {{variant}} { ...@@ -144,6 +141,14 @@ namespace {{variant}} {
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
// Forward-declare for |AsValueInto| so that we do not have to import the
// corresponding header.
namespace base {
namespace trace_event {
class TracedValue;
} // namespace trace_event
} // namespace base
{{namespace_begin()}} {{namespace_begin()}}
{%- set module_prefix = "%s"|format(namespaces_as_array|join(".")) %} {%- set module_prefix = "%s"|format(namespaces_as_array|join(".")) %}
......
...@@ -128,7 +128,6 @@ class {{export_attribute}} {{struct.name}} { ...@@ -128,7 +128,6 @@ class {{export_attribute}} {{struct.name}} {
{{type}} {{name}}; {{type}} {{name}};
{%- endfor %} {%- endfor %}
#if BUILDFLAG(MOJO_TRACE_ENABLED)
// Write this structure into |value|. The members are represented as a // Write this structure into |value|. The members are represented as a
// dictionary |member name|: |member value|. This method does not deal with // dictionary |member name|: |member value|. This method does not deal with
// the dictionary name. The caller is responsible for not calling // the dictionary name. The caller is responsible for not calling
...@@ -177,7 +176,6 @@ class {{export_attribute}} {{struct.name}} { ...@@ -177,7 +176,6 @@ class {{export_attribute}} {{struct.name}} {
// b.AsValueInto(value1); // b.AsValueInto(value1);
// c.AsValueInto(value2); // c.AsValueInto(value2);
void AsValueInto(base::trace_event::TracedValue* value) const; void AsValueInto(base::trace_event::TracedValue* value) const;
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
private: private:
static bool Validate(const void* data, static bool Validate(const void* data,
......
...@@ -32,7 +32,6 @@ size_t {{struct.name}}::Hash(size_t seed) const { ...@@ -32,7 +32,6 @@ size_t {{struct.name}}::Hash(size_t seed) const {
} }
{%- endif %} {%- endif %}
#if BUILDFLAG(MOJO_TRACE_ENABLED)
void {{struct.name}}::AsValueInto(base::trace_event::TracedValue* value) const { void {{struct.name}}::AsValueInto(base::trace_event::TracedValue* value) const {
{%- for field in struct.fields %} {%- for field in struct.fields %}
{%- for line in field.kind|write_input_param_for_tracing( {%- for line in field.kind|write_input_param_for_tracing(
...@@ -43,7 +42,6 @@ void {{struct.name}}::AsValueInto(base::trace_event::TracedValue* value) const { ...@@ -43,7 +42,6 @@ void {{struct.name}}::AsValueInto(base::trace_event::TracedValue* value) const {
{%- endfor -%} {%- endfor -%}
{%- endfor %} {%- endfor %}
} }
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
bool {{struct.name}}::Validate( bool {{struct.name}}::Validate(
const void* data, const void* data,
......
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