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

Side by Side Diff: mojo/public/dart/src/application_connection.dart

Issue 1060193002: Provide mechanism to close immediately to Dart bindings (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « mojo/public/dart/src/application.dart ('k') | mojo/public/dart/src/event_stream.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 part of application; 5 part of application;
6 6
7 typedef Object ServiceFactory(core.MojoMessagePipeEndpoint endpoint); 7 typedef Object ServiceFactory(core.MojoMessagePipeEndpoint endpoint);
8 typedef void FallbackServiceFactory( 8 typedef void FallbackServiceFactory(
9 String interfaceName, core.MojoMessagePipeEndpoint endpoint); 9 String interfaceName, core.MojoMessagePipeEndpoint endpoint);
10 10
11 class LocalServiceProvider implements ServiceProvider { 11 class LocalServiceProvider implements ServiceProvider {
12 final ApplicationConnection connection; 12 final ApplicationConnection connection;
13 ServiceProviderStub _stub; 13 ServiceProviderStub _stub;
14 14
15 LocalServiceProvider(this.connection, this._stub) { 15 LocalServiceProvider(this.connection, this._stub) {
16 assert(_stub.isOpen); 16 assert(_stub.isOpen);
17 _stub.impl = this; 17 _stub.impl = this;
18 } 18 }
19 19
20 set onError(Function f) { 20 set onError(Function f) {
21 _stub.onError = f; 21 _stub.onError = f;
22 } 22 }
23 23
24 Future close({bool nodefer: false}) => _stub.close(nodefer: nodefer); 24 Future close({bool immediate: false}) => _stub.close(immediate: immediate);
25 25
26 void connectToService( 26 void connectToService(
27 String interfaceName, core.MojoMessagePipeEndpoint pipe) { 27 String interfaceName, core.MojoMessagePipeEndpoint pipe) {
28 if (connection._nameToServiceFactory.containsKey(interfaceName)) { 28 if (connection._nameToServiceFactory.containsKey(interfaceName)) {
29 connection._nameToServiceFactory[interfaceName](pipe); 29 connection._nameToServiceFactory[interfaceName](pipe);
30 return; 30 return;
31 } 31 }
32 if (connection.fallbackServiceFactory != null) { 32 if (connection.fallbackServiceFactory != null) {
33 connection.fallbackServiceFactory(interfaceName, pipe); 33 connection.fallbackServiceFactory(interfaceName, pipe);
34 return; 34 return;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 assert(_localServiceProvider != null); 94 assert(_localServiceProvider != null);
95 _nameToServiceFactory[interfaceName] = factory; 95 _nameToServiceFactory[interfaceName] = factory;
96 } 96 }
97 97
98 void _errorHandler() { 98 void _errorHandler() {
99 close().then((_) { 99 close().then((_) {
100 if (onError != null) onError(); 100 if (onError != null) onError();
101 }); 101 });
102 } 102 }
103 103
104 Future close({bool nodefer: false}) { 104 Future close({bool immediate: false}) {
105 var rspCloseFuture; 105 var rspCloseFuture;
106 var lspCloseFuture; 106 var lspCloseFuture;
107 if (remoteServiceProvider != null) { 107 if (remoteServiceProvider != null) {
108 rspCloseFuture = remoteServiceProvider.close(); 108 rspCloseFuture = remoteServiceProvider.close();
109 remoteServiceProvider = null; 109 remoteServiceProvider = null;
110 } else { 110 } else {
111 rspCloseFuture = new Future.value(null); 111 rspCloseFuture = new Future.value(null);
112 } 112 }
113 if (_localServiceProvider != null) { 113 if (_localServiceProvider != null) {
114 lspCloseFuture = _localServiceProvider.close(nodefer: nodefer); 114 lspCloseFuture = _localServiceProvider.close(immediate: immediate);
115 _localServiceProvider = null; 115 _localServiceProvider = null;
116 } else { 116 } else {
117 lspCloseFuture = new Future.value(null); 117 lspCloseFuture = new Future.value(null);
118 } 118 }
119 return rspCloseFuture.then((_) => lspCloseFuture); 119 return rspCloseFuture.then((_) => lspCloseFuture);
120 } 120 }
121 } 121 }
OLDNEW
« no previous file with comments | « mojo/public/dart/src/application.dart ('k') | mojo/public/dart/src/event_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698