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

Unified Diff: mojo/dart/packages/mojo_services/lib/nfc/nfc.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/nfc/nfc.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart b/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart
index 0176a3ad9e329c784ad2898c04ec9dfc3cc59faa..42cb6cb63e9b52c4c3caa1a38fb62dc6f00bc4ef 100644
--- a/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart
@@ -613,14 +613,19 @@ class NfcTransmissionProxy implements bindings.ProxyBase {
class NfcTransmissionStub extends bindings.Stub {
- NfcTransmission _impl = null;
+ NfcTransmission _impl;
NfcTransmissionStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [NfcTransmission impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- NfcTransmissionStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ NfcTransmissionStub.fromHandle(
+ core.MojoHandle handle, [NfcTransmission impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
NfcTransmissionStub.unbound() : super.unbound();
@@ -638,7 +643,9 @@ class NfcTransmissionStub 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 _nfcTransmissionMethodCancelName:
_impl.cancel();
@@ -652,10 +659,23 @@ class NfcTransmissionStub extends bindings.Stub {
NfcTransmission get impl => _impl;
set impl(NfcTransmission 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 "NfcTransmissionStub($superString)";
@@ -801,14 +821,19 @@ class NfcReceiverProxy implements bindings.ProxyBase {
class NfcReceiverStub extends bindings.Stub {
- NfcReceiver _impl = null;
+ NfcReceiver _impl;
NfcReceiverStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [NfcReceiver impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- NfcReceiverStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ NfcReceiverStub.fromHandle(
+ core.MojoHandle handle, [NfcReceiver impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
NfcReceiverStub.unbound() : super.unbound();
@@ -826,7 +851,9 @@ class NfcReceiverStub 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 _nfcReceiverMethodOnReceivedNfcDataName:
var params = _NfcReceiverOnReceivedNfcDataParams.deserialize(
@@ -842,10 +869,23 @@ class NfcReceiverStub extends bindings.Stub {
NfcReceiver get impl => _impl;
set impl(NfcReceiver 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 "NfcReceiverStub($superString)";
@@ -1032,14 +1072,19 @@ class NfcProxy implements bindings.ProxyBase {
class NfcStub extends bindings.Stub {
- Nfc _impl = null;
+ Nfc _impl;
NfcStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [Nfc impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- NfcStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ NfcStub.fromHandle(
+ core.MojoHandle handle, [Nfc impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
NfcStub.unbound() : super.unbound();
@@ -1062,7 +1107,9 @@ class NfcStub 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 _nfcMethodTransmitOnNextConnectionName:
var params = _NfcTransmitOnNextConnectionParams.deserialize(
@@ -1101,10 +1148,23 @@ class NfcStub extends bindings.Stub {
Nfc get impl => _impl;
set impl(Nfc 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 "NfcStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698