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

Unified Diff: mojo/dart/packages/_mojo_for_test_only/lib/sample/sample_factory.mojom.dart

Issue 1964193002: Dart: Refactors Proxies (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments 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_for_test_only/lib/sample/sample_factory.mojom.dart
diff --git a/mojo/dart/packages/_mojo_for_test_only/lib/sample/sample_factory.mojom.dart b/mojo/dart/packages/_mojo_for_test_only/lib/sample/sample_factory.mojom.dart
index 46a28ba12e765cfe8f73f26605c28628ab3c2d8c..59f7373408324826bf5b4e6af82450b67cfa0af3 100644
--- a/mojo/dart/packages/_mojo_for_test_only/lib/sample/sample_factory.mojom.dart
+++ b/mojo/dart/packages/_mojo_for_test_only/lib/sample/sample_factory.mojom.dart
@@ -1103,24 +1103,22 @@ abstract class NamedObject {
}
-class _NamedObjectProxyImpl extends bindings.Proxy {
- _NamedObjectProxyImpl.fromEndpoint(
+class _NamedObjectProxyControl extends bindings.ProxyMessageHandler
+ implements bindings.ProxyControl {
+ _NamedObjectProxyControl.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
- _NamedObjectProxyImpl.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
+ _NamedObjectProxyControl.fromHandle(
+ core.MojoHandle handle) : super.fromHandle(handle);
- _NamedObjectProxyImpl.unbound() : super.unbound();
-
- static _NamedObjectProxyImpl newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) {
- assert(endpoint.setDescription("For _NamedObjectProxyImpl"));
- return new _NamedObjectProxyImpl.fromEndpoint(endpoint);
- }
+ _NamedObjectProxyControl.unbound() : super.unbound();
service_describer.ServiceDescription get serviceDescription =>
- new _NamedObjectServiceDescription();
+ new _NamedObjectServiceDescription();
+
+ String get serviceName => NamedObject.serviceName;
+ @override
void handleResponse(bindings.ServiceMessage message) {
switch (message.header.type) {
case _namedObjectMethodGetNameName:
@@ -1150,59 +1148,30 @@ class _NamedObjectProxyImpl extends bindings.Proxy {
}
}
+ @override
String toString() {
var superString = super.toString();
- return "_NamedObjectProxyImpl($superString)";
+ return "_NamedObjectProxyControl($superString)";
}
}
-class _NamedObjectProxyCalls implements NamedObject {
- _NamedObjectProxyImpl _proxyImpl;
-
- _NamedObjectProxyCalls(this._proxyImpl);
- void setName(String name) {
- if (!_proxyImpl.isBound) {
- _proxyImpl.proxyError("The Proxy is closed.");
- return;
- }
- var params = new _NamedObjectSetNameParams();
- params.name = name;
- _proxyImpl.sendMessage(params, _namedObjectMethodSetNameName);
- }
- dynamic getName([Function responseFactory = null]) {
- var params = new _NamedObjectGetNameParams();
- return _proxyImpl.sendMessageWithRequestId(
- params,
- _namedObjectMethodGetNameName,
- -1,
- bindings.MessageHeader.kMessageExpectsResponse);
- }
-}
-
-
-class NamedObjectProxy implements bindings.ProxyBase {
- final bindings.Proxy impl;
- NamedObject ptr;
-
- NamedObjectProxy(_NamedObjectProxyImpl proxyImpl) :
- impl = proxyImpl,
- ptr = new _NamedObjectProxyCalls(proxyImpl);
-
+class NamedObjectProxy extends bindings.Proxy
+ implements NamedObject {
NamedObjectProxy.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) :
- impl = new _NamedObjectProxyImpl.fromEndpoint(endpoint) {
- ptr = new _NamedObjectProxyCalls(impl);
- }
+ core.MojoMessagePipeEndpoint endpoint)
+ : super(new _NamedObjectProxyControl.fromEndpoint(endpoint));
- NamedObjectProxy.fromHandle(core.MojoHandle handle) :
- impl = new _NamedObjectProxyImpl.fromHandle(handle) {
- ptr = new _NamedObjectProxyCalls(impl);
- }
+ NamedObjectProxy.fromHandle(core.MojoHandle handle)
+ : super(new _NamedObjectProxyControl.fromHandle(handle));
- NamedObjectProxy.unbound() :
- impl = new _NamedObjectProxyImpl.unbound() {
- ptr = new _NamedObjectProxyCalls(impl);
+ NamedObjectProxy.unbound()
+ : super(new _NamedObjectProxyControl.unbound());
+
+ static NamedObjectProxy newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) {
+ assert(endpoint.setDescription("For NamedObjectProxy"));
+ return new NamedObjectProxy.fromEndpoint(endpoint);
}
factory NamedObjectProxy.connectToService(
@@ -1212,30 +1181,24 @@ class NamedObjectProxy implements bindings.ProxyBase {
return p;
}
- static NamedObjectProxy newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) {
- assert(endpoint.setDescription("For NamedObjectProxy"));
- return new NamedObjectProxy.fromEndpoint(endpoint);
- }
-
- String get serviceName => NamedObject.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);
+ void setName(String name) {
+ if (!ctrl.isBound) {
+ ctrl.proxyError("The Proxy is closed.");
+ return;
+ }
+ var params = new _NamedObjectSetNameParams();
+ params.name = name;
+ ctrl.sendMessage(params,
+ _namedObjectMethodSetNameName);
}
-
- String toString() {
- return "NamedObjectProxy($impl)";
+ dynamic getName([Function responseFactory = null]) {
+ var params = new _NamedObjectGetNameParams();
+ return ctrl.sendMessageWithRequestId(
+ params,
+ _namedObjectMethodGetNameName,
+ -1,
+ bindings.MessageHeader.kMessageExpectsResponse);
}
}
@@ -1374,24 +1337,22 @@ abstract class Factory {
}
-class _FactoryProxyImpl extends bindings.Proxy {
- _FactoryProxyImpl.fromEndpoint(
+class _FactoryProxyControl extends bindings.ProxyMessageHandler
+ implements bindings.ProxyControl {
+ _FactoryProxyControl.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
- _FactoryProxyImpl.fromHandle(core.MojoHandle handle) :
- super.fromHandle(handle);
+ _FactoryProxyControl.fromHandle(
+ core.MojoHandle handle) : super.fromHandle(handle);
- _FactoryProxyImpl.unbound() : super.unbound();
-
- static _FactoryProxyImpl newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) {
- assert(endpoint.setDescription("For _FactoryProxyImpl"));
- return new _FactoryProxyImpl.fromEndpoint(endpoint);
- }
+ _FactoryProxyControl.unbound() : super.unbound();
service_describer.ServiceDescription get serviceDescription =>
- new _FactoryServiceDescription();
+ new _FactoryServiceDescription();
+
+ String get serviceName => Factory.serviceName;
+ @override
void handleResponse(bindings.ServiceMessage message) {
switch (message.header.type) {
case _factoryMethodDoStuffName:
@@ -1481,88 +1442,30 @@ class _FactoryProxyImpl extends bindings.Proxy {
}
}
+ @override
String toString() {
var superString = super.toString();
- return "_FactoryProxyImpl($superString)";
+ return "_FactoryProxyControl($superString)";
}
}
-class _FactoryProxyCalls implements Factory {
- _FactoryProxyImpl _proxyImpl;
-
- _FactoryProxyCalls(this._proxyImpl);
- dynamic doStuff(Request request,core.MojoMessagePipeEndpoint pipe,[Function responseFactory = null]) {
- var params = new _FactoryDoStuffParams();
- params.request = request;
- params.pipe = pipe;
- return _proxyImpl.sendMessageWithRequestId(
- params,
- _factoryMethodDoStuffName,
- -1,
- bindings.MessageHeader.kMessageExpectsResponse);
- }
- dynamic doStuff2(core.MojoDataPipeConsumer pipe,[Function responseFactory = null]) {
- var params = new _FactoryDoStuff2Params();
- params.pipe = pipe;
- return _proxyImpl.sendMessageWithRequestId(
- params,
- _factoryMethodDoStuff2Name,
- -1,
- bindings.MessageHeader.kMessageExpectsResponse);
- }
- void createNamedObject(Object obj) {
- if (!_proxyImpl.isBound) {
- _proxyImpl.proxyError("The Proxy is closed.");
- return;
- }
- var params = new _FactoryCreateNamedObjectParams();
- params.obj = obj;
- _proxyImpl.sendMessage(params, _factoryMethodCreateNamedObjectName);
- }
- dynamic requestImportedInterface(Object obj,[Function responseFactory = null]) {
- var params = new _FactoryRequestImportedInterfaceParams();
- params.obj = obj;
- return _proxyImpl.sendMessageWithRequestId(
- params,
- _factoryMethodRequestImportedInterfaceName,
- -1,
- bindings.MessageHeader.kMessageExpectsResponse);
- }
- dynamic takeImportedInterface(Object obj,[Function responseFactory = null]) {
- var params = new _FactoryTakeImportedInterfaceParams();
- params.obj = obj;
- return _proxyImpl.sendMessageWithRequestId(
- params,
- _factoryMethodTakeImportedInterfaceName,
- -1,
- bindings.MessageHeader.kMessageExpectsResponse);
- }
-}
-
-
-class FactoryProxy implements bindings.ProxyBase {
- final bindings.Proxy impl;
- Factory ptr;
-
- FactoryProxy(_FactoryProxyImpl proxyImpl) :
- impl = proxyImpl,
- ptr = new _FactoryProxyCalls(proxyImpl);
-
+class FactoryProxy extends bindings.Proxy
+ implements Factory {
FactoryProxy.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) :
- impl = new _FactoryProxyImpl.fromEndpoint(endpoint) {
- ptr = new _FactoryProxyCalls(impl);
- }
+ core.MojoMessagePipeEndpoint endpoint)
+ : super(new _FactoryProxyControl.fromEndpoint(endpoint));
- FactoryProxy.fromHandle(core.MojoHandle handle) :
- impl = new _FactoryProxyImpl.fromHandle(handle) {
- ptr = new _FactoryProxyCalls(impl);
- }
+ FactoryProxy.fromHandle(core.MojoHandle handle)
+ : super(new _FactoryProxyControl.fromHandle(handle));
- FactoryProxy.unbound() :
- impl = new _FactoryProxyImpl.unbound() {
- ptr = new _FactoryProxyCalls(impl);
+ FactoryProxy.unbound()
+ : super(new _FactoryProxyControl.unbound());
+
+ static FactoryProxy newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) {
+ assert(endpoint.setDescription("For FactoryProxy"));
+ return new FactoryProxy.fromEndpoint(endpoint);
}
factory FactoryProxy.connectToService(
@@ -1572,30 +1475,53 @@ class FactoryProxy implements bindings.ProxyBase {
return p;
}
- static FactoryProxy newFromEndpoint(
- core.MojoMessagePipeEndpoint endpoint) {
- assert(endpoint.setDescription("For FactoryProxy"));
- return new FactoryProxy.fromEndpoint(endpoint);
- }
-
- String get serviceName => Factory.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 "FactoryProxy($impl)";
+ dynamic doStuff(Request request,core.MojoMessagePipeEndpoint pipe,[Function responseFactory = null]) {
+ var params = new _FactoryDoStuffParams();
+ params.request = request;
+ params.pipe = pipe;
+ return ctrl.sendMessageWithRequestId(
+ params,
+ _factoryMethodDoStuffName,
+ -1,
+ bindings.MessageHeader.kMessageExpectsResponse);
+ }
+ dynamic doStuff2(core.MojoDataPipeConsumer pipe,[Function responseFactory = null]) {
+ var params = new _FactoryDoStuff2Params();
+ params.pipe = pipe;
+ return ctrl.sendMessageWithRequestId(
+ params,
+ _factoryMethodDoStuff2Name,
+ -1,
+ bindings.MessageHeader.kMessageExpectsResponse);
+ }
+ void createNamedObject(Object obj) {
+ if (!ctrl.isBound) {
+ ctrl.proxyError("The Proxy is closed.");
+ return;
+ }
+ var params = new _FactoryCreateNamedObjectParams();
+ params.obj = obj;
+ ctrl.sendMessage(params,
+ _factoryMethodCreateNamedObjectName);
+ }
+ dynamic requestImportedInterface(Object obj,[Function responseFactory = null]) {
+ var params = new _FactoryRequestImportedInterfaceParams();
+ params.obj = obj;
+ return ctrl.sendMessageWithRequestId(
+ params,
+ _factoryMethodRequestImportedInterfaceName,
+ -1,
+ bindings.MessageHeader.kMessageExpectsResponse);
+ }
+ dynamic takeImportedInterface(Object obj,[Function responseFactory = null]) {
+ var params = new _FactoryTakeImportedInterfaceParams();
+ params.obj = obj;
+ return ctrl.sendMessageWithRequestId(
+ params,
+ _factoryMethodTakeImportedInterfaceName,
+ -1,
+ bindings.MessageHeader.kMessageExpectsResponse);
}
}
@@ -1804,7 +1730,7 @@ mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() {
// serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of
// a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this
// file. The string contains the base64 encoding of the gzip-compressed bytes.
- var serializedRuntimeTypeInfo = "H4sIAAAJbogC/+xaSZPbRBTW4qmYJYknU8QiJDMekgyZohiZcMA1p1RBSFJUQQpzIMVhxkubaIgsIcmUuXHMT+DIkZ+QI8f8jBw55pgbtKzXdrvVrcXR5mBVdbWlkab7ff19771eNCm4GlA/hZp93qHuZVzqcP8BLju4uD3TfoKOj7/pmWj4bf8MDTzu+9fhm+8fPbx78vXdR8fBh0fsd2z7z6C+hUsNlxbTrx+gtqHew6XJaeer3sCznN8S90P0f75Dv0yQ6836oXH/7trW2EX3ob++HSqDo3//fG8ZV+1w+b6jL+yWKLvJ9ZK5v8Pctxmc/oWLfY9cF3E5hwvB6TL+fWE+vnP4QuOzj8vbuPyISxcX/bFlIt2ZDC3TGCNHN60zS3edQfDDnvSfGAPdGHvIGfUGyNX7xnhojH9ydQ+j6upBcyejoLkj/yOTywuCy1VctuC3j5sC+NYoHLao9x8CIf8+D/zZDurnTT7eL6Ce1pLhLVF40/9PhPeXVtebjEYh+z4EW/LGtcXonth7qia307/aAjubYCvY+YkD+mHtJVcRPFKodk/lZTtpnW5xdCa6suKDCB+fD5cK5IPEtK8x/SR+MM5P8nCtReBaXwFXOQLXd6E927ARz4/4uH5aAK4NykfJnPioUX1WqPu89alBXxb6DOLXRp9hHdRn+uTjcx3yobL1SfpJ8pC4POWOIM8rWp8emno8ffq43ihQn5Ig3xXpU5QvaOpC71ngRMYVdHqbxelGyfnCrPHs/dFtkjCU5Y9YHqSNZ1n7obh45vPgoGC9KDF6kan3Wf78Q/xKSv50BPi8j8v2Mn8CRyeY31aJR3IJPBL5XZ9Hn1fM78qc+V9LMB9WUuCkUOMg4tMXDup5iF0lCON2syQ/TOw/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ei2ZHZUn4IcSE9dmdc45wkmOuox58zfrwDnZ/Y1onWG8EY9T2jpQUp/F1IGS2xH83oX38sKPrQeukbofsKs/dDHvFGVUKzpr3r0J+hsI9g2XQed54Za23qCUc73dXbhXVL0dDx+NDuQZ1DVpnPuk3YN1Rtd20VEAksfnTTA+LiDeqyAD4U2ZE2fUKdb9lSlw1G+w7l8Fn18EfrKs+2n/KYor23o2cYWtLyT5HVNWGNHT/ZzjCrteNtT5iCNrizgS2Q8pMo4k1X+S5/8PAAD//wmWKGaINQAA";
// Deserialize RuntimeTypeInfo
var bytes = BASE64.decode(serializedRuntimeTypeInfo);

Powered by Google App Engine
This is Rietveld 408576698