Index: mojo/public/dart/src/application.dart |
diff --git a/mojo/public/dart/src/application.dart b/mojo/public/dart/src/application.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1daa946265f87b97e351db82584a2c55b63bc047 |
--- /dev/null |
+++ b/mojo/public/dart/src/application.dart |
@@ -0,0 +1,77 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+part of bindings; |
abarth-chromium
2015/01/16 05:43:43
We should start a new package for these files. Th
zra
2015/01/16 17:54:51
Moved to an application library under //services/d
|
+ |
+// The Application interface doesn't explicitly have a Shell as a Client, but |
+// that is what is at the other end of the MessagePipe. |
+abstract class Application extends application.ApplicationInterface |
+ with shell.ShellCalls { |
+ List<service_provider.ServiceProviderClient> _clients; |
+ |
+ Application(core.MojoMessagePipeEndpoint endpoint) : |
+ _clients = [], |
+ super(endpoint); |
+ |
+ Application.fromHandle(core.MojoHandle shellHandle) : |
+ _clients = [], |
+ super.fromHandle(shellHandle); |
+ |
+ Function interfaceFactoryClosure(); |
+ |
+ void initialize(List<String> args) { |
+ } |
+ |
+ void acceptConnection( |
+ String requestorUrl, |
+ service_provider.ServiceProviderInterface services, |
+ service_provider.ServiceProviderClient exposedServices) { |
+ var serviceProvider = new ServiceProvider(interfaceFactoryClosure()); |
+ services.delegate = serviceProvider; |
+ services.listen(); |
+ } |
+ |
+ core.MojoMessagePipeEndpoint connectToService(String url, String service) { |
+ var applicationPipe = new core.MojoMessagePipe(); |
+ var clientEndpoint = applicationPipe.endpoints[0]; |
+ var applicationEndpoint = applicationPipe.endpoints[1]; |
+ var serviceProviderClient = |
+ new service_provider.ServiceProviderClient.unbound(); |
+ callConnectToApplication(url, serviceProviderClient, null); |
+ serviceProviderClient.callConnectToService(service, applicationEndpoint); |
+ _clients.add(serviceProviderClient); |
+ return clientEndpoint; |
+ } |
+ |
+ void close() { |
+ _clients.forEach((c) => c.close()); |
+ _clients.clear(); |
+ super.close(); |
+ } |
+} |
+ |
+ |
+// TODO(zra): Is this generally useful? If not remove. |
+// A ClientApplication is a Mojo Application that does not provide any |
+// services (does not implement any interfaces). |
+abstract class ClientApplication extends Application { |
+ ClientApplication(core.MojoMessagePipeEndpoint endpoint) : super(endpoint); |
+ |
+ ClientApplication.fromHandle(core.MojoHandle shellHandle) : |
+ super.fromHandle(shellHandle); |
+ |
+ Function interfaceFactoryClosure() => () => null; |
+ |
+ void initialize(List<String> args) { |
+ run(args); |
+ } |
+ |
+ void acceptConnection( |
+ String requestorUrl, |
+ service_provider.ServiceProviderInterface services, |
+ service_provider.ServiceProviderClient exposedServices) { |
+ } |
+ |
+ run(List<String> args) async; |
+} |