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

Unified Diff: mojo/dart/packages/mojo/lib/mojo/bindings/types/service_describer.mojom.dart

Issue 1948003003: Dart: Wait to handle events on a Stub until it makes sense to do it. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add test 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/bindings/types/service_describer.mojom.dart
diff --git a/mojo/dart/packages/mojo/lib/mojo/bindings/types/service_describer.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/bindings/types/service_describer.mojom.dart
index f6aa39196dd7d7418d0e1db9d2a792088ad7f2de..be58b3e8ff7eabe2f71cad74b4ab0f41cbfdf49b 100644
--- a/mojo/dart/packages/mojo/lib/mojo/bindings/types/service_describer.mojom.dart
+++ b/mojo/dart/packages/mojo/lib/mojo/bindings/types/service_describer.mojom.dart
@@ -686,14 +686,19 @@ class ServiceDescriberProxy implements bindings.ProxyBase {
class ServiceDescriberStub extends bindings.Stub {
- ServiceDescriber _impl = null;
+ ServiceDescriber _impl;
ServiceDescriberStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [ServiceDescriber impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- ServiceDescriberStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ ServiceDescriberStub.fromHandle(
+ core.MojoHandle handle, [ServiceDescriber impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
ServiceDescriberStub.unbound() : super.unbound();
@@ -711,7 +716,9 @@ class ServiceDescriberStub extends bindings.Stub {
0,
message);
}
- assert(_impl != null);
+ if (_impl == null) {
+ throw new core.MojoApiError("$this has no implementation set");
+ }
switch (message.header.type) {
case _serviceDescriberMethodDescribeServiceName:
var params = _ServiceDescriberDescribeServiceParams.deserialize(
@@ -727,10 +734,23 @@ class ServiceDescriberStub extends bindings.Stub {
ServiceDescriber get impl => _impl;
set impl(ServiceDescriber d) {
- assert(_impl == null);
+ if (d == null) {
+ throw new core.MojoApiError("$this: Cannot set a null implementation");
+ }
+ if (isBound && (_impl == null)) {
+ beginHandlingEvents();
+ }
_impl = d;
}
+ @override
+ void bind(core.MojoMessagePipeEndpoint endpoint) {
+ super.bind(endpoint);
+ if (!isOpen && (_impl != null)) {
+ beginHandlingEvents();
+ }
+ }
+
String toString() {
var superString = super.toString();
return "ServiceDescriberStub($superString)";
@@ -956,14 +976,19 @@ class ServiceDescriptionProxy implements bindings.ProxyBase {
class ServiceDescriptionStub extends bindings.Stub {
- ServiceDescription _impl = null;
+ ServiceDescription _impl;
ServiceDescriptionStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [ServiceDescription impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- ServiceDescriptionStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ ServiceDescriptionStub.fromHandle(
+ core.MojoHandle handle, [ServiceDescription impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
ServiceDescriptionStub.unbound() : super.unbound();
@@ -996,7 +1021,9 @@ class ServiceDescriptionStub extends bindings.Stub {
0,
message);
}
- assert(_impl != null);
+ if (_impl == null) {
+ throw new core.MojoApiError("$this has no implementation set");
+ }
switch (message.header.type) {
case _serviceDescriptionMethodGetTopLevelInterfaceName:
var response = _impl.getTopLevelInterface(_serviceDescriptionGetTopLevelInterfaceResponseParamsFactory);
@@ -1069,10 +1096,23 @@ class ServiceDescriptionStub extends bindings.Stub {
ServiceDescription get impl => _impl;
set impl(ServiceDescription d) {
- assert(_impl == null);
+ if (d == null) {
+ throw new core.MojoApiError("$this: Cannot set a null implementation");
+ }
+ if (isBound && (_impl == null)) {
+ beginHandlingEvents();
+ }
_impl = d;
}
+ @override
+ void bind(core.MojoMessagePipeEndpoint endpoint) {
+ super.bind(endpoint);
+ if (!isOpen && (_impl != null)) {
+ beginHandlingEvents();
+ }
+ }
+
String toString() {
var superString = super.toString();
return "ServiceDescriptionStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698