Commit c61f983d authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

[snippets-internals] Fix Mojo Closure externs generation.

This CL adds an Interface type for concrete implementations to @implement
and makes the Mojo interface non-nullable to avoid needing an assert.

Bug: 836128
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ie2f1d07966f734a47c8bc724a11641d0cab67daf
Reviewed-on: https://chromium-review.googlesource.com/1088355
Commit-Queue: calamity <calamity@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567160}
parent 0f9ea91e
......@@ -7,7 +7,7 @@
/** @type {snippetsInternals.mojom.PageHandlerPtr} */
let pageHandler = null;
/** @type {snippetsInternals.mojom.PagePtr} */
/** @type {snippetsInternals.mojom.PageImpl} */
let page = null;
/* Javascript module for chrome://snippets-internals. */
......@@ -276,15 +276,11 @@ function setupEventListeners() {
}
/* Represents the js-side of the IPC link. Backend talks to this. */
// TODO (calamity): Add a closure interface.
class SnippetsInternalsPageImpl extends snippetsInternals.mojom.PagePtr {
/** @implements {snippetsInternals.mojom.PageImpl} */
class SnippetsInternalsPageImpl {
constructor(request) {
super();
const page = snippetsInternals.mojom.Page;
assert(page !== null);
this.binding_ = new mojo.Binding(page, this, request);
this.binding_ =
new mojo.Binding(snippetsInternals.mojom.Page, this, request);
}
/* Callback for when suggestions change on the backend. */
......
/** @implements {mojo.InterfacePtr} */
{{module.namespace}}.{{interface.name}}Ptr = class {
{% for method in interface.methods %}
{% macro generateInterfaceClass() -%}
class {
{%- for method in interface.methods %}
/**
{%- for parameter in method.parameters %}
* @param { {{parameter.kind|closure_type_with_nullability}} } {{parameter.name|sanitize_identifier}}
......@@ -9,16 +9,26 @@
* @return {Promise}
{%- endif %}
*/
{{method.name}}(
{{method.name}}(
{%- for parameter in method.parameters -%}
{{parameter.name|sanitize_identifier}}{% if not loop.last %}, {% endif %}
{%- endfor -%}
) {}
{%- endfor %}
};
{%- endmacro %}
/**
* @const
* @type { mojo.Interface };
* @type { !mojo.Interface };
*/
{{module.namespace}}.{{interface.name}};
/** @interface */
{{module.namespace}}.{{interface.name}}Impl = {{ generateInterfaceClass() }}
/**
* @implements { mojo.InterfacePtr }
* @implements { {{module.namespace}}.{{interface.name}}Impl }
*/
{{module.namespace}}.{{interface.name}}Ptr = {{ generateInterfaceClass() }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment