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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/http_connection.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/http_connection.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart
index 5e014968f64d23468d2e9e1ca81827e809f7cdbf..fa7c5e54ab17b9997a1e61da09d0cb0c00edff9b 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart
@@ -795,14 +795,19 @@ class HttpConnectionProxy implements bindings.ProxyBase {
class HttpConnectionStub extends bindings.Stub {
- HttpConnection _impl = null;
+ HttpConnection _impl;
HttpConnectionStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [HttpConnection impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- HttpConnectionStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ HttpConnectionStub.fromHandle(
+ core.MojoHandle handle, [HttpConnection impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
HttpConnectionStub.unbound() : super.unbound();
@@ -830,7 +835,9 @@ class HttpConnectionStub 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 _httpConnectionMethodSetSendBufferSizeName:
var params = _HttpConnectionSetSendBufferSizeParams.deserialize(
@@ -885,10 +892,23 @@ class HttpConnectionStub extends bindings.Stub {
HttpConnection get impl => _impl;
set impl(HttpConnection 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 "HttpConnectionStub($superString)";
@@ -1085,14 +1105,19 @@ class HttpConnectionDelegateProxy implements bindings.ProxyBase {
class HttpConnectionDelegateStub extends bindings.Stub {
- HttpConnectionDelegate _impl = null;
+ HttpConnectionDelegate _impl;
HttpConnectionDelegateStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [HttpConnectionDelegate impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- HttpConnectionDelegateStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ HttpConnectionDelegateStub.fromHandle(
+ core.MojoHandle handle, [HttpConnectionDelegate impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
HttpConnectionDelegateStub.unbound() : super.unbound();
@@ -1122,7 +1147,9 @@ class HttpConnectionDelegateStub 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 _httpConnectionDelegateMethodOnReceivedRequestName:
var params = _HttpConnectionDelegateOnReceivedRequestParams.deserialize(
@@ -1177,10 +1204,23 @@ class HttpConnectionDelegateStub extends bindings.Stub {
HttpConnectionDelegate get impl => _impl;
set impl(HttpConnectionDelegate 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 "HttpConnectionDelegateStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698