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 %} |