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

Unified Diff: mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl

Issue 637373002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed the mojo_internals module, made Connection localFactory optional Created 6 years, 2 months 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
Index: mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
index 391d375e1e6688cc5ed04585dc75aef22ee6939e..1212dae59ffc259a6a61a9bcb34ef14514cf56ec 100644
--- a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
@@ -103,6 +103,24 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%}
}
};
+ function {{interface.name}}DelegatingStub() {
+ }
+
+ {{interface.name}}DelegatingStub.prototype =
+ Object.create({{interface.name}}Stub.prototype);
+
+ {{interface.name}}DelegatingStub.prototype.callDelegateMethod$ = function(methodName, args) {
+ var method = this.delegate$ && this.delegate$[methodName];
+ return method && method.apply(this.delegate$, args);
+ }
+
+{%- for method in interface.methods %}
+{%- set method_name = method.name|stylize_method %}
+ {{interface.name}}DelegatingStub.prototype.{{method_name}} = function() {
+ return this.callDelegateMethod$("{{method_name}}", arguments);
+ }
+{%- endfor %}
+
{#--- Validation #}
function validate{{interface.name}}Request(messageValidator) {
@@ -156,6 +174,7 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%}
name: '{{namespace|replace(".","::")}}::{{interface.name}}',
proxyClass: {{interface.name}}Proxy,
stubClass: {{interface.name}}Stub,
+ delegatingStubClass: {{interface.name}}DelegatingStub,
validateRequest: validate{{interface.name}}Request,
{%- if interface|has_callbacks %}
validateResponse: validate{{interface.name}}Response,
« no previous file with comments | « mojo/public/js/bindings/connection.js ('k') | mojo/public/tools/bindings/generators/js_templates/module.js.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698