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 @@ ...@@ -7,7 +7,7 @@
/** @type {snippetsInternals.mojom.PageHandlerPtr} */ /** @type {snippetsInternals.mojom.PageHandlerPtr} */
let pageHandler = null; let pageHandler = null;
/** @type {snippetsInternals.mojom.PagePtr} */ /** @type {snippetsInternals.mojom.PageImpl} */
let page = null; let page = null;
/* Javascript module for chrome://snippets-internals. */ /* Javascript module for chrome://snippets-internals. */
...@@ -276,15 +276,11 @@ function setupEventListeners() { ...@@ -276,15 +276,11 @@ function setupEventListeners() {
} }
/* Represents the js-side of the IPC link. Backend talks to this. */ /* Represents the js-side of the IPC link. Backend talks to this. */
// TODO (calamity): Add a closure interface. /** @implements {snippetsInternals.mojom.PageImpl} */
class SnippetsInternalsPageImpl extends snippetsInternals.mojom.PagePtr { class SnippetsInternalsPageImpl {
constructor(request) { constructor(request) {
super(); this.binding_ =
new mojo.Binding(snippetsInternals.mojom.Page, this, request);
const page = snippetsInternals.mojom.Page;
assert(page !== null);
this.binding_ = new mojo.Binding(page, this, request);
} }
/* Callback for when suggestions change on the backend. */ /* Callback for when suggestions change on the backend. */
......
/** @implements {mojo.InterfacePtr} */ {% macro generateInterfaceClass() -%}
{{module.namespace}}.{{interface.name}}Ptr = class { class {
{% for method in interface.methods %} {%- for method in interface.methods %}
/** /**
{%- for parameter in method.parameters %} {%- for parameter in method.parameters %}
* @param { {{parameter.kind|closure_type_with_nullability}} } {{parameter.name|sanitize_identifier}} * @param { {{parameter.kind|closure_type_with_nullability}} } {{parameter.name|sanitize_identifier}}
...@@ -9,16 +9,26 @@ ...@@ -9,16 +9,26 @@
* @return {Promise} * @return {Promise}
{%- endif %} {%- endif %}
*/ */
{{method.name}}( {{method.name}}(
{%- for parameter in method.parameters -%} {%- for parameter in method.parameters -%}
{{parameter.name|sanitize_identifier}}{% if not loop.last %}, {% endif %} {{parameter.name|sanitize_identifier}}{% if not loop.last %}, {% endif %}
{%- endfor -%} {%- endfor -%}
) {} ) {}
{%- endfor %} {%- endfor %}
}; };
{%- endmacro %}
/** /**
* @const * @const
* @type { mojo.Interface }; * @type { !mojo.Interface };
*/ */
{{module.namespace}}.{{interface.name}}; {{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