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

Unified Diff: mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl

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
« no previous file with comments | « mojo/dart/packages/mojo_services/lib/vsync/vsync.mojom.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
index 31fc778eef0c66b88610d9bbd754e878d2351dd6..362bd4c7384c0860b1c434ec324052debeed42a9 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
@@ -231,14 +231,19 @@ class {{interface|name}}Proxy implements bindings.ProxyBase {
class {{interface|name}}Stub extends bindings.Stub {
- {{interface|name}} _impl = null;
+ {{interface|name}} _impl;
{{interface|name}}Stub.fromEndpoint(
- core.MojoMessagePipeEndpoint endpoint, [this._impl])
- : super.fromEndpoint(endpoint);
+ core.MojoMessagePipeEndpoint endpoint, [{{interface|name}} impl])
+ : super.fromEndpoint(endpoint, autoBegin: impl != null) {
+ _impl = impl;
+ }
- {{interface|name}}Stub.fromHandle(core.MojoHandle handle, [this._impl])
- : super.fromHandle(handle);
+ {{interface|name}}Stub.fromHandle(
+ core.MojoHandle handle, [{{interface|name}} impl])
+ : super.fromHandle(handle, autoBegin: impl != null) {
+ _impl = impl;
+ }
{{interface|name}}Stub.unbound() : super.unbound();
@@ -271,7 +276,9 @@ class {{interface|name}}Stub extends bindings.Stub {
{{interface.version}},
message);
}
- assert(_impl != null);
+ if (_impl == null) {
+ throw new core.MojoApiError("$this has no implementation set");
+ }
switch (message.header.type) {
{%- for method in interface.methods %}
{%- set request_struct = method.param_struct %}
@@ -322,10 +329,23 @@ class {{interface|name}}Stub extends bindings.Stub {
{{interface|name}} get impl => _impl;
set impl({{interface|name}} 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 "{{interface|name}}Stub($superString)";
« no previous file with comments | « mojo/dart/packages/mojo_services/lib/vsync/vsync.mojom.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698