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

Side by Side Diff: services/dart/test/pingpong_target/lib/main.dart

Issue 1545483003: Dart: Reorganize files (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix build file Created 4 years, 12 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 2015 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 import 'dart:async';
6
7 import 'package:mojo/application.dart';
8 import 'package:mojo/bindings.dart';
9 import 'package:mojo/core.dart';
10
11 import 'package:_mojo_for_test_only/test/pingpong_service.mojom.dart';
12
13 class PingPongServiceImpl implements PingPongService {
14 PingPongServiceStub _stub;
15 Application _application;
16 PingPongClientProxy _pingPongClient;
17
18 PingPongServiceImpl(this._application, MojoMessagePipeEndpoint endpoint) {
19 _stub = new PingPongServiceStub.fromEndpoint(endpoint, this);
20 }
21
22 void setClient(ProxyBase proxyBase) {
23 assert(_pingPongClient == null);
24 _pingPongClient = proxyBase;
25 }
26
27 void ping(int pingValue) => _pingPongClient.ptr.pong(pingValue + 1);
28
29 // These methods are unimplemented; they merely throw on invocation.
30 dynamic pingTargetUrl(String url, int count, [Function responseFactory]) =>
31 throw "Unimplemented";
32 dynamic pingTargetService(
33 Object service, int count, [Function responseFactory]) =>
34 throw "Unimplemented";
35 void getPingPongService(Object service) => throw "Unimplemented";
36
37 void quit() {
38 if (_pingPongClient != null) {
39 _pingPongClient.close();
40 _pingPongClient = null;
41 }
42 _stub.close();
43 }
44 }
45
46 class PingPongApplication extends Application {
47 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);
48
49 @override
50 void acceptConnection(String requestorUrl, String resolvedUrl,
51 ApplicationConnection connection) {
52 connection.provideService(PingPongService.serviceName,
53 (endpoint) => new PingPongServiceImpl(this, endpoint));
54 // Close the application when the first connection goes down.
55 connection.onError = ((_) => closeApplication());
56 }
57
58 Future closeApplication() async {
59 await close();
60 MojoHandle.reportLeakedHandles();
61 }
62 }
63
64 main(List args) {
65 MojoHandle appHandle = new MojoHandle(args[0]);
66 String url = args[1];
67 new PingPongApplication.fromHandle(appHandle);
68 }
OLDNEW
« no previous file with comments | « services/dart/test/pingpong_target/BUILD.gn ('k') | services/dart/test/pingpong_target/pubspec.lock » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698