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 {%- if new_style(domain) -%} |
| 200 Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} |
| 201 {%- else -%} |
199 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}
} | 202 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}
} |
200 {%- else -%} | 203 {%- endif -%} |
| 204 {%- else -%} |
201 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 205 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
202 {%- endif -%} | 206 {%- endif -%} |
203 {%- if not loop.last -%}, {% endif -%} | 207 {%- if not loop.last -%}, {% endif -%} |
204 {%- endfor -%} | 208 {%- endfor -%} |
205 ) = 0; | 209 ) = 0; |
| 210 {% if new_style(domain) %} |
| 211 virtual void sendFailure(const DispatchResponse&) = 0; |
| 212 {% else %} |
| 213 virtual void sendFailure(const ErrorString&) = 0; |
| 214 {% endif %} |
206 }; | 215 }; |
207 {% endif %} | 216 {% endif %} |
| 217 {%- if not("async" in command) and new_style(domain) %} |
| 218 virtual DispatchResponse {{command.name}}( |
| 219 {%- else %} |
208 virtual void {{command.name}}( | 220 virtual void {{command.name}}( |
209 {%- if not("async" in command) -%} | 221 {%- endif %} |
| 222 {%- if not("async" in command) and not new_style(domain) -%} |
210 ErrorString* | 223 ErrorString* |
211 {%- endif -%} | 224 {%- endif -%} |
212 {%- for parameter in command.parameters -%} | 225 {%- for parameter in command.parameters -%} |
213 {%- if (not loop.first) or not("async" in command) -%}, {% endif -%} | 226 {%- if (not loop.first) or (not ("async" in command) and not new_style(dom
ain)) -%}, {% endif -%} |
214 {%- if "optional" in parameter -%} | 227 {%- if "optional" in parameter -%} |
| 228 {%- if new_style(domain) -%} |
| 229 Maybe<{{resolve_type(parameter).raw_type}}> in_{{parameter.name}} |
| 230 {%- else -%} |
215 const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} | 231 const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} |
216 {%- else -%} | 232 {%- endif -%} |
| 233 {%- else -%} |
217 {{resolve_type(parameter).pass_type}} in_{{parameter.name}} | 234 {{resolve_type(parameter).pass_type}} in_{{parameter.name}} |
218 {%- endif -%} | 235 {%- endif -%} |
219 {%- endfor -%} | 236 {%- endfor -%} |
220 {%- if "async" in command -%} | 237 {%- if "async" in command -%} |
221 {%- if command.parameters -%}, {% endif -%} | 238 {%- if command.parameters -%}, {% endif -%} |
222 std::unique_ptr<{{command.name | to_title_case}}Callback> callback | 239 std::unique_ptr<{{command.name | to_title_case}}Callback> callback |
223 {%- else -%} | 240 {%- else -%} |
224 {%- for parameter in command.returns -%} | 241 {%- for parameter in command.returns -%} |
| 242 {%- if (not loop.first) or command.parameters or not new_style(domain) -
%}, {% endif -%} |
225 {%- if "optional" in parameter -%} | 243 {%- if "optional" in parameter -%} |
226 , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}} | 244 Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}} |
227 {%- else -%} | 245 {%- else -%} |
228 , {{resolve_type(parameter).type}}* out_{{parameter.name}} | 246 {{resolve_type(parameter).type}}* out_{{parameter.name}} |
229 {%- endif -%} | 247 {%- endif -%} |
230 {%- endfor -%} | 248 {%- endfor -%} |
231 {%- endif -%} | 249 {%- endif -%} |
232 ) = 0; | 250 ) = 0; |
233 {% endfor %} | 251 {% endfor %} |
234 | 252 |
235 {% if not has_disable(domain.commands) %} | 253 {% if not has_disable(domain.commands) %} |
| 254 {% if new_style(domain) %} |
| 255 virtual DispatchResponse disable() |
| 256 { |
| 257 return DispatchResponse::OK(); |
| 258 } |
| 259 {% else %} |
236 virtual void disable(ErrorString*) { } | 260 virtual void disable(ErrorString*) { } |
| 261 {% endif %} |
237 {% endif %} | 262 {% endif %} |
| 263 |
| 264 // TODO(dgozman): remove once all domains migrated. |
| 265 static void disableMe(Backend* backend) |
| 266 { |
| 267 {% if new_style(domain) %} |
| 268 backend->disable(); |
| 269 {% else %} |
| 270 ErrorString error; |
| 271 backend->disable(&error); |
| 272 {% endif %} |
| 273 } |
238 }; | 274 }; |
239 | 275 |
240 // ------------- Frontend interface. | 276 // ------------- Frontend interface. |
241 | 277 |
242 class {{config.protocol.export_macro}} Frontend { | 278 class {{config.protocol.export_macro}} Frontend { |
243 public: | 279 public: |
244 Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChann
el) { } | 280 Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChann
el) { } |
245 {% for event in domain.events %} | 281 {% for event in domain.events %} |
246 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con
tinue %}{% endif %} | 282 {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% con
tinue %}{% endif %} |
247 void {{event.name}}( | 283 void {{event.name}}( |
248 {%- for parameter in event.parameters -%} | 284 {%- for parameter in event.parameters -%} |
249 {%- if "optional" in parameter -%} | 285 {%- if "optional" in parameter -%} |
| 286 {%- if new_style(domain) -%} |
| 287 Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} = Maybe<{
{resolve_type(parameter).raw_type}}>() |
| 288 {%- else -%} |
250 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} =
Maybe<{{resolve_type(parameter).raw_type}}>() | 289 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} =
Maybe<{{resolve_type(parameter).raw_type}}>() |
| 290 {%- endif -%} |
251 {%- else -%} | 291 {%- else -%} |
252 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 292 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
253 {%- endif -%}{%- if not loop.last -%}, {% endif -%} | 293 {%- endif -%}{%- if not loop.last -%}, {% endif -%} |
254 {%- endfor -%} | 294 {%- endfor -%} |
255 ); | 295 ); |
256 {% endfor %} | 296 {% endfor %} |
257 | 297 |
258 void flush(); | 298 void flush(); |
259 private: | 299 private: |
260 FrontendChannel* m_frontendChannel; | 300 FrontendChannel* m_frontendChannel; |
(...skipping 20 matching lines...) Expand all Loading... |
281 static const char commandPrefix[]; | 321 static const char commandPrefix[]; |
282 static const char version[]; | 322 static const char version[]; |
283 }; | 323 }; |
284 | 324 |
285 } // namespace {{domain.domain}} | 325 } // namespace {{domain.domain}} |
286 {% for namespace in config.protocol.namespace %} | 326 {% for namespace in config.protocol.namespace %} |
287 } // namespace {{namespace}} | 327 } // namespace {{namespace}} |
288 {% endfor %} | 328 {% endfor %} |
289 | 329 |
290 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) | 330 #endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_h) |
OLD | NEW |