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

Unified Diff: mojo/dart/packages/mojo_services/lib/keyboard/keyboard.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/keyboard/keyboard.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart b/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart
index e028e40cc38b531f05ea0cb0729b9fa27c8aaf7d..44c2e582e37cd49a585113969af552efcf679b38 100644
--- a/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart
@@ -1644,14 +1644,19 @@ class KeyboardClientProxy implements bindings.ProxyBase {
class KeyboardClientStub extends bindings.Stub {
- KeyboardClient _impl = null;
+ KeyboardClient _impl;
KeyboardClientStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [KeyboardClient impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- KeyboardClientStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ KeyboardClientStub.fromHandle(
+ core.MojoHandle handle, [KeyboardClient impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
KeyboardClientStub.unbound() : super.unbound();
@@ -1669,7 +1674,9 @@ class KeyboardClientStub 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 _keyboardClientMethodCommitCompletionName:
var params = _KeyboardClientCommitCompletionParams.deserialize(
@@ -1720,10 +1727,23 @@ class KeyboardClientStub extends bindings.Stub {
KeyboardClient get impl => _impl;
set impl(KeyboardClient 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 "KeyboardClientStub($superString)";
@@ -1913,14 +1933,19 @@ class KeyboardServiceProxy implements bindings.ProxyBase {
class KeyboardServiceStub extends bindings.Stub {
- KeyboardService _impl = null;
+ KeyboardService _impl;
KeyboardServiceStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [KeyboardService impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- KeyboardServiceStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ KeyboardServiceStub.fromHandle(
+ core.MojoHandle handle, [KeyboardService impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
KeyboardServiceStub.unbound() : super.unbound();
@@ -1938,7 +1963,9 @@ class KeyboardServiceStub 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 _keyboardServiceMethodShowName:
var params = _KeyboardServiceShowParams.deserialize(
@@ -1970,10 +1997,23 @@ class KeyboardServiceStub extends bindings.Stub {
KeyboardService get impl => _impl;
set impl(KeyboardService 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 "KeyboardServiceStub($superString)";
@@ -2120,14 +2160,19 @@ class KeyboardServiceFactoryProxy implements bindings.ProxyBase {
class KeyboardServiceFactoryStub extends bindings.Stub {
- KeyboardServiceFactory _impl = null;
+ KeyboardServiceFactory _impl;
KeyboardServiceFactoryStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [KeyboardServiceFactory impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- KeyboardServiceFactoryStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ KeyboardServiceFactoryStub.fromHandle(
+ core.MojoHandle handle, [KeyboardServiceFactory impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
KeyboardServiceFactoryStub.unbound() : super.unbound();
@@ -2145,7 +2190,9 @@ class KeyboardServiceFactoryStub 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 _keyboardServiceFactoryMethodCreateKeyboardServiceName:
var params = _KeyboardServiceFactoryCreateKeyboardServiceParams.deserialize(
@@ -2161,10 +2208,23 @@ class KeyboardServiceFactoryStub extends bindings.Stub {
KeyboardServiceFactory get impl => _impl;
set impl(KeyboardServiceFactory 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 "KeyboardServiceFactoryStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698