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

Unified Diff: mojo/dart/packages/mojo_services/lib/tracing/tracing.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/tracing/tracing.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart b/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart
index 44aeb52581978ea551dfae881e2d41e0bd90df2a..7728f20a6238753cc51c6db768d6fee325f0f307 100644
--- a/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart
@@ -505,14 +505,19 @@ class TraceProviderProxy implements bindings.ProxyBase {
class TraceProviderStub extends bindings.Stub {
- TraceProvider _impl = null;
+ TraceProvider _impl;
TraceProviderStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [TraceProvider impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- TraceProviderStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ TraceProviderStub.fromHandle(
+ core.MojoHandle handle, [TraceProvider impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
TraceProviderStub.unbound() : super.unbound();
@@ -530,7 +535,9 @@ class TraceProviderStub 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 _traceProviderMethodStartTracingName:
var params = _TraceProviderStartTracingParams.deserialize(
@@ -549,10 +556,23 @@ class TraceProviderStub extends bindings.Stub {
TraceProvider get impl => _impl;
set impl(TraceProvider 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 "TraceProviderStub($superString)";
@@ -698,14 +718,19 @@ class TraceRecorderProxy implements bindings.ProxyBase {
class TraceRecorderStub extends bindings.Stub {
- TraceRecorder _impl = null;
+ TraceRecorder _impl;
TraceRecorderStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [TraceRecorder impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- TraceRecorderStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ TraceRecorderStub.fromHandle(
+ core.MojoHandle handle, [TraceRecorder impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
TraceRecorderStub.unbound() : super.unbound();
@@ -723,7 +748,9 @@ class TraceRecorderStub 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 _traceRecorderMethodRecordName:
var params = _TraceRecorderRecordParams.deserialize(
@@ -739,10 +766,23 @@ class TraceRecorderStub extends bindings.Stub {
TraceRecorder get impl => _impl;
set impl(TraceRecorder 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 "TraceRecorderStub($superString)";
@@ -899,14 +939,19 @@ class TraceCollectorProxy implements bindings.ProxyBase {
class TraceCollectorStub extends bindings.Stub {
- TraceCollector _impl = null;
+ TraceCollector _impl;
TraceCollectorStub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [TraceCollector impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- TraceCollectorStub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ TraceCollectorStub.fromHandle(
+ core.MojoHandle handle, [TraceCollector impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
TraceCollectorStub.unbound() : super.unbound();
@@ -924,7 +969,9 @@ class TraceCollectorStub 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 _traceCollectorMethodStartName:
var params = _TraceCollectorStartParams.deserialize(
@@ -943,10 +990,23 @@ class TraceCollectorStub extends bindings.Stub {
TraceCollector get impl => _impl;
set impl(TraceCollector 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 "TraceCollectorStub($superString)";

Powered by Google App Engine
This is Rietveld 408576698