summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/build/scripts/templates/InstrumentingProbesInl.h.tmpl
blob: 1fa858b634c2b326a356615cbe9e6de1912a7d0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

{% from 'macros.tmpl' import source_files_for_generated_file %}
{{source_files_for_generated_file(template_file, input_files)}}

#ifndef {{file.header_name}}_h
#define {{file.header_name}}_h

#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
{% for include in config["settings"]["includes"] %}
#include "{{include}}"
{% endfor %}

{% set export_symbol = config["settings"]["export_symbol"] %}
{% set sink_class = (name | to_singular) + "Sink" %}

namespace blink {

{% for forward_decl in file.forward_declarations %}
{{forward_decl}}
{% endfor %}

namespace probe {
{% for probe in file.declarations %}

{%- macro params_decl(probe) %}
{%- for param in probe.params %}
{{ param.type }}
{%- if param.default_value %} = {{ param.default_value }}
{%- endif %}
{%- if not loop.last %}, {% endif %}
{%- endfor %}
{%- endmacro -%}

{%- macro params_list(probe) %}
{%- for param in probe.params %}
{{param.type}} {{param.name}}
{%- if not loop.last %}, {% endif -%}
{%- endfor -%}
{%- endmacro %}

{% if probe.is_scoped %}

class {{export_symbol}} {{probe.name}} : public ProbeBase {
  STACK_ALLOCATED();

 public:
  explicit {{probe.name}}({{ params_decl(probe) }});
  ~{{probe.name}}();
  Member<{{sink_class}}> probe_sink;
{% for param in probe.params %}
  {{param.member_type}} {{param.name}};
{% endfor %}
};

{%- else %}

{{export_symbol}} void {{probe.name}}Impl({{ params_decl(probe) }});
inline void {{probe.name}}({{params_list(probe)}}) {
  if (!{{sink_class}}::HasAgentsGlobal(
    {%- for agent in probe.agents %}
    {% if not loop.first %} | {% endif -%}
    {{sink_class}}::k{{agent}}
    {%- endfor %}))
    return;

  {{probe.name}}Impl(
    {%- for param in probe.params %}
      {% if not loop.first %}, {% endif %}{{param.name}}
    {%- endfor %});
}

{%- endif %}
{%- endfor %}


} // namespace probe
} // namespace blink

#endif // !defined({{file.header_name}}_h)