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 {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h | 7 #ifndef {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h |
8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h | 8 #define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h |
9 | 9 |
10 {% if config.protocol.export_header %} | 10 {% if config.protocol.export_header %} |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // ------------- Backend interface. | 184 // ------------- Backend interface. |
185 | 185 |
186 class {{config.protocol.export_macro}} Backend { | 186 class {{config.protocol.export_macro}} Backend { |
187 public: | 187 public: |
188 virtual ~Backend() { } | 188 virtual ~Backend() { } |
189 | 189 |
190 {% for command in domain.commands %} | 190 {% for command in domain.commands %} |
191 {% if "redirect" in command %}{% continue %}{% endif %} | 191 {% if "redirect" in command %}{% continue %}{% endif %} |
192 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}
{% continue %}{% endif %} | 192 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}
{% continue %}{% endif %} |
193 {% if "async" in command %} | 193 {% if "async" in command %} |
194 class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callb
ack : public BackendCallback { | 194 class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callb
ack { |
195 public: | 195 public: |
196 virtual void sendSuccess( | 196 virtual void sendSuccess( |
197 {%- for parameter in command.returns -%} | 197 {%- for parameter in command.returns -%} |
198 {%- if "optional" in parameter -%} | 198 {%- if "optional" in parameter -%} |
199 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}
} | 199 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}
} |
200 {%- else -%} | 200 {%- else -%} |
201 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 201 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
202 {%- endif -%} | 202 {%- endif -%} |
203 {%- if not loop.last -%}, {% endif -%} | 203 {%- if not loop.last -%}, {% endif -%} |
204 {%- endfor -%} | 204 {%- endfor -%} |
205 ) = 0; | 205 ) = 0; |
| 206 {% if new_style(domain) %} |
| 207 virtual void sendFailure(const DispatchResponse&) = 0; |
| 208 {% else %} |
| 209 virtual void sendFailure(const ErrorString&) = 0; |
| 210 {% endif %} |
206 }; | 211 }; |
207 {% endif %} | 212 {% endif %} |
| 213 {%- if not("async" in command) and new_style(domain) %} |
| 214 virtual DispatchResponse {{command.name}}( |
| 215 {%- else %} |
208 virtual void {{command.name}}( | 216 virtual void {{command.name}}( |
209 {%- if not("async" in command) -%} | 217 {%- endif %} |
| 218 {%- if not("async" in command) and not new_style(domain) -%} |
210 ErrorString* | 219 ErrorString* |
211 {%- endif -%} | 220 {%- endif -%} |
212 {%- for parameter in command.parameters -%} | 221 {%- for parameter in command.parameters -%} |
213 {%- if (not loop.first) or not("async" in command) -%}, {% endif -%} | 222 {%- if (not loop.first) or (not ("async" in command) and not new_style(dom
ain)) -%}, {% endif -%} |
214 {%- if "optional" in parameter -%} | 223 {%- if "optional" in parameter -%} |
215 const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} | 224 const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} |
216 {%- else -%} | 225 {%- else -%} |
217 {{resolve_type(parameter).pass_type}} in_{{parameter.name}} | 226 {{resolve_type(parameter).pass_type}} in_{{parameter.name}} |
218 {%- endif -%} | 227 {%- endif -%} |
219 {%- endfor -%} | 228 {%- endfor -%} |
220 {%- if "async" in command -%} | 229 {%- if "async" in command -%} |
221 {%- if command.parameters -%}, {% endif -%} | 230 {%- if command.parameters -%}, {% endif -%} |
222 std::unique_ptr<{{command.name | to_title_case}}Callback> callback | 231 std::unique_ptr<{{command.name | to_title_case}}Callback> callback |
223 {%- else -%} | 232 {%- else -%} |
224 {%- for parameter in command.returns -%} | 233 {%- for parameter in command.returns -%} |
| 234 {%- if (not loop.first) or command.parameters or not new_style(domain) -
%}, {% endif -%} |
225 {%- if "optional" in parameter -%} | 235 {%- if "optional" in parameter -%} |
226 , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}} | 236 Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}} |
227 {%- else -%} | 237 {%- else -%} |
228 , {{resolve_type(parameter).type}}* out_{{parameter.name}} | 238 {{resolve_type(parameter).type}}* out_{{parameter.name}} |
229 {%- endif -%} | 239 {%- endif -%} |
230 {%- endfor -%} | 240 {%- endfor -%} |
231 {%- endif -%} | 241 {%- endif -%} |
232 ) = 0; | 242 ) = 0; |
233 {% endfor %} | 243 {% endfor %} |
234 | 244 |
235 {% if not has_disable(domain.commands) %} | 245 {% if not has_disable(domain.commands) %} |
| 246 {% if new_style(domain) %} |
| 247 virtual DispatchResponse disable() |
| 248 { |
| 249 return DispatchResponse::OK(); |
| 250 } |
| 251 {% else %} |
236 virtual void disable(ErrorString*) { } | 252 virtual void disable(ErrorString*) { } |
| 253 {% endif %} |
237 {% endif %} | 254 {% endif %} |
| 255 |
| 256 // TODO(dgozman): remove once all domains migrated. |
| 257 static void disableMe(Backend* backend) |
| 258 { |
| 259 {% if new_style(domain) %} |
| 260 backend->disable(); |
| 261 {% else %} |
| 262 ErrorString error; |
| 263 backend->disable(&error); |
| 264 {% endif %} |
| 265 } |
238 }; | 266 }; |
239 | 267 |
240 // ------------- Frontend interface. | 268 // ------------- Frontend interface. |
241 | 269 |
242 class {{config.protocol.export_macro}} Frontend { | 270 class {{config.protocol.export_macro}} Frontend { |
243 public: | 271 public: |
244 Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChann
el) { } | 272 Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChann
el) { } |
245 {% for event in domain.events %} | 273 {% for event in domain.events %} |
246 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con
tinue %}{% endif %} | 274 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con
tinue %}{% endif %} |
247 void {{event.name}}( | 275 void {{event.name}}( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 static const char commandPrefix[]; | 309 static const char commandPrefix[]; |
282 static const char version[]; | 310 static const char version[]; |
283 }; | 311 }; |
284 | 312 |
285 } // namespace {{domain.domain}} | 313 } // namespace {{domain.domain}} |
286 {% for namespace in config.protocol.namespace %} | 314 {% for namespace in config.protocol.namespace %} |
287 } // namespace {{namespace}} | 315 } // namespace {{namespace}} |
288 {% endfor %} | 316 {% endfor %} |
289 | 317 |
290 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) | 318 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) |
OLD | NEW |