OLD | NEW |
---|---|
(Empty) | |
1 #!mojo mojo:dart_content_handler | |
2 | |
3 // Copyright 2014 The Chromium Authors. All rights reserved. | |
4 // Use of this source code is governed by a BSD-style license that can be | |
5 // found in the LICENSE file. | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:mojo_application'; | |
9 import 'dart:mojo_bindings'; | |
10 import 'dart:mojo_core'; | |
11 | |
12 import 'package:services/dart/test/echo_service.mojom.dart'; | |
13 | |
14 // TODO(zra): Interface implementations that delegate to another implementation | |
15 // will all look the same, more or less. Maybe we should generate them? | |
abarth-chromium
2015/01/18 22:19:02
Yeah, we generate them in JavaScript.
zra
2015/01/20 17:36:51
There is a simple way to remove this. I'll clean i
| |
16 class EchoServiceImpl extends EchoServiceInterface { | |
17 EchoServiceInterface _delegate; | |
18 | |
19 EchoServiceImpl(this._delegate, MojoMessagePipeEndpoint endpoint) : | |
20 super(endpoint); | |
21 | |
22 echoString(String value) => _delegate.echoString(value); | |
23 } | |
24 | |
25 class EchoApplication extends Application implements EchoServiceInterface { | |
26 EchoApplication(MojoMessagePipeEndpoint endpoint) : super(endpoint); | |
27 | |
28 EchoApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); | |
abarth-chromium
2015/01/18 22:19:02
It's too bad we need both these constructors. The
abarth-chromium
2015/01/18 22:19:02
It's too bad we need both these constructors. See
zra
2015/01/20 17:36:51
I'll try to clean up in the next CL.
| |
29 | |
30 Function interfaceFactoryClosure() { | |
31 return (endpoint) => new EchoServiceImpl(this, endpoint); | |
32 } | |
33 | |
34 echoString(String value) { | |
35 var response = new EchoServiceEchoStringResponseParams(); | |
abarth-chromium
2015/01/18 22:19:02
In other languages, we're able to bury the EchoSer
zra
2015/01/20 17:36:51
I'll try to clean up in the next CL.
| |
36 if (value == 'quit') { | |
37 close(); | |
38 } | |
39 response.value = value; | |
40 return new Future.value(response); | |
41 } | |
42 } | |
43 | |
44 main(List args) { | |
45 MojoHandle shellHandle = new MojoHandle(args[0]); | |
46 String url = args[1]; | |
47 var echoApplication = new EchoApplication.fromHandle(shellHandle); | |
48 echoApplication.listen(); | |
49 } | |
OLD | NEW |