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

Side by Side Diff: third_party/WebKit/Source/platform/probe/templates/InstrumentingProbesImpl.cpp.tmpl

Issue 2790973002: [instrumentation] Introduce JSON5 config files for probe generator. (Closed)
Patch Set: add missing config files Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // This file is generated from {{input_file}}
2
3 // Copyright 2017 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
6
7
8 {% set sink_class = (name | to_singular) + "Sink" %}
9 {% for file in files %}
10 #include "{{file.name}}Inl.h"
11 {% endfor %}
12 #include "{{sink_class}}.h"
13 {% for agent in agents %}
14 {% set class_name = agent | agent_name_to_class %}
15 {% if class_name == "PerformanceMonitor" %}
16 #include "core/frame/PerformanceMonitor.h"
17 {% elif class_name.startswith("Platform") %}
18 #include "platform/probe/{{class_name}}.h"
19 {% else %}
20 #include "core/inspector/{{class_name}}.h"
21 {% endif %}
22 {% endfor %}
23
24 namespace blink {
25
26 {{sink_class}}::{{sink_class}}() {}
27
28 {% for agent in agents %}
29 {% set class_name = agent | agent_name_to_class %}
30 {% set getter_name = class_name | to_lower_case %}
31 void {{sink_class}}::add{{class_name}}({{class_name}}* agent) {
32 m_{{getter_name}}s.insert(agent);
33 m_has{{class_name}}s = true;
34 }
35
36 void {{sink_class}}::remove{{class_name}}({{class_name}}* agent) {
37 m_{{getter_name}}s.erase(agent);
38 m_has{{class_name}}s = !m_{{getter_name}}s.isEmpty();
39 }
40
41 {% endfor -%}
42
43 DEFINE_TRACE({{sink_class}})
44 {
45 {% for agent in agents %}
46 {% set getter_name = agent | agent_name_to_class | to_lower_case %}
47 visitor->trace(m_{{getter_name}}s);
48 {% endfor %}
49 }
50
51 namespace probe {
52 {% macro params_list(probe) -%}
53 {%- for param in probe.params %}
54 {{param.type}} {{param.name}}
55 {%- if not loop.last %}, {% endif -%}
56 {%- endfor -%}
57 {%- endmacro %}
58
59 {% macro probe_body(probe, common_name) %}
60 {% set agent_probe_name = common_name or probe.name %}
61 {{sink_class}}* sink = to{{sink_class}}({{probe.params[0].name}});
62 if (!sink)
63 return {{probe.default_return_value}};
64 {% for param in probe.params %}
65 {% if param.is_prp %}
66 RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}};
67 {% endif %}
68 {% endfor %}
69 {% set maybe_return = "return " if probe.returns_value else "" %}
70 {% for agent in probe.agents %}
71 {% set class_name = agent | agent_name_to_class %}
72 if (sink->has{{class_name}}s()) {
73 for ({{class_name}}* agent : sink->{{ class_name | to_lower_case }}s())
74 {{maybe_return}}agent->{{agent_probe_name}}({{caller()}});
75 }
76 {% endfor %}
77 {% if probe.default_return_value %}
78 return {{probe.default_return_value}};
79 {% endif %}
80 {% endmacro -%}
81
82 {% for file in files %}
83 {% for probe in file.declarations %}
84 {% if probe.is_scoped %}
85 {{probe.name}}::{{probe.name}}({{ params_list(probe) }}) :
86 {% for param in probe.params %}
87 {{param.name}}({{param.name}})
88 {%- if not loop.last %},
89 {% endif %}
90 {% endfor %} {
91 {% call probe_body(probe, "will") %}*this{% endcall %}
92 }
93
94 {{probe.name}}::~{{probe.name}}() {
95 {% call probe_body(probe, "did") %}*this{% endcall %}
96 }
97
98 {% else -%}
99
100 CORE_EXPORT {{probe.return_type}} {{probe.name}}({{ params_list(probe) }}) {
101 {% call probe_body(probe, "") %}
102 {%- for param in probe.params %}
103 {%- if not loop.first or "Keep" in param.options -%}
104 {{param.value}}
105 {%- if not loop.last %}, {% endif -%}
106 {%- endif -%}
107 {%- endfor %}
108 {%- endcall %}
109 }
110
111 {% endif %}
112 {% endfor %}
113 {% endfor %}
114
115 } // namespace probe
116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698