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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/ui/views.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/ui/views.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart
index 57bf9d0273f55cae19c53c49cb5a3dcd3bff4de8..0c52d2d82d3b7befb8f03a5ef11573b17ecc9040 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart
@@ -684,14 +684,19 @@ class ViewProxy implements bindings.ProxyBase {
class ViewStub extends bindings.Stub {
- View _impl = null;
+ View _impl;
ViewStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [View impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- ViewStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ ViewStub.fromHandle(
+ core.MojoHandle handle, [View impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
ViewStub.unbound() : super.unbound();
@@ -714,7 +719,9 @@ class ViewStub 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 _viewMethodGetTokenName:
var response = _impl.getToken(_viewGetTokenResponseParamsFactory);
@@ -760,10 +767,23 @@ class ViewStub extends bindings.Stub {
View get impl => _impl;
set impl(View 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 "ViewStub($superString)";
@@ -930,14 +950,19 @@ class ViewListenerProxy implements bindings.ProxyBase {
class ViewListenerStub extends bindings.Stub {
- ViewListener _impl = null;
+ ViewListener _impl;
ViewListenerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [ViewListener impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- ViewListenerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ ViewListenerStub.fromHandle(
+ core.MojoHandle handle, [ViewListener impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
ViewListenerStub.unbound() : super.unbound();
@@ -959,7 +984,9 @@ class ViewListenerStub 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 _viewListenerMethodOnPropertiesChangedName:
var params = _ViewListenerOnPropertiesChangedParams.deserialize(
@@ -992,10 +1019,23 @@ class ViewListenerStub extends bindings.Stub {
ViewListener get impl => _impl;
set impl(ViewListener 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 "ViewListenerStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698