| Index: mojo/public/dart/src/application_connection.dart
|
| diff --git a/mojo/public/dart/src/application_connection.dart b/mojo/public/dart/src/application_connection.dart
|
| index c44944e2a21e02bc9693367cae3359d7e67465e1..4f0b6c8ed250056b670b9b7cddee8faeb53c7b07 100644
|
| --- a/mojo/public/dart/src/application_connection.dart
|
| +++ b/mojo/public/dart/src/application_connection.dart
|
| @@ -4,28 +4,28 @@
|
|
|
| part of application;
|
|
|
| -typedef core.Listener ServiceFactory(core.MojoMessagePipeEndpoint endpoint);
|
| +typedef Object ServiceFactory(core.MojoMessagePipeEndpoint endpoint);
|
| typedef void FallbackServiceFactory(String interfaceName,
|
| core.MojoMessagePipeEndpoint endpoint);
|
|
|
|
|
| -class LocalServiceProvider extends ServiceProvider {
|
| +class LocalServiceProvider implements ServiceProvider {
|
| final ApplicationConnection connection;
|
| + ServiceProviderStub _stub;
|
|
|
| - LocalServiceProvider(ApplicationConnection this.connection,
|
| - ServiceProviderStub stub)
|
| - : super.fromStub(stub) {
|
| - delegate = this;
|
| + LocalServiceProvider(this.connection, this._stub) {
|
| + _stub.delegate = this;
|
| }
|
|
|
| + listen() => _stub.listen();
|
| +
|
| + void close({bool nodefer : false}) => _stub.close(nodefer: nodefer);
|
| +
|
| void connectToService(String interfaceName,
|
| core.MojoMessagePipeEndpoint pipe) {
|
| if (connection._nameToServiceFactory.containsKey(interfaceName)) {
|
| - var listener = connection._nameToServiceFactory[interfaceName](pipe);
|
| - if (listener != null) {
|
| - listener.listen();
|
| - return;
|
| - }
|
| + connection._nameToServiceFactory[interfaceName](pipe);
|
| + return;
|
| }
|
| if (connection.fallbackServiceFactory != null) {
|
| connection.fallbackServiceFactory(interfaceName, pipe);
|
| @@ -44,11 +44,11 @@ class LocalServiceProvider extends ServiceProvider {
|
| // and they're passed to the Application AcceptConnection() method.
|
| //
|
| // To request a service from the remote application:
|
| -// var proxy = applicationConnection.requestService(ViewManagerClient.name);
|
| +// var proxy = applicationConnection.requestService(ViewManagerClientName);
|
| //
|
| // To provide a service to the remote application, specify a function that
|
| // returns a service. For example:
|
| -// applicationConnection.provideService(ViewManagerClient.name, (pipe) =>
|
| +// applicationConnection.provideService(ViewManagerClientName, (pipe) =>
|
| // new ViewManagerClientImpl(pipe));
|
| //
|
| // To handle requests for any interface, set fallbackServiceFactory to a
|
| @@ -62,7 +62,7 @@ class ApplicationConnection {
|
| ServiceProviderProxy remoteServiceProvider;
|
| LocalServiceProvider _localServiceProvider;
|
| final _nameToServiceFactory = new Map<String, ServiceFactory>();
|
| - FallbackServiceFactory fallbackServiceFactory;
|
| + FallbackServiceFactory _fallbackServiceFactory;
|
|
|
| ApplicationConnection(ServiceProviderStub stub, ServiceProviderProxy proxy)
|
| : remoteServiceProvider = proxy {
|
| @@ -70,13 +70,20 @@ class ApplicationConnection {
|
| new LocalServiceProvider(this, stub);
|
| }
|
|
|
| - bindings.Proxy requestService(bindings.Proxy proxy) {
|
| - assert(!proxy.isBound &&
|
| + FallbackServiceFactory get fallbackServiceFactory => _fallbackServiceFactory;
|
| + set fallbackServiceFactory(FallbackServiceFactory f) {
|
| + assert(_localServiceProvider != null);
|
| + _fallbackServiceFactory = f;
|
| + }
|
| +
|
| + bindings.ProxyBase requestService(bindings.ProxyBase proxy) {
|
| + assert(!proxy.impl.isBound &&
|
| (remoteServiceProvider != null) &&
|
| - remoteServiceProvider.isBound);
|
| + remoteServiceProvider.impl.isBound);
|
| var pipe = new core.MojoMessagePipe();
|
| - proxy.bind(pipe.endpoints[0]);
|
| - remoteServiceProvider.connectToService(proxy.name, pipe.endpoints[1]);
|
| + proxy.impl.bind(pipe.endpoints[0]);
|
| + remoteServiceProvider.ptr.connectToService(
|
| + proxy.name, pipe.endpoints[1]);
|
| return proxy;
|
| }
|
|
|
| @@ -86,7 +93,8 @@ class ApplicationConnection {
|
| }
|
|
|
| void listen() {
|
| - if (_localServiceProvider != null) _localServiceProvider.listen();
|
| + assert(_localServiceProvider != null);
|
| + _localServiceProvider.listen();
|
| }
|
|
|
| void close({bool nodefer: false}) {
|
|
|