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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.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/tcp_connected_socket.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart
index 7612a02b7d05423a9df74299ce302a8af8e9d7c2..cb2f5b077e71178fe2c7ef60472f041a2a450314 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart
@@ -125,14 +125,19 @@ class TcpConnectedSocketProxy implements bindings.ProxyBase {
class TcpConnectedSocketStub extends bindings.Stub {
- TcpConnectedSocket _impl = null;
+ TcpConnectedSocket _impl;
TcpConnectedSocketStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [TcpConnectedSocket impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- TcpConnectedSocketStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ TcpConnectedSocketStub.fromHandle(
+ core.MojoHandle handle, [TcpConnectedSocket impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
TcpConnectedSocketStub.unbound() : super.unbound();
@@ -150,7 +155,9 @@ class TcpConnectedSocketStub extends bindings.Stub {
0,
message);
}
- assert(_impl != null);
+ if (_impl == null) {
+ throw new core.MojoApiError("$this has no implementation set");
+ }
switch (message.header.type) {
default:
throw new bindings.MojoCodecError("Unexpected message name");
@@ -161,10 +168,23 @@ class TcpConnectedSocketStub extends bindings.Stub {
TcpConnectedSocket get impl => _impl;
set impl(TcpConnectedSocket 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 "TcpConnectedSocketStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698