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

Unified Diff: mojo/dart/packages/mojo/lib/mojo/service_provider.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/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 8dfdddcff6e1356c56727c1a0a897bb9d2ef1046..18d9420d1ed20d564754b58781f034720e6bead9 100644
--- a/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
+++ b/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
@@ -223,14 +223,19 @@ class ServiceProviderProxy implements bindings.ProxyBase {
class ServiceProviderStub extends bindings.Stub {
- ServiceProvider _impl = null;
+ ServiceProvider _impl;
ServiceProviderStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [ServiceProvider impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- ServiceProviderStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ ServiceProviderStub.fromHandle(
+ core.MojoHandle handle, [ServiceProvider impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
ServiceProviderStub.unbound() : super.unbound();
@@ -248,7 +253,9 @@ class ServiceProviderStub 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 _serviceProviderMethodConnectToServiceName:
var params = _ServiceProviderConnectToServiceParams.deserialize(
@@ -264,10 +271,23 @@ class ServiceProviderStub extends bindings.Stub {
ServiceProvider get impl => _impl;
set impl(ServiceProvider 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 "ServiceProviderStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698