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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/camera.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/camera.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart
index fac04fcb76ee049b5571424fd64f754f0ba4f9c8..d2d2f3642d23aa5aa2f2f355078d12842cb92272 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart
@@ -743,14 +743,19 @@ class CameraRollServiceProxy implements bindings.ProxyBase {
class CameraRollServiceStub extends bindings.Stub {
- CameraRollService _impl = null;
+ CameraRollService _impl;
CameraRollServiceStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [CameraRollService impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- CameraRollServiceStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ CameraRollServiceStub.fromHandle(
+ core.MojoHandle handle, [CameraRollService impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
CameraRollServiceStub.unbound() : super.unbound();
@@ -778,7 +783,9 @@ class CameraRollServiceStub 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 _cameraRollServiceMethodUpdateName:
_impl.update();
@@ -834,10 +841,23 @@ class CameraRollServiceStub extends bindings.Stub {
CameraRollService get impl => _impl;
set impl(CameraRollService 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 "CameraRollServiceStub($superString)";
@@ -1002,14 +1022,19 @@ class CameraServiceProxy implements bindings.ProxyBase {
class CameraServiceStub extends bindings.Stub {
- CameraService _impl = null;
+ CameraService _impl;
CameraServiceStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [CameraService impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- CameraServiceStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ CameraServiceStub.fromHandle(
+ core.MojoHandle handle, [CameraService impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
CameraServiceStub.unbound() : super.unbound();
@@ -1032,7 +1057,9 @@ class CameraServiceStub 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 _cameraServiceMethodGetLatestFrameName:
var response = _impl.getLatestFrame(_cameraServiceGetLatestFrameResponseParamsFactory);
@@ -1063,10 +1090,23 @@ class CameraServiceStub extends bindings.Stub {
CameraService get impl => _impl;
set impl(CameraService 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 "CameraServiceStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698