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

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

Issue 1906503002: headless: Implement convenience overloads for DevTools commands (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | headless/lib/browser/domain_h.template » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/domain_cc.template
diff --git a/headless/lib/browser/domain_cc.template b/headless/lib/browser/domain_cc.template
index 26ee01b1974d0a112a0b2e1b9e56d640453adf86..9a99bdec8e1169b977542169f7150677afafd78d 100644
--- a/headless/lib/browser/domain_cc.template
+++ b/headless/lib/browser/domain_cc.template
@@ -28,12 +28,41 @@ void Domain::{{method_name}}(std::unique_ptr<{{method_name}}Params> params, base
dispatcher_->SendMessage("{{domain.domain}}.{{command.name}}", params->Serialize(), std::move(callback));
{% elif "returns" in command %}
void Domain::{{method_name}}(base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback) {
- dispatcher_->SendMessage("{{domain.domain}}.{{command.name}}", base::Bind(&Domain::Handle{{method_name}}Response, callback));
+ dispatcher_->SendMessage("{{domain.domain}}.{{command.name}}", base::Bind(&Domain::Handle{{method_name}}Response, std::move(callback)));
{% else %}
void Domain::{{method_name}}(base::Callback<void()> callback) {
dispatcher_->SendMessage("{{domain.domain}}.{{command.name}}", std::move(callback));
{% endif %}
}
+ {# Generate convenience methods that take the required parameters directly. #}
+ {% if not "parameters" in command %}{% continue %}{% endif %}
+
+void Domain::{{method_name}}({##}
+ {% for parameter in command.parameters -%}
+ {% if parameter.get("optional", False) -%}
+ {% break %}
+ {% endif %}
+ {% 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 -%}
+ base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback{##}
+ {% else -%}
+ base::Callback<void()> callback{##}
+ {% endif %}) {
+ {# Build the parameters object. #}
+ std::unique_ptr<{{method_name}}Params> params = {{method_name}}Params::Builder()
+ {% for parameter in command.parameters -%}
+ {% if parameter.get("optional", False) -%}
+ {% break %}
+ {% endif %}
+ .Set{{parameter.name | to_title_case}}(std::move({{parameter.name | camelcase_to_hacker_style}}))
+ {% endfor %}
+ .Build();
+ {# Send the message. #}
+ {{method_name}}(std::move(params), std::move(callback));
+}
{% endfor %}
{# Generate response handlers for commands that need them. #}
« no previous file with comments | « no previous file | headless/lib/browser/domain_h.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698