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

Unified Diff: mojo/dart/packages/mojo_services/lib/input/input.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/input/input.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart b/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart
index fd407e3b1594b20db2d3f35d29d739e64ddbe72e..d701dd2621fedc58bdb6084e59075d3afe4d6f85 100644
--- a/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart
@@ -344,14 +344,19 @@ class InputClientProxy implements bindings.ProxyBase {
class InputClientStub extends bindings.Stub {
- InputClient _impl = null;
+ InputClient _impl;
InputClientStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [InputClient impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- InputClientStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ InputClientStub.fromHandle(
+ core.MojoHandle handle, [InputClient impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
InputClientStub.unbound() : super.unbound();
@@ -373,7 +378,9 @@ class InputClientStub 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 _inputClientMethodOnBackButtonName:
var response = _impl.onBackButton(_inputClientOnBackButtonResponseParamsFactory);
@@ -404,10 +411,23 @@ class InputClientStub extends bindings.Stub {
InputClient get impl => _impl;
set impl(InputClient 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 "InputClientStub($superString)";
@@ -553,14 +573,19 @@ class InputServiceProxy implements bindings.ProxyBase {
class InputServiceStub extends bindings.Stub {
- InputService _impl = null;
+ InputService _impl;
InputServiceStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [InputService impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- InputServiceStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ InputServiceStub.fromHandle(
+ core.MojoHandle handle, [InputService impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
InputServiceStub.unbound() : super.unbound();
@@ -578,7 +603,9 @@ class InputServiceStub 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 _inputServiceMethodSetClientName:
var params = _InputServiceSetClientParams.deserialize(
@@ -594,10 +621,23 @@ class InputServiceStub extends bindings.Stub {
InputService get impl => _impl;
set impl(InputService 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 "InputServiceStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698