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

Unified Diff: headless/lib/browser/domain_h.template

Issue 2278123002: headless: Ensure all commands have parameters and return types (Closed)
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/browser/domain_cc.template ('k') | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/domain_h.template
diff --git a/headless/lib/browser/domain_h.template b/headless/lib/browser/domain_h.template
index cc0e8eb4e9b2da58c217bcb5b590a2d9e5feb4ba..2d146a70b52e34dec2ab6204c39660ee19507539 100644
--- a/headless/lib/browser/domain_h.template
+++ b/headless/lib/browser/domain_h.template
@@ -20,15 +20,7 @@
{% if command.description %}
// {{ command.description }}
{% endif %}
- {% if "parameters" in command and "returns" in command %}
void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback = base::Callback<void(std::unique_ptr<{{method_name}}Result>)>());
- {% elif "parameters" in command %}
- void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Callback<void()> callback = base::Callback<void()>());
- {% elif "returns" in command %}
- void {{method_name}}(base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback = base::Callback<void(std::unique_ptr<{{method_name}}Result>)>());
- {% else %}
- void {{method_name}}(base::Callback<void()> callback = base::Callback<void()>());
- {% endif %}
{# Generate convenience methods that take the required parameters directly. #}
{# Don't generate these for experimental commands. #}
{% if "parameters" in command and not command.experimental %}
@@ -40,12 +32,17 @@
{% if not loop.first %}, {% endif %}
{{resolve_type(parameter).pass_type}} {{parameter.name | camelcase_to_hacker_style -}}
{% endfor %}
- {% if "parameters" in command and not command.parameters[0].get("optional", False) %}, {% endif %}{# -#}
- {% if "returns" in command -%}
+ {% if command.get("parameters", []) and not command.parameters[0].get("optional", False) %}, {% endif %}{# -#}
+ {% if command.get("returns", []) -%}
base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback = base::Callback<void(std::unique_ptr<{{method_name}}Result>)>(){##}
{% else -%}
base::Callback<void()> callback = base::Callback<void()>(){##}
{% endif %});
+ {# If the command has no return value, generate a convenience method that #}
+ {# accepts a base::Callback<void()> together with the parameters object. #}
+ {% if not command.get("returns", []) %}
+ void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Callback<void()> callback);
+ {% endif %}
{% endif %}
{% endmacro %}
« no previous file with comments | « headless/lib/browser/domain_cc.template ('k') | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698