| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'mojo:application'; | 6 import 'mojo:application'; |
| 7 import 'mojo:bindings'; | 7 import 'mojo:bindings'; |
| 8 import 'mojo:core'; | 8 import 'mojo:core'; |
| 9 | 9 |
| 10 import 'package:services/dart/test/pingpong_service.mojom.dart'; | 10 import 'package:services/dart/test/pingpong_service.mojom.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 void ping(int pingValue) => _pingPongClient.ptr.pong(pingValue + 1); | 26 void ping(int pingValue) => _pingPongClient.ptr.pong(pingValue + 1); |
| 27 | 27 |
| 28 void quit() { | 28 void quit() { |
| 29 if (_pingPongClient != null) { | 29 if (_pingPongClient != null) { |
| 30 _pingPongClient.close(); | 30 _pingPongClient.close(); |
| 31 _pingPongClient = null; | 31 _pingPongClient = null; |
| 32 } | 32 } |
| 33 _stub.close(); | 33 _stub.close(); |
| 34 } | 34 } |
| 35 |
| 36 Future pingTargetUrl(String url, int count, [Function responseFactory]) {} |
| 37 |
| 38 Future pingTargetService(ProxyBase proxyBase, int count, |
| 39 [Function responseFactory]) {} |
| 40 |
| 41 getPingPongService(PingPongServiceStub serviceStub) {} |
| 35 } | 42 } |
| 36 | 43 |
| 37 class PingPongApplication extends Application { | 44 class PingPongApplication extends Application { |
| 38 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); | 45 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); |
| 39 | 46 |
| 40 @override | 47 @override |
| 41 void acceptConnection(String requestorUrl, String resolvedUrl, | 48 void acceptConnection(String requestorUrl, String resolvedUrl, |
| 42 ApplicationConnection connection) { | 49 ApplicationConnection connection) { |
| 43 connection.provideService(PingPongServiceName, | 50 connection.provideService(PingPongServiceName, |
| 44 (endpoint) => new PingPongServiceImpl(this, endpoint)); | 51 (endpoint) => new PingPongServiceImpl(this, endpoint)); |
| 45 // Close the application when the first connection goes down. | 52 // Close the application when the first connection goes down. |
| 46 connection.onError = close; | 53 connection.onError = closeApplication; |
| 54 } |
| 55 |
| 56 Future closeApplication() async { |
| 57 await close(); |
| 58 assert(MojoHandle.reportLeakedHandles()); |
| 47 } | 59 } |
| 48 } | 60 } |
| 49 | 61 |
| 50 main(List args) { | 62 main(List args) { |
| 51 MojoHandle appHandle = new MojoHandle(args[0]); | 63 MojoHandle appHandle = new MojoHandle(args[0]); |
| 52 String url = args[1]; | 64 String url = args[1]; |
| 53 new PingPongApplication.fromHandle(appHandle); | 65 new PingPongApplication.fromHandle(appHandle); |
| 54 } | 66 } |
| OLD | NEW |