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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 bindings;
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 List<ServiceProvider> _providers;
13
14 Application(core.MojoMessagePipeEndpoint endpoint) :
15 _clients = [],
16 _providers = [],
17 super(endpoint);
18
19 Application.fromHandle(int shellHandle) :
20 _clients = [],
21 _providers = [],
22 super.fromHandle(shellHandle);
23
24 Function interfaceFactoryClosure();
25
26 void initialize(List<String> args) {
27 }
28
29 void acceptConnection(
30 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
31 var serviceProviderEndpoint =
32 new core.MojoMessagePipeEndpoint(serviceProviderHandle);
33 var serviceProvider =
34 new ServiceProvider(serviceProviderEndpoint, interfaceFactoryClosure());
35 serviceProvider.listen();
36 _providers.add(serviceProvider);
abarth-chromium 2015/01/10 04:46:25 What's this about?
zra 2015/01/16 00:33:40 Removed
37 }
38
39 core.MojoMessagePipeEndpoint connectToService(String url, String service) {
40 var serviceProviderPipe = new core.MojoMessagePipe();
41 var applicationPipe = new core.MojoMessagePipe();
42 var clientEndpoint = applicationPipe.endpoints[0];
43 var applicationEndpoint = applicationPipe.endpoints[1];
44 var serviceProviderClient = new service_provider.ServiceProviderClient(
45 serviceProviderPipe.endpoints[0]);
46 serviceProviderClient.open();
47 callConnectToApplication(url, serviceProviderPipe.endpoints[1].handle);
48 serviceProviderClient.callConnectToService(
49 service, applicationEndpoint.handle);
50 _clients.add(serviceProviderClient);
51 return clientEndpoint;
52 }
53
54 void close() {
55 _providers.forEach((p) => p.close());
56 _providers.clear();
57 _clients.forEach((c) => c.close());
58 _clients.clear();
59 super.close();
60 }
61 }
62
63
64 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
65 ClientApplication(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
66
67 ClientApplication.fromHandle(int shellHandle) : super.fromHandle(shellHandle);
68
69 Function interfaceFactoryClosure() => () => null;
70
71 void initialize(List<String> args) {
72 run(args);
73 }
74
75 void acceptConnection(
76 String requestorUrl, core.MojoHandle serviceProviderHandle) {
77 }
78
79 run(List<String> args) async;
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698