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_DEVTOOLS_DOMAINS_{{domain.domain | camelcase_to_hacker_s
tyle | upper}}_H_ | 7 #ifndef HEADLESS_PUBLIC_DEVTOOLS_DOMAINS_{{domain.domain | camelcase_to_hacker_s
tyle | upper}}_H_ |
8 #define HEADLESS_PUBLIC_DEVTOOLS_DOMAINS_{{domain.domain | camelcase_to_hacker_s
tyle | upper}}_H_ | 8 #define HEADLESS_PUBLIC_DEVTOOLS_DOMAINS_{{domain.domain | camelcase_to_hacker_s
tyle | upper}}_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 {% for domain_name in domain.dependencies %} | 13 {% for domain_name in domain.dependencies %} |
14 #include "headless/public/devtools/domains/types_{{domain_name | camelcase_to_ha
cker_style}}.h" | 14 #include "headless/public/devtools/domains/types_{{domain_name | camelcase_to_ha
cker_style}}.h" |
15 {% endfor %} | 15 {% endfor %} |
16 #include "headless/public/headless_export.h" | 16 #include "headless/public/headless_export.h" |
17 #include "headless/public/internal/message_dispatcher.h" | 17 #include "headless/public/internal/message_dispatcher.h" |
18 | 18 |
19 {# Macro for defining a member function for a given command. #} | 19 {# Macro for defining a member function for a given command. #} |
20 {% macro command_decl(command) %} | 20 {% macro command_decl(command) %} |
21 {% set method_name = command.name | to_title_case %} | 21 {% set method_name = command.name | sanitize_literal | to_title_case %} |
22 {% if command.description %} | 22 {% if command.description %} |
23 // {{ command.description }} | 23 // {{ command.description }} |
24 {% endif %} | 24 {% endif %} |
25 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 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>)>()); |
26 {# Generate convenience methods that take the required parameters directly. #} | 26 {# Generate convenience methods that take the required parameters directly. #} |
27 {# Don't generate these for experimental commands. #} | 27 {# Don't generate these for experimental commands. #} |
28 {% if "parameters" in command and not command.experimental %} | 28 {% if "parameters" in command and not command.experimental %} |
29 void {{method_name}}({##} | 29 void {{method_name}}({##} |
30 {% for parameter in command.parameters -%} | 30 {% for parameter in command.parameters -%} |
31 {% if parameter.get("optional", False) -%} | 31 {% if parameter.get("optional", False) -%} |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 {% if command.experimental %}{% continue %}{% endif %} | 101 {% if command.experimental %}{% continue %}{% endif %} |
102 {{ command_decl(command) }} | 102 {{ command_decl(command) }} |
103 {% endfor %} | 103 {% endfor %} |
104 protected: | 104 protected: |
105 Domain(internal::MessageDispatcher* dispatcher); | 105 Domain(internal::MessageDispatcher* dispatcher); |
106 ~Domain(); | 106 ~Domain(); |
107 | 107 |
108 {# Generate response handlers for commands that need them. #} | 108 {# Generate response handlers for commands that need them. #} |
109 {% for command in domain.commands %} | 109 {% for command in domain.commands %} |
110 {% if not "returns" in command %}{% continue %}{% endif %} | 110 {% if not "returns" in command %}{% continue %}{% endif %} |
111 {% set method_name = command.name | to_title_case %} | 111 {% set method_name = command.name | sanitize_literal | to_title_case %} |
112 static void Handle{{method_name}}Response(base::Callback<void(std::unique_ptr<
{{method_name}}Result>)> callback, const base::Value& response); | 112 static void Handle{{method_name}}Response(base::Callback<void(std::unique_ptr<
{{method_name}}Result>)> callback, const base::Value& response); |
113 {% endfor %} | 113 {% endfor %} |
114 | 114 |
115 {# Generate event dispatchers. #} | 115 {# Generate event dispatchers. #} |
116 {% for event in domain.events %} | 116 {% for event in domain.events %} |
117 void Dispatch{{event.name | to_title_case}}Event(const base::Value& params); | 117 void Dispatch{{event.name | to_title_case}}Event(const base::Value& params); |
118 {% endfor %} | 118 {% endfor %} |
119 | 119 |
120 internal::MessageDispatcher* dispatcher_; // Not owned. | 120 internal::MessageDispatcher* dispatcher_; // Not owned. |
121 {% if "events" in domain %} | 121 {% if "events" in domain %} |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 {% endfor %} | 157 {% endfor %} |
158 | 158 |
159 private: | 159 private: |
160 DISALLOW_COPY_AND_ASSIGN(ExperimentalDomain); | 160 DISALLOW_COPY_AND_ASSIGN(ExperimentalDomain); |
161 }; | 161 }; |
162 | 162 |
163 } // namespace {{domain.domain | camelcase_to_hacker_style}} | 163 } // namespace {{domain.domain | camelcase_to_hacker_style}} |
164 } // namespace headless | 164 } // namespace headless |
165 | 165 |
166 #endif // HEADLESS_PUBLIC_DEVTOOLS_DOMAINS_{{domain.domain | camelcase_to_hacke
r_style | upper}}_H_ | 166 #endif // HEADLESS_PUBLIC_DEVTOOLS_DOMAINS_{{domain.domain | camelcase_to_hacke
r_style | upper}}_H_ |
OLD | NEW |