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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/media/media_transport.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/media/media_transport.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/media/media_transport.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/media/media_transport.mojom.dart
index c2f8ee2e518ac7e288aaa198002deab24952c5ce..217505c21f41e80c8bde2612124e1beb987ca56c 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/media/media_transport.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/media/media_transport.mojom.dart
@@ -1433,14 +1433,19 @@ class MediaProducerProxy implements bindings.ProxyBase {
class MediaProducerStub extends bindings.Stub {
- MediaProducer _impl = null;
+ MediaProducer _impl;
MediaProducerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [MediaProducer impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- MediaProducerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ MediaProducerStub.fromHandle(
+ core.MojoHandle handle, [MediaProducer impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
MediaProducerStub.unbound() : super.unbound();
@@ -1462,7 +1467,9 @@ class MediaProducerStub 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 _mediaProducerMethodConnectName:
var params = _MediaProducerConnectParams.deserialize(
@@ -1498,10 +1505,23 @@ class MediaProducerStub extends bindings.Stub {
MediaProducer get impl => _impl;
set impl(MediaProducer 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 "MediaProducerStub($superString)";
@@ -1708,14 +1728,19 @@ class MediaPullModeProducerProxy implements bindings.ProxyBase {
class MediaPullModeProducerStub extends bindings.Stub {
- MediaPullModeProducer _impl = null;
+ MediaPullModeProducer _impl;
MediaPullModeProducerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [MediaPullModeProducer impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- MediaPullModeProducerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ MediaPullModeProducerStub.fromHandle(
+ core.MojoHandle handle, [MediaPullModeProducer impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
MediaPullModeProducerStub.unbound() : super.unbound();
@@ -1743,7 +1768,9 @@ class MediaPullModeProducerStub 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 _mediaPullModeProducerMethodGetBufferName:
var response = _impl.getBuffer(_mediaPullModeProducerGetBufferResponseParamsFactory);
@@ -1801,10 +1828,23 @@ class MediaPullModeProducerStub extends bindings.Stub {
MediaPullModeProducer get impl => _impl;
set impl(MediaPullModeProducer 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 "MediaPullModeProducerStub($superString)";
@@ -2114,14 +2154,19 @@ class MediaConsumerProxy implements bindings.ProxyBase {
class MediaConsumerStub extends bindings.Stub {
- MediaConsumer _impl = null;
+ MediaConsumer _impl;
MediaConsumerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [MediaConsumer impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- MediaConsumerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ MediaConsumerStub.fromHandle(
+ core.MojoHandle handle, [MediaConsumer impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
MediaConsumerStub.unbound() : super.unbound();
@@ -2156,7 +2201,9 @@ class MediaConsumerStub 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 _mediaConsumerMethodSetBufferName:
var params = _MediaConsumerSetBufferParams.deserialize(
@@ -2251,10 +2298,23 @@ class MediaConsumerStub extends bindings.Stub {
MediaConsumer get impl => _impl;
set impl(MediaConsumer 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 "MediaConsumerStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698