| Index: mojo/public/dart/src/application.dart
|
| diff --git a/mojo/public/dart/src/application.dart b/mojo/public/dart/src/application.dart
|
| index d0d2afe9d6e3d12a269ed28cb718dcd8098147c5..4d6ba3bb58bf26a2608c45fa1423262ac7c0fb6a 100644
|
| --- a/mojo/public/dart/src/application.dart
|
| +++ b/mojo/public/dart/src/application.dart
|
| @@ -9,28 +9,25 @@ class _ApplicationImpl implements application_mojom.Application {
|
| shell_mojom.ShellProxy shell;
|
| Application _application;
|
|
|
| - _ApplicationImpl(Application application,
|
| - core.MojoMessagePipeEndpoint endpoint, {Function onClosed}) {
|
| + _ApplicationImpl(
|
| + Application application, core.MojoMessagePipeEndpoint endpoint) {
|
| _application = application;
|
| - // We wrap the onClosed callback in a closure to ensure that all
|
| - // necessary cleanup is performed on a PEER_CLOSED signal.
|
| - _stub = new application_mojom.ApplicationStub.fromEndpoint(
|
| - endpoint,
|
| - impl: this,
|
| - onClosed: _closer(onClosed));
|
| + _stub = new application_mojom.ApplicationStub.fromEndpoint(endpoint, this);
|
| + _stub.onError = close;
|
| }
|
|
|
| - _ApplicationImpl.fromHandle(Application application, core.MojoHandle handle,
|
| - {Function onClosed}) {
|
| + _ApplicationImpl.fromHandle(Application application, core.MojoHandle handle) {
|
| _application = application;
|
| - _stub = new application_mojom.ApplicationStub.fromHandle(
|
| - handle,
|
| - impl: this,
|
| - onClosed: _closer(onClosed));
|
| + _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);
|
| @@ -38,27 +35,14 @@ class _ApplicationImpl implements application_mojom.Application {
|
|
|
| @override
|
| void acceptConnection(String requestorUrl, ServiceProviderStub services,
|
| - bindings.ProxyBase exposedServices, String resolvedUrl) =>
|
| - _application._acceptConnection(
|
| - requestorUrl,
|
| - services,
|
| - exposedServices,
|
| - resolvedUrl);
|
| + bindings.ProxyBase exposedServices, String resolvedUrl) => _application
|
| + ._acceptConnection(requestorUrl, services, exposedServices, resolvedUrl);
|
|
|
| @override
|
| void requestQuit() => _application._requestQuitAndClose();
|
|
|
| - Function _closer(Function onClosed) {
|
| - return (() {
|
| - if (onClosed != null) {
|
| - onClosed();
|
| - }
|
| - close();
|
| - });
|
| - }
|
| -
|
| void close({bool nodefer: false}) {
|
| - shell.close();
|
| + if (shell != null) shell.close();
|
| _stub.close();
|
| }
|
| }
|
| @@ -72,26 +56,24 @@ abstract class Application {
|
| _ApplicationImpl _applicationImpl;
|
| List<ApplicationConnection> _applicationConnections;
|
|
|
| - Application(core.MojoMessagePipeEndpoint endpoint, {Function onClosed}) {
|
| + Application(core.MojoMessagePipeEndpoint endpoint) {
|
| _applicationConnections = [];
|
| - // We wrap the onClosed callback in a closure to ensure that all
|
| - // necessary cleanup is performed on a PEER_CLOSED signal.
|
| - _applicationImpl =
|
| - new _ApplicationImpl(this, endpoint, onClosed: _closer(onClosed));
|
| + _applicationImpl = new _ApplicationImpl(this, endpoint);
|
| + _applicationImpl.onError = close;
|
| }
|
|
|
| - Application.fromHandle(core.MojoHandle appHandle, {Function onClosed}) {
|
| + Application.fromHandle(core.MojoHandle appHandle) {
|
| _applicationConnections = [];
|
| - _applicationImpl =
|
| - new _ApplicationImpl.fromHandle(this, appHandle, onClosed: _closer(onClosed));
|
| + _applicationImpl = new _ApplicationImpl.fromHandle(this, appHandle);
|
| + _applicationImpl.onError = close;
|
| }
|
|
|
| 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|.
|
| @@ -115,15 +97,6 @@ abstract class Application {
|
| close();
|
| }
|
|
|
| - Function _closer(Function onClose) {
|
| - return (() {
|
| - if (onClose != null) {
|
| - onClose();
|
| - }
|
| - close();
|
| - });
|
| - }
|
| -
|
| void close() {
|
| assert(_applicationImpl != null);
|
| _applicationConnections.forEach((c) => c.close());
|
| @@ -132,7 +105,7 @@ abstract class Application {
|
| }
|
|
|
| // This method closes all the application connections. Used during apptesting.
|
| - resetConnections() {
|
| + void resetConnections() {
|
| assert(_applicationImpl != null);
|
| _applicationConnections.forEach((c) => c.close());
|
| _applicationConnections.clear();
|
| @@ -146,9 +119,6 @@ abstract class Application {
|
| }
|
|
|
| // 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, String resolvedUrl,
|
| - ApplicationConnection connection) {
|
| - }
|
| + ApplicationConnection connection) {}
|
| }
|
|
|