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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.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_services/lib/mojo/url_loader_interceptor.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart
index 473621410780db206922178ebcca527e1f797c4d..21032a36b970348d60cbaa9cf4e8fd53df36d2ef 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart
@@ -715,14 +715,19 @@ class UrlLoaderInterceptorFactoryProxy implements bindings.ProxyBase {
class UrlLoaderInterceptorFactoryStub extends bindings.Stub {
- UrlLoaderInterceptorFactory _impl = null;
+ UrlLoaderInterceptorFactory _impl;
UrlLoaderInterceptorFactoryStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [UrlLoaderInterceptorFactory impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- UrlLoaderInterceptorFactoryStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ UrlLoaderInterceptorFactoryStub.fromHandle(
+ core.MojoHandle handle, [UrlLoaderInterceptorFactory impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
UrlLoaderInterceptorFactoryStub.unbound() : super.unbound();
@@ -740,7 +745,9 @@ class UrlLoaderInterceptorFactoryStub 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 _urlLoaderInterceptorFactoryMethodCreateName:
var params = _UrlLoaderInterceptorFactoryCreateParams.deserialize(
@@ -756,10 +763,23 @@ class UrlLoaderInterceptorFactoryStub extends bindings.Stub {
UrlLoaderInterceptorFactory get impl => _impl;
set impl(UrlLoaderInterceptorFactory 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 "UrlLoaderInterceptorFactoryStub($superString)";
@@ -986,14 +1006,19 @@ class UrlLoaderInterceptorProxy implements bindings.ProxyBase {
class UrlLoaderInterceptorStub extends bindings.Stub {
- UrlLoaderInterceptor _impl = null;
+ UrlLoaderInterceptor _impl;
UrlLoaderInterceptorStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [UrlLoaderInterceptor impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- UrlLoaderInterceptorStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ UrlLoaderInterceptorStub.fromHandle(
+ core.MojoHandle handle, [UrlLoaderInterceptor impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
UrlLoaderInterceptorStub.unbound() : super.unbound();
@@ -1026,7 +1051,9 @@ class UrlLoaderInterceptorStub 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 _urlLoaderInterceptorMethodInterceptRequestName:
var params = _UrlLoaderInterceptorInterceptRequestParams.deserialize(
@@ -1101,10 +1128,23 @@ class UrlLoaderInterceptorStub extends bindings.Stub {
UrlLoaderInterceptor get impl => _impl;
set impl(UrlLoaderInterceptor 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 "UrlLoaderInterceptorStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698