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

Unified Diff: third_party/mojo/src/mojo/public/dart/src/application_connection.dart

Issue 1019173002: Update mojo sdk to rev 7214b7ec7d27563b2666afad86cf1c5895c56c18 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep permission service alive if embedder drops requests Created 5 years, 9 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: third_party/mojo/src/mojo/public/dart/src/application_connection.dart
diff --git a/third_party/mojo/src/mojo/public/dart/src/application_connection.dart b/third_party/mojo/src/mojo/public/dart/src/application_connection.dart
index 4f0b6c8ed250056b670b9b7cddee8faeb53c7b07..8c354ea672618106c4922223c0e76f8d539f323a 100644
--- a/third_party/mojo/src/mojo/public/dart/src/application_connection.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/application_connection.dart
@@ -5,24 +5,26 @@
part of application;
typedef Object ServiceFactory(core.MojoMessagePipeEndpoint endpoint);
-typedef void FallbackServiceFactory(String interfaceName,
- core.MojoMessagePipeEndpoint endpoint);
-
+typedef void FallbackServiceFactory(
+ String interfaceName, core.MojoMessagePipeEndpoint endpoint);
class LocalServiceProvider implements ServiceProvider {
final ApplicationConnection connection;
ServiceProviderStub _stub;
LocalServiceProvider(this.connection, this._stub) {
- _stub.delegate = this;
+ assert(_stub.isOpen);
+ _stub.impl = this;
}
- listen() => _stub.listen();
+ set onError(Function f) {
+ _stub.onError = f;
+ }
- void close({bool nodefer : false}) => _stub.close(nodefer: nodefer);
+ Future close({bool nodefer: false}) => _stub.close(nodefer: nodefer);
- void connectToService(String interfaceName,
- core.MojoMessagePipeEndpoint pipe) {
+ void connectToService(
+ String interfaceName, core.MojoMessagePipeEndpoint pipe) {
if (connection._nameToServiceFactory.containsKey(interfaceName)) {
connection._nameToServiceFactory[interfaceName](pipe);
return;
@@ -33,7 +35,7 @@ class LocalServiceProvider implements ServiceProvider {
}
// The specified interface isn't provided. Close the pipe so the
// remote endpoint sees that we don't support this interface.
- pipe.handle.close();
+ pipe.close();
}
}
@@ -63,15 +65,17 @@ class ApplicationConnection {
LocalServiceProvider _localServiceProvider;
final _nameToServiceFactory = new Map<String, ServiceFactory>();
FallbackServiceFactory _fallbackServiceFactory;
+ core.ErrorHandler onError;
- ApplicationConnection(ServiceProviderStub stub, ServiceProviderProxy proxy)
- : remoteServiceProvider = proxy {
- if (stub != null) _localServiceProvider =
- new LocalServiceProvider(this, stub);
+ ApplicationConnection(ServiceProviderStub stub, this.remoteServiceProvider) {
+ if (stub != null) {
+ _localServiceProvider = new LocalServiceProvider(this, stub);
+ _localServiceProvider.onError = _errorHandler;
+ }
}
FallbackServiceFactory get fallbackServiceFactory => _fallbackServiceFactory;
- set fallbackServiceFactory(FallbackServiceFactory f) {
+ set fallbackServiceFactory(FallbackServiceFactory f) {
assert(_localServiceProvider != null);
_fallbackServiceFactory = f;
}
@@ -82,8 +86,7 @@ class ApplicationConnection {
remoteServiceProvider.impl.isBound);
var pipe = new core.MojoMessagePipe();
proxy.impl.bind(pipe.endpoints[0]);
- remoteServiceProvider.ptr.connectToService(
- proxy.name, pipe.endpoints[1]);
+ remoteServiceProvider.ptr.connectToService(proxy.name, pipe.endpoints[1]);
return proxy;
}
@@ -92,20 +95,27 @@ class ApplicationConnection {
_nameToServiceFactory[interfaceName] = factory;
}
- void listen() {
- assert(_localServiceProvider != null);
- _localServiceProvider.listen();
+ void _errorHandler() {
+ close().then((_) {
+ if (onError != null) onError();
+ });
}
- void close({bool nodefer: false}) {
+ Future close({bool nodefer: false}) {
+ var rspCloseFuture;
+ var lspCloseFuture;
if (remoteServiceProvider != null) {
- remoteServiceProvider.close();
+ rspCloseFuture = remoteServiceProvider.close();
remoteServiceProvider = null;
+ } else {
+ rspCloseFuture = new Future.value(null);
}
if (_localServiceProvider != null) {
- _localServiceProvider.close(nodefer: nodefer);
+ lspCloseFuture = _localServiceProvider.close(nodefer: nodefer);
_localServiceProvider = null;
+ } else {
+ lspCloseFuture = new Future.value(null);
}
-
+ return rspCloseFuture.then((_) => lspCloseFuture);
}
}
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/src/application.dart ('k') | third_party/mojo/src/mojo/public/dart/src/codec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698