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

Unified Diff: third_party/mojo/src/mojo/public/dart/src/application.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.dart
diff --git a/third_party/mojo/src/mojo/public/dart/src/application.dart b/third_party/mojo/src/mojo/public/dart/src/application.dart
index 3ae900b5ce884a95669d031425ee1b1cc07ccf07..03d0843f4e55e1d7947ce27064746eea71eb7f75 100644
--- a/third_party/mojo/src/mojo/public/dart/src/application.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/application.dart
@@ -9,35 +9,42 @@ class _ApplicationImpl implements application_mojom.Application {
shell_mojom.ShellProxy shell;
Application _application;
- _ApplicationImpl(Application application,
- core.MojoMessagePipeEndpoint endpoint) {
+ _ApplicationImpl(
+ Application application, core.MojoMessagePipeEndpoint endpoint) {
_application = application;
- _stub = new application_mojom.ApplicationStub.fromEndpoint(endpoint)
- ..delegate = this
- ..listen();
+ _stub = new application_mojom.ApplicationStub.fromEndpoint(endpoint, this);
+ _stub.onError = close;
}
_ApplicationImpl.fromHandle(Application application, core.MojoHandle handle) {
_application = application;
- _stub = new application_mojom.ApplicationStub.fromHandle(handle)
- ..delegate = this
- ..listen();
+ _stub = new application_mojom.ApplicationStub.fromHandle(handle, this);
+ _stub.onError = close;
}
- void initialize(bindings.ProxyBase shellProxy, List<String> args,
- String url) {
+ set onError(core.ErrorHandler f) {
+ _stub.onError = f;
+ }
+
+ void initialize(
+ bindings.ProxyBase shellProxy, List<String> args, String url) {
assert(shell == null);
shell = shellProxy;
_application.initialize(args, url);
}
+ @override
void acceptConnection(String requestorUrl, ServiceProviderStub services,
- bindings.ProxyBase exposedServices, String requested_url) =>
- _application._acceptConnection(requestorUrl, services, exposedServices);
+ bindings.ProxyBase exposedServices, String resolvedUrl) => _application
+ ._acceptConnection(requestorUrl, services, exposedServices, resolvedUrl);
+ @override
void requestQuit() => _application._requestQuitAndClose();
- void close({bool nodefer: false}) => shell.close();
+ Future close({bool nodefer: false}) {
+ if (shell != null) shell.close();
+ return _stub.close();
+ }
}
// TODO(zra): Better documentation and examples.
@@ -48,23 +55,26 @@ class _ApplicationImpl implements application_mojom.Application {
abstract class Application {
_ApplicationImpl _applicationImpl;
List<ApplicationConnection> _applicationConnections;
+ Function onError;
Application(core.MojoMessagePipeEndpoint endpoint) {
_applicationConnections = [];
_applicationImpl = new _ApplicationImpl(this, endpoint);
+ _applicationImpl.onError = _errorHandler;
}
Application.fromHandle(core.MojoHandle appHandle) {
_applicationConnections = [];
_applicationImpl = new _ApplicationImpl.fromHandle(this, appHandle);
+ _applicationImpl.onError = _errorHandler;
}
void initialize(List<String> args, String url) {}
// TODO(skydart): This is a temporary fix to allow sky application to consume
// mojo services. Do not use for any other purpose.
- void initializeFromShellProxy(shell_mojom.ShellProxy shellProxy,
- List<String> args, String url) =>
+ void initializeFromShellProxy(
+ shell_mojom.ShellProxy shellProxy, List<String> args, String url) =>
_applicationImpl.initialize(shellProxy, args, url);
// Returns a connection to the app at |url|.
@@ -88,23 +98,34 @@ abstract class Application {
close();
}
- void close() {
+ void _errorHandler() {
+ close().then((_) {
+ if (onError != null) onError();
+ });
+ }
+
+ Future close() {
+ assert(_applicationImpl != null);
+ _applicationConnections.forEach((c) => c.close());
+ _applicationConnections.clear();
+ return _applicationImpl.close();
+ }
+
+ // This method closes all the application connections. Used during apptesting.
+ void resetConnections() {
assert(_applicationImpl != null);
_applicationConnections.forEach((c) => c.close());
_applicationConnections.clear();
- _applicationImpl.close();
}
void _acceptConnection(String requestorUrl, ServiceProviderStub services,
- ServiceProviderProxy exposedServices) {
+ ServiceProviderProxy exposedServices, String resolvedUrl) {
var connection = new ApplicationConnection(services, exposedServices);
_applicationConnections.add(connection);
- acceptConnection(requestorUrl, connection);
+ acceptConnection(requestorUrl, resolvedUrl, connection);
}
// Override this method to provide services on |connection|.
- // If you provide at least one service or set fallbackServiceProvider,
- // then you must invoke connection.listen().
- void acceptConnection(String requestorUrl, ApplicationConnection connection) {
- }
+ void acceptConnection(String requestorUrl, String resolvedUrl,
+ ApplicationConnection connection) {}
}
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/rules.gni ('k') | third_party/mojo/src/mojo/public/dart/src/application_connection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698