OLD | NEW |
1 // This file is generated | 1 // This file is generated |
2 | 2 |
3 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 3 // Copyright (c) 2016 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 #ifndef HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style | up
per}}_H_ | 7 #ifndef HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style | up
per}}_H_ |
8 #define HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style | up
per}}_H_ | 8 #define HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style | up
per}}_H_ |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "headless/public/domains/types.h" | 13 #include "headless/public/domains/types.h" |
14 #include "headless/public/headless_export.h" | 14 #include "headless/public/headless_export.h" |
15 #include "headless/public/internal/message_dispatcher.h" | 15 #include "headless/public/internal/message_dispatcher.h" |
16 | 16 |
17 {# Macro for defining a member function for a given command. #} | 17 {# Macro for defining a member function for a given command. #} |
18 {% macro command_decl(command) %} | 18 {% macro command_decl(command) %} |
19 {% set method_name = command.name | to_title_case %} | 19 {% set method_name = command.name | to_title_case %} |
20 {% if command.description %} | 20 {% if command.description %} |
21 // {{ command.description }} | 21 // {{ command.description }} |
22 {% endif %} | 22 {% endif %} |
23 {% if "parameters" in command and "returns" in command %} | |
24 void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Call
back<void(std::unique_ptr<{{method_name}}Result>)> callback = base::Callback<voi
d(std::unique_ptr<{{method_name}}Result>)>()); | 23 void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Call
back<void(std::unique_ptr<{{method_name}}Result>)> callback = base::Callback<voi
d(std::unique_ptr<{{method_name}}Result>)>()); |
25 {% elif "parameters" in command %} | |
26 void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Call
back<void()> callback = base::Callback<void()>()); | |
27 {% elif "returns" in command %} | |
28 void {{method_name}}(base::Callback<void(std::unique_ptr<{{method_name}}Result
>)> callback = base::Callback<void(std::unique_ptr<{{method_name}}Result>)>()); | |
29 {% else %} | |
30 void {{method_name}}(base::Callback<void()> callback = base::Callback<void()>(
)); | |
31 {% endif %} | |
32 {# Generate convenience methods that take the required parameters directly. #} | 24 {# Generate convenience methods that take the required parameters directly. #} |
33 {# Don't generate these for experimental commands. #} | 25 {# Don't generate these for experimental commands. #} |
34 {% if "parameters" in command and not command.experimental %} | 26 {% if "parameters" in command and not command.experimental %} |
35 void {{method_name}}({##} | 27 void {{method_name}}({##} |
36 {% for parameter in command.parameters -%} | 28 {% for parameter in command.parameters -%} |
37 {% if parameter.get("optional", False) -%} | 29 {% if parameter.get("optional", False) -%} |
38 {% break %} | 30 {% break %} |
39 {% endif %} | 31 {% endif %} |
40 {% if not loop.first %}, {% endif %} | 32 {% if not loop.first %}, {% endif %} |
41 {{resolve_type(parameter).pass_type}} {{parameter.name | camelcase_to_hacker_sty
le -}} | 33 {{resolve_type(parameter).pass_type}} {{parameter.name | camelcase_to_hacker_sty
le -}} |
42 {% endfor %} | 34 {% endfor %} |
43 {% if "parameters" in command and not command.parameters[0].get("optional",
False) %}, {% endif %}{# -#} | 35 {% if command.get("parameters", []) and not command.parameters[0].get("optio
nal", False) %}, {% endif %}{# -#} |
44 {% if "returns" in command -%} | 36 {% if command.get("returns", []) -%} |
45 base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback = ba
se::Callback<void(std::unique_ptr<{{method_name}}Result>)>(){##} | 37 base::Callback<void(std::unique_ptr<{{method_name}}Result>)> callback = ba
se::Callback<void(std::unique_ptr<{{method_name}}Result>)>(){##} |
46 {% else -%} | 38 {% else -%} |
47 base::Callback<void()> callback = base::Callback<void()>(){##} | 39 base::Callback<void()> callback = base::Callback<void()>(){##} |
48 {% endif %}); | 40 {% endif %}); |
| 41 {# If the command has no return value, generate a convenience method that #} |
| 42 {# accepts a base::Callback<void()> together with the parameters object. #} |
| 43 {% if not command.get("returns", []) %} |
| 44 void {{method_name}}(std::unique_ptr<{{method_name}}Params> params, base::Call
back<void()> callback); |
| 45 {% endif %} |
49 {% endif %} | 46 {% endif %} |
50 {% endmacro %} | 47 {% endmacro %} |
51 | 48 |
52 namespace headless { | 49 namespace headless { |
53 namespace {{domain.domain | camelcase_to_hacker_style}} { | 50 namespace {{domain.domain | camelcase_to_hacker_style}} { |
54 class ExperimentalDomain; | 51 class ExperimentalDomain; |
55 class ExperimentalObserver; | 52 class ExperimentalObserver; |
56 {% if "events" in domain %} | 53 {% if "events" in domain %} |
57 | 54 |
58 class HEADLESS_EXPORT ExperimentalObserver { | 55 class HEADLESS_EXPORT ExperimentalObserver { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 {% endfor %} | 146 {% endfor %} |
150 | 147 |
151 private: | 148 private: |
152 DISALLOW_COPY_AND_ASSIGN(ExperimentalDomain); | 149 DISALLOW_COPY_AND_ASSIGN(ExperimentalDomain); |
153 }; | 150 }; |
154 | 151 |
155 } // namespace {{domain.domain | camelcase_to_hacker_style}} | 152 } // namespace {{domain.domain | camelcase_to_hacker_style}} |
156 } // namespace headless | 153 } // namespace headless |
157 | 154 |
158 #endif // HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style |
upper}}_H_ | 155 #endif // HEADLESS_PUBLIC_DOMAINS_{{domain.domain | camelcase_to_hacker_style |
upper}}_H_ |
OLD | NEW |