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

Unified Diff: mojo/public/dart/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: 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: 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..0b5e99b853bfb3f2e9b6c545325dc7a123441a9d
--- /dev/null
+++ b/mojo/public/dart/src/application.dart
@@ -0,0 +1,80 @@
+// 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;
+
+// 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;
+ List<ServiceProvider> _providers;
+
+ Application(core.MojoMessagePipeEndpoint endpoint) :
+ _clients = [],
+ _providers = [],
+ super(endpoint);
+
+ Application.fromHandle(int shellHandle) :
+ _clients = [],
+ _providers = [],
+ super.fromHandle(shellHandle);
+
+ Function interfaceFactoryClosure();
+
+ void initialize(List<String> args) {
+ }
+
+ void acceptConnection(
+ String requestorUrl, core.MojoHandle serviceProviderHandle) {
abarth-chromium 2015/01/10 04:46:25 Can this have a stronger type? Ideally the bindin
zra 2015/01/16 00:33:40 Better types added with https://codereview.chromiu
+ var serviceProviderEndpoint =
+ new core.MojoMessagePipeEndpoint(serviceProviderHandle);
+ var serviceProvider =
+ new ServiceProvider(serviceProviderEndpoint, interfaceFactoryClosure());
+ serviceProvider.listen();
+ _providers.add(serviceProvider);
abarth-chromium 2015/01/10 04:46:25 What's this about?
zra 2015/01/16 00:33:40 Removed
+ }
+
+ core.MojoMessagePipeEndpoint connectToService(String url, String service) {
+ var serviceProviderPipe = new core.MojoMessagePipe();
+ var applicationPipe = new core.MojoMessagePipe();
+ var clientEndpoint = applicationPipe.endpoints[0];
+ var applicationEndpoint = applicationPipe.endpoints[1];
+ var serviceProviderClient = new service_provider.ServiceProviderClient(
+ serviceProviderPipe.endpoints[0]);
+ serviceProviderClient.open();
+ callConnectToApplication(url, serviceProviderPipe.endpoints[1].handle);
+ serviceProviderClient.callConnectToService(
+ service, applicationEndpoint.handle);
+ _clients.add(serviceProviderClient);
+ return clientEndpoint;
+ }
+
+ void close() {
+ _providers.forEach((p) => p.close());
+ _providers.clear();
+ _clients.forEach((c) => c.close());
+ _clients.clear();
+ super.close();
+ }
+}
+
+
+abstract class ClientApplication extends Application {
abarth-chromium 2015/01/10 04:46:25 What's the difference between a ClientApplication
zra 2015/01/16 00:33:40 Added a comment. Will remove if this turns out not
+ ClientApplication(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
+
+ ClientApplication.fromHandle(int shellHandle) : super.fromHandle(shellHandle);
+
+ Function interfaceFactoryClosure() => () => null;
+
+ void initialize(List<String> args) {
+ run(args);
+ }
+
+ void acceptConnection(
+ String requestorUrl, core.MojoHandle serviceProviderHandle) {
+ }
+
+ run(List<String> args) async;
+}

Powered by Google App Engine
This is Rietveld 408576698