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

Unified Diff: templates/TypeBuilder_h.template

Issue 2468923002: [inspector_protocol] support fall through and moveable Maybe (Closed)
Patch Set: added missing std::move Created 4 years, 1 month 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 | « templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: templates/TypeBuilder_h.template
diff --git a/templates/TypeBuilder_h.template b/templates/TypeBuilder_h.template
index 553ba55f7c0de6956c1d0bf5900149a1a6c814b5..802a16fd657aa7de273a13ac44fa7f9fe5886cd5 100644
--- a/templates/TypeBuilder_h.template
+++ b/templates/TypeBuilder_h.template
@@ -191,41 +191,59 @@ public:
{% if "redirect" in command %}{% continue %}{% endif %}
{% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
{% if "async" in command %}
- class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callback : public BackendCallback {
+ class {{config.protocol.export_macro}} {{command.name | to_title_case}}Callback {
public:
virtual void sendSuccess(
- {%- for parameter in command.returns -%}
- {%- if "optional" in parameter -%}
+ {%- for parameter in command.returns -%}
+ {%- if "optional" in parameter -%}
+ {%- if new_style(domain) -%}
+ Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}}
+ {%- else -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}}
- {%- else -%}
+ {%- endif -%}
+ {%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
- {%- endif -%}
- {%- if not loop.last -%}, {% endif -%}
- {%- endfor -%}
+ {%- endif -%}
+ {%- if not loop.last -%}, {% endif -%}
+ {%- endfor -%}
) = 0;
+ {% if new_style(domain) %}
+ virtual void sendFailure(const DispatchResponse&) = 0;
+ {% else %}
+ virtual void sendFailure(const ErrorString&) = 0;
+ {% endif %}
};
{% endif %}
+ {%- if not("async" in command) and new_style(domain) %}
+ virtual DispatchResponse {{command.name}}(
+ {%- else %}
virtual void {{command.name}}(
- {%- if not("async" in command) -%}
+ {%- endif %}
+ {%- if not("async" in command) and not new_style(domain) -%}
ErrorString*
{%- endif -%}
{%- for parameter in command.parameters -%}
- {%- if (not loop.first) or not("async" in command) -%}, {% endif -%}
- {%- if "optional" in parameter -%}
- const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}}
+ {%- if (not loop.first) or (not ("async" in command) and not new_style(domain)) -%}, {% endif -%}
+ {%- if "optional" in parameter -%}
+ {%- if new_style(domain) -%}
+ Maybe<{{resolve_type(parameter).raw_type}}> in_{{parameter.name}}
{%- else -%}
- {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
+ const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}}
{%- endif -%}
+ {%- else -%}
+ {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
+ {%- endif -%}
{%- endfor -%}
{%- if "async" in command -%}
- {%- if command.parameters -%}, {% endif -%}
+ {%- if command.parameters -%}, {% endif -%}
std::unique_ptr<{{command.name | to_title_case}}Callback> callback
{%- else -%}
{%- for parameter in command.returns -%}
+ {%- if (not loop.first) or command.parameters or not new_style(domain) -%}, {% endif -%}
{%- if "optional" in parameter -%}
- , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
+ Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
{%- else -%}
- , {{resolve_type(parameter).type}}* out_{{parameter.name}}
+ {{resolve_type(parameter).type}}* out_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
@@ -233,8 +251,26 @@ public:
{% endfor %}
{% if not has_disable(domain.commands) %}
+ {% if new_style(domain) %}
+ virtual DispatchResponse disable()
+ {
+ return DispatchResponse::OK();
+ }
+ {% else %}
virtual void disable(ErrorString*) { }
+ {% endif %}
{% endif %}
+
+ // TODO(dgozman): remove once all domains migrated.
+ static void disableMe(Backend* backend)
+ {
+ {% if new_style(domain) %}
+ backend->disable();
+ {% else %}
+ ErrorString error;
+ backend->disable(&error);
+ {% endif %}
+ }
};
// ------------- Frontend interface.
@@ -247,7 +283,11 @@ public:
void {{event.name}}(
{%- for parameter in event.parameters -%}
{%- if "optional" in parameter -%}
+ {%- if new_style(domain) -%}
+ Maybe<{{resolve_type(parameter).raw_type}}> {{parameter.name}} = Maybe<{{resolve_type(parameter).raw_type}}>()
+ {%- else -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} = Maybe<{{resolve_type(parameter).raw_type}}>()
+ {%- endif -%}
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}{%- if not loop.last -%}, {% endif -%}
« no previous file with comments | « templates/TypeBuilder_cpp.template ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698