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

Unified Diff: mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart

Issue 1964193002: Dart: Refactors Proxies (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Cleanup Created 4 years, 7 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/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
diff --git a/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
index 887d18029040051b357734593395919aaf755fec..979c6fb86d2751f3934bdef7b475ca1fe53a505b 100644
--- a/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
+++ b/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
@@ -108,28 +108,26 @@ class _ServiceProviderServiceDescription implements service_describer.ServiceDes
abstract class ServiceProvider {
static const String serviceName = null;
- void connectToService(String interfaceName, core.MojoMessagePipeEndpoint pipe);
+ void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe);
}
-class _ServiceProviderProxyImpl extends bindings.Proxy {
- _ServiceProviderProxyImpl.fromEndpoint(
+class _ServiceProviderProxyControl extends bindings.ProxyMessageHandler
+ implements bindings.ProxyControl {
+ _ServiceProviderProxyControl.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
- _ServiceProviderProxyImpl.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
+ _ServiceProviderProxyControl.fromHandle(
+ core.MojoHandle handle) : super.fromHandle(handle);
- _ServiceProviderProxyImpl.unbound() : super.unbound();
-
- static _ServiceProviderProxyImpl newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) {
- assert(endpoint.setDescription("For _ServiceProviderProxyImpl"));
- return new _ServiceProviderProxyImpl.fromEndpoint(endpoint);
- }
+ _ServiceProviderProxyControl.unbound() : super.unbound();
service_describer.ServiceDescription get serviceDescription =>
- new _ServiceProviderServiceDescription();
+ new _ServiceProviderServiceDescription();
+
+ String get serviceName => ServiceProvider.serviceName;
+ @override
void handleResponse(bindings.ServiceMessage message) {
switch (message.header.type) {
default:
@@ -139,52 +137,30 @@ class _ServiceProviderProxyImpl extends bindings.Proxy {
}
}
+ @override
String toString() {
var superString = super.toString();
- return "_ServiceProviderProxyImpl($superString)";
+ return "_ServiceProviderProxyControl($superString)";
}
}
-class _ServiceProviderProxyCalls implements ServiceProvider {
- _ServiceProviderProxyImpl _proxyImpl;
-
- _ServiceProviderProxyCalls(this._proxyImpl);
- void connectToService(String interfaceName, core.MojoMessagePipeEndpoint pipe) {
- if (!_proxyImpl.isBound) {
- _proxyImpl.proxyError("The Proxy is closed.");
- return;
- }
- var params = new _ServiceProviderConnectToServiceParams();
- params.interfaceName = interfaceName;
- params.pipe = pipe;
- _proxyImpl.sendMessage(params, _serviceProviderMethodConnectToServiceName);
- }
-}
-
-
-class ServiceProviderProxy implements bindings.ProxyBase {
- final bindings.Proxy impl;
- ServiceProvider ptr;
-
- ServiceProviderProxy(_ServiceProviderProxyImpl proxyImpl) :
- impl = proxyImpl,
- ptr = new _ServiceProviderProxyCalls(proxyImpl);
-
+class ServiceProviderProxy extends bindings.Proxy
+ implements ServiceProvider {
ServiceProviderProxy.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) :
- impl = new _ServiceProviderProxyImpl.fromEndpoint(endpoint) {
- ptr = new _ServiceProviderProxyCalls(impl);
- }
+ core.MojoMessagePipeEndpoint endpoint)
+ : super(new _ServiceProviderProxyControl.fromEndpoint(endpoint));
- ServiceProviderProxy.fromHandle(core.MojoHandle handle) :
- impl = new _ServiceProviderProxyImpl.fromHandle(handle) {
- ptr = new _ServiceProviderProxyCalls(impl);
- }
+ ServiceProviderProxy.fromHandle(core.MojoHandle handle)
+ : super(new _ServiceProviderProxyControl.fromHandle(handle));
- ServiceProviderProxy.unbound() :
- impl = new _ServiceProviderProxyImpl.unbound() {
- ptr = new _ServiceProviderProxyCalls(impl);
+ ServiceProviderProxy.unbound()
+ : super(new _ServiceProviderProxyControl.unbound());
+
+ static ServiceProviderProxy newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) {
+ assert(endpoint.setDescription("For ServiceProviderProxy"));
+ return new ServiceProviderProxy.fromEndpoint(endpoint);
}
factory ServiceProviderProxy.connectToService(
@@ -194,30 +170,17 @@ class ServiceProviderProxy implements bindings.ProxyBase {
return p;
}
- static ServiceProviderProxy newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) {
- assert(endpoint.setDescription("For ServiceProviderProxy"));
- return new ServiceProviderProxy.fromEndpoint(endpoint);
- }
-
- String get serviceName => ServiceProvider.serviceName;
- Future close({bool immediate: false}) => impl.close(immediate: immediate);
-
- Future responseOrError(Future f) => impl.responseOrError(f);
-
- Future get errorFuture => impl.errorFuture;
-
- int get version => impl.version;
-
- Future<int> queryVersion() => impl.queryVersion();
-
- void requireVersion(int requiredVersion) {
- impl.requireVersion(requiredVersion);
- }
-
- String toString() {
- return "ServiceProviderProxy($impl)";
+ void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe) {
+ if (!ctrl.isBound) {
+ ctrl.proxyError("The Proxy is closed.");
+ return;
+ }
+ var params = new _ServiceProviderConnectToServiceParams();
+ params.interfaceName = interfaceName;
+ params.pipe = pipe;
+ ctrl.sendMessage(params,
+ _serviceProviderMethodConnectToServiceName);
}
}
@@ -260,7 +223,7 @@ class ServiceProviderStub extends bindings.Stub {
case _serviceProviderMethodConnectToServiceName:
var params = _ServiceProviderConnectToServiceParams.deserialize(
message.payload);
- _impl.connectToService(params.interfaceName, params.pipe);
+ _impl.connectToService_(params.interfaceName, params.pipe);
break;
default:
throw new bindings.MojoCodecError("Unexpected message name");

Powered by Google App Engine
This is Rietveld 408576698