| OLD | NEW |
| 1 // This file is generated from {{input_file}} | 1 // This file is generated from {{input_file}} |
| 2 | 2 |
| 3 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 4 // Use of this source code is governed by a BSD-style license that can be |
| 5 // found in the LICENSE file. | 5 // found in the LICENSE file. |
| 6 | 6 |
| 7 | 7 |
| 8 {% set agents_class = name + "Agents" %} | 8 {% set sink_class = (name | to_singular) + "Sink" %} |
| 9 {% for file in files %} | 9 {% for file in files %} |
| 10 #include "{{file.name}}Inl.h" | 10 #include "{{file.name}}Inl.h" |
| 11 {% endfor %} | 11 {% endfor %} |
| 12 #include "{{agents_class}}.h" | 12 #include "{{sink_class}}.h" |
| 13 {% for agent in agents %} | 13 {% for agent in agents %} |
| 14 {% set class_name = agent | agent_name_to_class %} | 14 {% set class_name = agent | agent_name_to_class %} |
| 15 {% if class_name == "PerformanceMonitor" %} | 15 {% if class_name == "PerformanceMonitor" %} |
| 16 #include "core/frame/PerformanceMonitor.h" | 16 #include "core/frame/PerformanceMonitor.h" |
| 17 {% elif class_name.startswith("Platform") %} | 17 {% elif class_name.startswith("Platform") %} |
| 18 #include "platform/instrumentation/{{class_name}}.h" | 18 #include "platform/probe/{{class_name}}.h" |
| 19 {% else %} | 19 {% else %} |
| 20 #include "core/inspector/{{class_name}}.h" | 20 #include "core/inspector/{{class_name}}.h" |
| 21 {% endif %} | 21 {% endif %} |
| 22 {% endfor %} | 22 {% endfor %} |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 | 25 |
| 26 {{agents_class}}::{{agents_class}}() {} | 26 {{sink_class}}::{{sink_class}}() {} |
| 27 | 27 |
| 28 {% for agent in agents %} | 28 {% for agent in agents %} |
| 29 {% set class_name = agent | agent_name_to_class %} | 29 {% set class_name = agent | agent_name_to_class %} |
| 30 {% set getter_name = class_name | to_lower_case %} | 30 {% set getter_name = class_name | to_lower_case %} |
| 31 void {{agents_class}}::add{{class_name}}({{class_name}}* agent) { | 31 void {{sink_class}}::add{{class_name}}({{class_name}}* agent) { |
| 32 m_{{getter_name}}s.insert(agent); | 32 m_{{getter_name}}s.insert(agent); |
| 33 m_has{{class_name}}s = true; | 33 m_has{{class_name}}s = true; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void {{agents_class}}::remove{{class_name}}({{class_name}}* agent) { | 36 void {{sink_class}}::remove{{class_name}}({{class_name}}* agent) { |
| 37 m_{{getter_name}}s.erase(agent); | 37 m_{{getter_name}}s.erase(agent); |
| 38 m_has{{class_name}}s = !m_{{getter_name}}s.isEmpty(); | 38 m_has{{class_name}}s = !m_{{getter_name}}s.isEmpty(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 {% endfor -%} | 41 {% endfor -%} |
| 42 | 42 |
| 43 DEFINE_TRACE({{agents_class}}) | 43 DEFINE_TRACE({{sink_class}}) |
| 44 { | 44 { |
| 45 {% for agent in agents %} | 45 {% for agent in agents %} |
| 46 {% set getter_name = agent | agent_name_to_class | to_lower_case %} | 46 {% set getter_name = agent | agent_name_to_class | to_lower_case %} |
| 47 visitor->trace(m_{{getter_name}}s); | 47 visitor->trace(m_{{getter_name}}s); |
| 48 {% endfor %} | 48 {% endfor %} |
| 49 } | 49 } |
| 50 | 50 |
| 51 namespace probe { | 51 namespace probe { |
| 52 {% macro params_list(probe) -%} | 52 {% macro params_list(probe) -%} |
| 53 {%- for param in probe.params %} | 53 {%- for param in probe.params %} |
| 54 {{param.type}} {{param.name}} | 54 {{param.type}} {{param.name}} |
| 55 {%- if not loop.last %}, {% endif -%} | 55 {%- if not loop.last %}, {% endif -%} |
| 56 {%- endfor -%} | 56 {%- endfor -%} |
| 57 {%- endmacro %} | 57 {%- endmacro %} |
| 58 | 58 |
| 59 {% macro probe_body(probe, common_name) %} | 59 {% macro probe_body(probe, common_name) %} |
| 60 {% set agent_probe_name = common_name or probe.name %} | 60 {% set agent_probe_name = common_name or probe.name %} |
| 61 {{agents_class}}* agents = instrumentingAgentsFor({{probe.params[0].name}}); | 61 {{sink_class}}* sink = to{{sink_class}}({{probe.params[0].name}}); |
| 62 if (!agents) | 62 if (!sink) |
| 63 return {{probe.default_return_value}}; | 63 return {{probe.default_return_value}}; |
| 64 {% for param in probe.params %} | 64 {% for param in probe.params %} |
| 65 {% if param.is_prp %} | 65 {% if param.is_prp %} |
| 66 RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}}; | 66 RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}}; |
| 67 {% endif %} | 67 {% endif %} |
| 68 {% endfor %} | 68 {% endfor %} |
| 69 {% set maybe_return = "return " if probe.returns_value else "" %} | 69 {% set maybe_return = "return " if probe.returns_value else "" %} |
| 70 {% for agent in probe.agents %} | 70 {% for agent in probe.agents %} |
| 71 {% set class_name = agent | agent_name_to_class %} | 71 {% set class_name = agent | agent_name_to_class %} |
| 72 if (agents->has{{class_name}}s()) { | 72 if (sink->has{{class_name}}s()) { |
| 73 for ({{class_name}}* agent : agents->{{ class_name | to_lower_case }}s()) | 73 for ({{class_name}}* agent : sink->{{ class_name | to_lower_case }}s()) |
| 74 {{maybe_return}}agent->{{agent_probe_name}}({{caller()}}); | 74 {{maybe_return}}agent->{{agent_probe_name}}({{caller()}}); |
| 75 } | 75 } |
| 76 {% endfor %} | 76 {% endfor %} |
| 77 {% if probe.default_return_value %} | 77 {% if probe.default_return_value %} |
| 78 return {{probe.default_return_value}}; | 78 return {{probe.default_return_value}}; |
| 79 {% endif %} | 79 {% endif %} |
| 80 {% endmacro -%} | 80 {% endmacro -%} |
| 81 | 81 |
| 82 {% for file in files %} | 82 {% for file in files %} |
| 83 {% for probe in file.declarations %} | 83 {% for probe in file.declarations %} |
| (...skipping 23 matching lines...) Expand all Loading... |
| 107 {%- endfor %} | 107 {%- endfor %} |
| 108 {%- endcall %} | 108 {%- endcall %} |
| 109 } | 109 } |
| 110 | 110 |
| 111 {% endif %} | 111 {% endif %} |
| 112 {% endfor %} | 112 {% endfor %} |
| 113 {% endfor %} | 113 {% endfor %} |
| 114 | 114 |
| 115 } // namespace probe | 115 } // namespace probe |
| 116 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |