| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 assert(_pingPongClient == null); | 44 assert(_pingPongClient == null); |
| 45 _pingPongClient = proxyBase; | 45 _pingPongClient = proxyBase; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ping(int pingValue) { | 48 void ping(int pingValue) { |
| 49 if (_pingPongClient != null) { | 49 if (_pingPongClient != null) { |
| 50 _pingPongClient.ptr.pong(pingValue + 1); | 50 _pingPongClient.ptr.pong(pingValue + 1); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 Future pingTargetUrl(String url, int count, Function responseFactory) async { | 54 Future pingTargetUrl(String url, int count, |
| 55 [Function responseFactory]) async { |
| 55 if (_application == null) { | 56 if (_application == null) { |
| 56 return responseFactory(false); | 57 return responseFactory(false); |
| 57 } | 58 } |
| 58 var completer = new Completer(); | 59 var completer = new Completer(); |
| 59 var pingPongService = new PingPongServiceProxy.unbound(); | 60 var pingPongService = new PingPongServiceProxy.unbound(); |
| 60 _application.connectToService(url, pingPongService); | 61 _application.connectToService(url, pingPongService); |
| 61 | 62 |
| 62 var pingPongClient = new PingPongClientImpl.unbound(count, completer); | 63 var pingPongClient = new PingPongClientImpl.unbound(count, completer); |
| 63 pingPongService.ptr.setClient(pingPongClient.stub); | 64 pingPongService.ptr.setClient(pingPongClient.stub); |
| 64 | 65 |
| 65 for (var i = 0; i < count; i++) { | 66 for (var i = 0; i < count; i++) { |
| 66 pingPongService.ptr.ping(i); | 67 pingPongService.ptr.ping(i); |
| 67 } | 68 } |
| 68 await completer.future; | 69 await completer.future; |
| 69 pingPongService.ptr.quit(); | 70 pingPongService.ptr.quit(); |
| 70 pingPongService.close(); | 71 pingPongService.close(); |
| 71 | 72 |
| 72 return responseFactory(true); | 73 return responseFactory(true); |
| 73 } | 74 } |
| 74 | 75 |
| 75 Future pingTargetService( | 76 Future pingTargetService(ProxyBase proxyBase, int count, |
| 76 ProxyBase proxyBase, int count, Function responseFactory) async { | 77 [Function responseFactory]) async { |
| 77 var pingPongService = proxyBase; | 78 var pingPongService = proxyBase; |
| 78 var completer = new Completer(); | 79 var completer = new Completer(); |
| 79 var client = new PingPongClientImpl.unbound(count, completer); | 80 var client = new PingPongClientImpl.unbound(count, completer); |
| 80 pingPongService.ptr.setClient(client.stub); | 81 pingPongService.ptr.setClient(client.stub); |
| 81 | 82 |
| 82 for (var i = 0; i < count; i++) { | 83 for (var i = 0; i < count; i++) { |
| 83 pingPongService.ptr.ping(i); | 84 pingPongService.ptr.ping(i); |
| 84 } | 85 } |
| 85 await completer.future; | 86 await completer.future; |
| 86 pingPongService.ptr.quit(); | 87 pingPongService.ptr.quit(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 110 void acceptConnection(String requestorUrl, String resolvedUrl, | 111 void acceptConnection(String requestorUrl, String resolvedUrl, |
| 111 ApplicationConnection connection) { | 112 ApplicationConnection connection) { |
| 112 connection.provideService(PingPongServiceName, | 113 connection.provideService(PingPongServiceName, |
| 113 (endpoint) => new PingPongServiceImpl(this, endpoint)); | 114 (endpoint) => new PingPongServiceImpl(this, endpoint)); |
| 114 } | 115 } |
| 115 } | 116 } |
| 116 | 117 |
| 117 main(List args) { | 118 main(List args) { |
| 118 MojoHandle appHandle = new MojoHandle(args[0]); | 119 MojoHandle appHandle = new MojoHandle(args[0]); |
| 119 String url = args[1]; | 120 String url = args[1]; |
| 120 new PingPongApplication.fromHandle(appHandle); | 121 new PingPongApplication.fromHandle(appHandle) |
| 122 ..onError = (() { |
| 123 assert(MojoHandle.reportLeakedHandles()); |
| 124 }); |
| 121 } | 125 } |
| OLD | NEW |