OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 part of application; |
| 6 |
| 7 // The Application interface doesn't explicitly have a Shell as a Client, but |
| 8 // that is what is at the other end of the MessagePipe. |
| 9 abstract class Application extends application.ApplicationInterface |
| 10 with shell.ShellCalls { |
| 11 List<service_provider.ServiceProviderClient> _clients; |
| 12 |
| 13 Application(core.MojoMessagePipeEndpoint endpoint) : |
| 14 _clients = [], |
| 15 super(endpoint); |
| 16 |
| 17 Application.fromHandle(core.MojoHandle shellHandle) : |
| 18 _clients = [], |
| 19 super.fromHandle(shellHandle); |
| 20 |
| 21 Function interfaceFactoryClosure() => (endpoint) => null; |
| 22 |
| 23 void initialize(List<String> args) { |
| 24 } |
| 25 |
| 26 void acceptConnection( |
| 27 String requestorUrl, |
| 28 service_provider.ServiceProviderInterface services, |
| 29 service_provider.ServiceProviderClient exposedServices) { |
| 30 var closure = interfaceFactoryClosure(); |
| 31 if (closure != null) { |
| 32 var serviceProvider = new ServiceProvider(closure); |
| 33 services.delegate = serviceProvider; |
| 34 services.listen(); |
| 35 } |
| 36 } |
| 37 |
| 38 core.MojoMessagePipeEndpoint connectToService(String url, String service) { |
| 39 var applicationPipe = new core.MojoMessagePipe(); |
| 40 var clientEndpoint = applicationPipe.endpoints[0]; |
| 41 var applicationEndpoint = applicationPipe.endpoints[1]; |
| 42 var serviceProviderClient = |
| 43 new service_provider.ServiceProviderClient.unbound(); |
| 44 callConnectToApplication(url, serviceProviderClient, null); |
| 45 serviceProviderClient.callConnectToService(service, applicationEndpoint); |
| 46 _clients.add(serviceProviderClient); |
| 47 return clientEndpoint; |
| 48 } |
| 49 |
| 50 void close() { |
| 51 _clients.forEach((c) => c.close()); |
| 52 _clients.clear(); |
| 53 super.close(); |
| 54 } |
| 55 } |
OLD | NEW |