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

Unified Diff: services/dart/lib/src/application.dart

Issue 816113004: Dart: Adds a content handler and a test. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: comment Created 5 years, 11 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: services/dart/lib/src/application.dart
diff --git a/services/dart/lib/src/application.dart b/services/dart/lib/src/application.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d5c7fa18f7706d4415734877876741a1c13d6d45
--- /dev/null
+++ b/services/dart/lib/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 application;
+
+// 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
abarth-chromium 2015/01/18 22:19:02 The way we've been naming things in C++ is to have
abarth-chromium 2015/01/18 22:19:02 The way we've been naming things in C++ is to have
zra 2015/01/20 17:36:51 Added TODO in the interface template.
+ with shell.ShellCalls {
abarth-chromium 2015/01/18 22:19:02 What is ShellCalls?
zra 2015/01/20 17:36:51 I have (partly) implemented Client= using Dart mix
+ 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);
abarth-chromium 2015/01/18 22:19:02 callConnectToApplication ? Why not connectToAppli
zra 2015/01/20 17:36:51 This is more cruftiness related to Client=. Since
+ 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).
abarth-chromium 2015/01/18 22:19:02 I'd remove this. We don't have this concept in th
zra 2015/01/20 17:36:51 Done.
+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;
+}

Powered by Google App Engine
This is Rietveld 408576698