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

Unified Diff: mojo/services/public/js/service_provider.js

Issue 803173009: Mojo JS Bindings: Eliminate foo$ Stub and Proxy class members (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sync Created 5 years, 11 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/services/public/js/service_provider.js
diff --git a/mojo/services/public/js/service_provider.js b/mojo/services/public/js/service_provider.js
index 9ad0c5d14e529b960780024cd8ff9b2f922f4797..e8d491f9c5803821a574c725e57760b7b12107df 100644
--- a/mojo/services/public/js/service_provider.js
+++ b/mojo/services/public/js/service_provider.js
@@ -3,10 +3,13 @@
// found in the LICENSE file.
define("mojo/services/public/js/service_provider", [
+ "mojo/public/js/bindings",
"mojo/public/interfaces/application/service_provider.mojom",
"mojo/public/js/connection",
-], function(serviceProviderMojom, connection) {
+], function(bindings, serviceProviderMojom, connection) {
+ const ProxyBindings = bindings.ProxyBindings;
+ const StubBindings = bindings.StubBindings;
const ServiceProviderInterface = serviceProviderMojom.ServiceProvider;
function checkServiceProvider(sp) {
@@ -18,7 +21,8 @@ define("mojo/services/public/js/service_provider", [
constructor(service) {
if (!(service instanceof ServiceProviderInterface.proxyClass))
throw new Error("service must be a ServiceProvider proxy");
- service.local$ = this; // Implicitly sets this.remote$ to service.
+ this.proxy = service;
+ ProxyBindings(this.proxy).setLocalDelegate(this);
this.providers_ = new Map(); // serviceName => see provideService() below
this.pendingRequests_ = new Map(); // serviceName => serviceHandle
}
@@ -35,8 +39,9 @@ define("mojo/services/public/js/service_provider", [
}
var proxy = connection.bindProxyHandle(
serviceHandle, provider.service, provider.service.client);
- proxy.local$ = new provider.factory(proxy);
- provider.connections.push(proxy.connection$);
+ if (ProxyBindings(proxy).local)
+ ProxyBindings(proxy).setLocalDelegate(new provider.factory(proxy));
+ provider.connections.push(ProxyBindings(proxy).connection);
}
provideService(service, factory) {
@@ -64,12 +69,12 @@ define("mojo/services/public/js/service_provider", [
if (!clientImpl && interfaceObject.client)
throw new Error("Client implementation must be provided");
- if (!clientImpl)
- clientImpl = {};
+ var remoteProxy;
+ var clientFactory = function(x) {remoteProxy = x; return clientImpl;};
var messagePipeHandle = connection.bindProxyClient(
- clientImpl, interfaceObject.client, interfaceObject);
- this.remote$.connectToService(interfaceObject.name, messagePipeHandle);
- return clientImpl.remote$;
+ clientFactory, interfaceObject.client, interfaceObject);
+ this.proxy.connectToService(interfaceObject.name, messagePipeHandle);
+ return remoteProxy;
};
close() {
« no previous file with comments | « mojo/public/tools/bindings/generators/js_templates/module.sky.tmpl ('k') | mojo/services/public/js/shell.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698