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

Unified Diff: mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.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/asset_bundle/asset_bundle.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart
index 7d7f49ffaa220e1e241e1a55a8864c35e72a88cd..22151b9591348ced8caa1700800659bf9c6d0430 100644
--- a/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart
@@ -385,14 +385,19 @@ class AssetBundleProxy implements bindings.ProxyBase {
class AssetBundleStub extends bindings.Stub {
- AssetBundle _impl = null;
+ AssetBundle _impl;
AssetBundleStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [AssetBundle impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- AssetBundleStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ AssetBundleStub.fromHandle(
+ core.MojoHandle handle, [AssetBundle impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
AssetBundleStub.unbound() : super.unbound();
@@ -415,7 +420,9 @@ class AssetBundleStub 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 _assetBundleMethodGetAsStreamName:
var params = _AssetBundleGetAsStreamParams.deserialize(
@@ -448,10 +455,23 @@ class AssetBundleStub extends bindings.Stub {
AssetBundle get impl => _impl;
set impl(AssetBundle 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 "AssetBundleStub($superString)";
@@ -598,14 +618,19 @@ class AssetUnpackerProxy implements bindings.ProxyBase {
class AssetUnpackerStub extends bindings.Stub {
- AssetUnpacker _impl = null;
+ AssetUnpacker _impl;
AssetUnpackerStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [AssetUnpacker impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- AssetUnpackerStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ AssetUnpackerStub.fromHandle(
+ core.MojoHandle handle, [AssetUnpacker impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
AssetUnpackerStub.unbound() : super.unbound();
@@ -623,7 +648,9 @@ class AssetUnpackerStub 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 _assetUnpackerMethodUnpackZipStreamName:
var params = _AssetUnpackerUnpackZipStreamParams.deserialize(
@@ -639,10 +666,23 @@ class AssetUnpackerStub extends bindings.Stub {
AssetUnpacker get impl => _impl;
set impl(AssetUnpacker 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 "AssetUnpackerStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698