OLD | NEW |
| (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 {% for file in files %} | |
9 #include "{{file.header_name}}.h" | |
10 {% endfor %} | |
11 #include "InstrumentingAgents.h" | |
12 #include "core/CoreExport.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 {% else %} | |
18 #include "core/inspector/{{class_name}}.h" | |
19 {% endif %} | |
20 {% endfor %} | |
21 | |
22 namespace blink { | |
23 | |
24 InstrumentingAgents::InstrumentingAgents() {} | |
25 | |
26 {% for agent in agents %} | |
27 {% set class_name = agent | agent_name_to_class %} | |
28 {% set getter_name = class_name | to_lower_case %} | |
29 void InstrumentingAgents::add{{class_name}}({{class_name}}* agent) { | |
30 m_{{getter_name}}s.insert(agent); | |
31 m_has{{class_name}}s = true; | |
32 } | |
33 | |
34 void InstrumentingAgents::remove{{class_name}}({{class_name}}* agent) { | |
35 m_{{getter_name}}s.erase(agent); | |
36 m_has{{class_name}}s = !m_{{getter_name}}s.isEmpty(); | |
37 } | |
38 | |
39 {% endfor -%} | |
40 | |
41 DEFINE_TRACE(InstrumentingAgents) | |
42 { | |
43 {% for agent in agents %} | |
44 {% set getter_name = agent | agent_name_to_class | to_lower_case %} | |
45 visitor->trace(m_{{getter_name}}s); | |
46 {% endfor %} | |
47 } | |
48 | |
49 namespace probe { | |
50 {% macro params_list(probe) -%} | |
51 {%- for param in probe.params %} | |
52 {{param.type}} {{param.name}} | |
53 {%- if not loop.last %}, {% endif -%} | |
54 {%- endfor -%} | |
55 {%- endmacro %} | |
56 | |
57 {% macro probe_body(probe, common_name) %} | |
58 {% set agent_probe_name = common_name or probe.name %} | |
59 InstrumentingAgents* agents = instrumentingAgentsFor({{probe.params[0].name}})
; | |
60 if (!agents) | |
61 return {{probe.default_return_value}}; | |
62 {% for param in probe.params %} | |
63 {% if param.is_prp %} | |
64 RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}}; | |
65 {% endif %} | |
66 {% endfor %} | |
67 {% set maybe_return = "return " if probe.returns_value else "" %} | |
68 {% for agent in probe.agents %} | |
69 {% set class_name = agent | agent_name_to_class %} | |
70 if (agents->has{{class_name}}s()) { | |
71 for ({{class_name}}* agent : agents->{{ class_name | to_lower_case }}s()) | |
72 {{maybe_return}}agent->{{agent_probe_name}}({{caller()}}); | |
73 } | |
74 {% endfor %} | |
75 {% if probe.default_return_value %} | |
76 return {{probe.default_return_value}}; | |
77 {% endif %} | |
78 {% endmacro -%} | |
79 | |
80 {% for file in files %} | |
81 {% for probe in file.declarations %} | |
82 {% if probe.is_scoped %} | |
83 {{probe.name}}::{{probe.name}}({{ params_list(probe) }}) : | |
84 {% for param in probe.params %} | |
85 {{param.name}}({{param.name}}) | |
86 {%- if not loop.last %}, | |
87 {% endif %} | |
88 {% endfor %} { | |
89 {% call probe_body(probe, "will") %}*this{% endcall %} | |
90 } | |
91 | |
92 {{probe.name}}::~{{probe.name}}() { | |
93 {% call probe_body(probe, "did") %}*this{% endcall %} | |
94 } | |
95 | |
96 {% else -%} | |
97 | |
98 CORE_EXPORT {{probe.return_type}} {{probe.name}}({{ params_list(probe) }}) { | |
99 {% call probe_body(probe, "") %} | |
100 {%- for param in probe.params %} | |
101 {%- if not loop.first or "Keep" in param.options -%} | |
102 {{param.value}} | |
103 {%- if not loop.last %}, {% endif -%} | |
104 {%- endif -%} | |
105 {%- endfor %} | |
106 {%- endcall %} | |
107 } | |
108 | |
109 {% endif %} | |
110 {% endfor %} | |
111 {% endfor %} | |
112 | |
113 } // namespace probe | |
114 } // namespace blink | |
OLD | NEW |