| 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 sink_class = (name | to_singular) + "Sink" %} | 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 {% for agent in agents %} | 21 {% for agent in agents %} |
| 22 {% set class_name = agent | agent_name_to_class %} | 22 {% set class_name = agent | agent_name_to_class %} |
| 23 {% set getter_name = class_name | to_lower_case %} | 23 {% set getter_name = class_name | to_lower_case %} |
| 24 void {{sink_class}}::add{{class_name}}({{class_name}}* agent) { | 24 void {{sink_class}}::add{{class_name}}({{class_name}}* agent) { |
| 25 m_{{getter_name}}s.insert(agent); | 25 m_{{getter_name}}s.insert(agent); |
| 26 m_has{{class_name}}s = true; | 26 m_has{{class_name}}s = true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 void {{sink_class}}::remove{{class_name}}({{class_name}}* agent) { | 29 void {{sink_class}}::remove{{class_name}}({{class_name}}* agent) { |
| 30 m_{{getter_name}}s.erase(agent); | 30 m_{{getter_name}}s.erase(agent); |
| 31 m_has{{class_name}}s = !m_{{getter_name}}s.isEmpty(); | 31 m_has{{class_name}}s = !m_{{getter_name}}s.IsEmpty(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 {% endfor -%} | 34 {% endfor -%} |
| 35 | 35 |
| 36 DEFINE_TRACE({{sink_class}}) | 36 DEFINE_TRACE({{sink_class}}) |
| 37 { | 37 { |
| 38 {% for agent in agents %} | 38 {% for agent in agents %} |
| 39 {% set getter_name = agent | agent_name_to_class | to_lower_case %} | 39 {% set getter_name = agent | agent_name_to_class | to_lower_case %} |
| 40 visitor->trace(m_{{getter_name}}s); | 40 visitor->Trace(m_{{getter_name}}s); |
| 41 {% endfor %} | 41 {% endfor %} |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace probe { | 44 namespace probe { |
| 45 {% macro params_list(probe) -%} | 45 {% macro params_list(probe) -%} |
| 46 {%- for param in probe.params %} | 46 {%- for param in probe.params %} |
| 47 {{param.type}} {{param.name}} | 47 {{param.type}} {{param.name}} |
| 48 {%- if not loop.last %}, {% endif -%} | 48 {%- if not loop.last %}, {% endif -%} |
| 49 {%- endfor -%} | 49 {%- endfor -%} |
| 50 {%- endmacro %} | 50 {%- endmacro %} |
| 51 | 51 |
| 52 {% macro probe_body(probe, common_name) %} | 52 {% macro probe_body(probe, common_name) %} |
| 53 {% set agent_probe_name = common_name or probe.name %} | 53 {% set agent_probe_name = method_name(common_name or probe.name) %} |
| 54 {{sink_class}}* sink = to{{sink_class}}({{probe.params[0].name}}); | 54 {{sink_class}}* sink = To{{sink_class}}({{probe.params[0].name}}); |
| 55 if (!sink) | 55 if (!sink) |
| 56 return; | 56 return; |
| 57 {% for param in probe.params %} | 57 {% for param in probe.params %} |
| 58 {% if param.is_prp %} | 58 {% if param.is_prp %} |
| 59 RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}}; | 59 RefPtr<{{param.inner_type}}> {{param.value}} = {{param.name}}; |
| 60 {% endif %} | 60 {% endif %} |
| 61 {% endfor %} | 61 {% endfor %} |
| 62 {% for agent in probe.agents %} | 62 {% for agent in probe.agents %} |
| 63 {% set class_name = agent | agent_name_to_class %} | 63 {% set class_name = agent | agent_name_to_class %} |
| 64 if (sink->has{{class_name}}s()) { | 64 if (sink->has{{class_name}}s()) { |
| 65 for ({{class_name}}* agent : sink->{{ class_name | to_lower_case }}s()) | 65 for ({{class_name}}* agent : sink->{{ class_name | to_lower_case }}s()) |
| 66 agent->{{agent_probe_name}}({{caller()}}); | 66 agent->{{agent_probe_name}}({{caller()}}); |
| 67 } | 67 } |
| 68 {% endfor %} | 68 {% endfor %} |
| 69 {% endmacro -%} | 69 {% endmacro -%} |
| 70 | 70 |
| 71 {% for file in files %} | 71 {% for file in files %} |
| 72 {% for probe in file.declarations %} | 72 {% for probe in file.declarations %} |
| 73 {% if probe.is_scoped %} | 73 {% if probe.is_scoped %} |
| 74 {{probe.name}}::{{probe.name}}({{ params_list(probe) }}) : | 74 {{probe.name}}::{{probe.name}}({{ params_list(probe) }}) : |
| 75 {% for param in probe.params %} | 75 {% for param in probe.params %} |
| 76 {{param.name}}({{param.name}}) | 76 {{param.name}}({{param.name}}) |
| 77 {%- if not loop.last %}, | 77 {%- if not loop.last %}, |
| 78 {% endif %} | 78 {% endif %} |
| 79 {% endfor %} { | 79 {% endfor %} { |
| 80 {% call probe_body(probe, "will") %}*this{% endcall %} | 80 {% call probe_body(probe, "Will") %}*this{% endcall %} |
| 81 } | 81 } |
| 82 | 82 |
| 83 {{probe.name}}::~{{probe.name}}() { | 83 {{probe.name}}::~{{probe.name}}() { |
| 84 {% call probe_body(probe, "did") %}*this{% endcall %} | 84 {% call probe_body(probe, "Did") %}*this{% endcall %} |
| 85 } | 85 } |
| 86 | 86 |
| 87 {% else -%} | 87 {% else -%} |
| 88 | 88 |
| 89 CORE_EXPORT void {{probe.name}}({{ params_list(probe) }}) { | 89 CORE_EXPORT void {{probe.name}}({{ params_list(probe) }}) { |
| 90 {% call probe_body(probe, "") %} | 90 {% call probe_body(probe, "") %} |
| 91 {%- for param in probe.params %} | 91 {%- for param in probe.params %} |
| 92 {%- if not loop.first or "Keep" in param.options -%} | 92 {%- if not loop.first or "Keep" in param.options -%} |
| 93 {{param.value}} | 93 {{param.value}} |
| 94 {%- if not loop.last %}, {% endif -%} | 94 {%- if not loop.last %}, {% endif -%} |
| 95 {%- endif -%} | 95 {%- endif -%} |
| 96 {%- endfor %} | 96 {%- endfor %} |
| 97 {%- endcall %} | 97 {%- endcall %} |
| 98 } | 98 } |
| 99 | 99 |
| 100 {% endif %} | 100 {% endif %} |
| 101 {% endfor %} | 101 {% endfor %} |
| 102 {% endfor %} | 102 {% endfor %} |
| 103 | 103 |
| 104 } // namespace probe | 104 } // namespace probe |
| 105 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |