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

Unified Diff: mojo/dart/packages/mojo_services/lib/http_server/http_server.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/http_server/http_server.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart b/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart
index 45b36b3a75cb0317acee2356b7fce4f903e9452f..35a191c17920b6e9c4582ea90860b0cc7903530e 100644
--- a/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart
@@ -621,14 +621,19 @@ class HttpServerProxy implements bindings.ProxyBase {
class HttpServerStub extends bindings.Stub {
- HttpServer _impl = null;
+ HttpServer _impl;
HttpServerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [HttpServer impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- HttpServerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ HttpServerStub.fromHandle(
+ core.MojoHandle handle, [HttpServer impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
HttpServerStub.unbound() : super.unbound();
@@ -656,7 +661,9 @@ class HttpServerStub 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 _httpServerMethodSetHandlerName:
var params = _HttpServerSetHandlerParams.deserialize(
@@ -709,10 +716,23 @@ class HttpServerStub extends bindings.Stub {
HttpServer get impl => _impl;
set impl(HttpServer 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 "HttpServerStub($superString)";
@@ -878,14 +898,19 @@ class HttpHandlerProxy implements bindings.ProxyBase {
class HttpHandlerStub extends bindings.Stub {
- HttpHandler _impl = null;
+ HttpHandler _impl;
HttpHandlerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [HttpHandler impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- HttpHandlerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ HttpHandlerStub.fromHandle(
+ core.MojoHandle handle, [HttpHandler impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
HttpHandlerStub.unbound() : super.unbound();
@@ -908,7 +933,9 @@ class HttpHandlerStub 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 _httpHandlerMethodHandleRequestName:
var params = _HttpHandlerHandleRequestParams.deserialize(
@@ -941,10 +968,23 @@ class HttpHandlerStub extends bindings.Stub {
HttpHandler get impl => _impl;
set impl(HttpHandler 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 "HttpHandlerStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698