| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 'dart:isolate'; | 6 import 'dart:isolate'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 import 'mojo:bindings' as bindings; | 8 import 'mojo:bindings' as bindings; |
| 9 import 'mojo:core' as core; | 9 import 'mojo:core' as core; |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 default: | 104 default: |
| 105 throw new Exception("Unexpected case"); | 105 throw new Exception("Unexpected case"); |
| 106 break; | 106 break; |
| 107 } | 107 } |
| 108 return null; | 108 return null; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 class EchoProxy extends bindings.Proxy { | 113 class EchoProxy extends bindings.Proxy { |
| 114 EchoProxy(core.MojoMessagePipeEndpoint endpoint, {bool doListen: true, | 114 EchoProxy(core.MojoMessagePipeEndpoint endpoint) |
| 115 Function onClosed}) | 115 : super.fromEndpoint(endpoint); |
| 116 : super.fromEndpoint(endpoint, doListen: doListen, onClosed: onClosed); | |
| 117 | 116 |
| 118 Future<EchoStringResponse> echoString(String a) { | 117 Future<EchoStringResponse> echoString(String a) { |
| 119 // compose message. | 118 // compose message. |
| 120 var es = new EchoString(); | 119 var es = new EchoString(); |
| 121 es.a = a; | 120 es.a = a; |
| 122 return sendMessageWithRequestId( | 121 return sendMessageWithRequestId( |
| 123 es, | 122 es, |
| 124 kEchoString_name, | 123 kEchoString_name, |
| 125 -1, | 124 -1, |
| 126 bindings.MessageHeader.kMessageExpectsResponse); | 125 bindings.MessageHeader.kMessageExpectsResponse); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void closingProviderIsolate(core.MojoMessagePipeEndpoint endpoint) { | 187 void closingProviderIsolate(core.MojoMessagePipeEndpoint endpoint) { |
| 189 var provider = new EchoStub(endpoint); | 188 var provider = new EchoStub(endpoint); |
| 190 provider.close(); | 189 provider.close(); |
| 191 } | 190 } |
| 192 | 191 |
| 193 | 192 |
| 194 Future<bool> runOnClosedTest() async { | 193 Future<bool> runOnClosedTest() async { |
| 195 var testCompleter = new Completer(); | 194 var testCompleter = new Completer(); |
| 196 | 195 |
| 197 var pipe = new core.MojoMessagePipe(); | 196 var pipe = new core.MojoMessagePipe(); |
| 198 var proxy = new EchoProxy(pipe.endpoints[0], onClosed: () { | 197 var proxy = new EchoProxy(pipe.endpoints[0]); |
| 199 testCompleter.complete(true); | 198 proxy.onError = () => testCompleter.complete(true); |
| 200 }); | |
| 201 await Isolate.spawn(closingProviderIsolate, pipe.endpoints[1]); | 199 await Isolate.spawn(closingProviderIsolate, pipe.endpoints[1]); |
| 202 return testCompleter.future.timeout( | 200 return testCompleter.future.timeout( |
| 203 new Duration(seconds: 1), | 201 new Duration(seconds: 1), |
| 204 onTimeout: () => false); | 202 onTimeout: () => false); |
| 205 } | 203 } |
| 206 | 204 |
| 207 | 205 |
| 208 main() async { | 206 main() async { |
| 209 Expect.equals(kEchoesCount, await runTest()); | 207 Expect.equals(kEchoesCount, await runTest()); |
| 210 await runAwaitTest(); | 208 await runAwaitTest(); |
| 211 Expect.isTrue(await runOnClosedTest()); | 209 Expect.isTrue(await runOnClosedTest()); |
| 212 } | 210 } |
| OLD | NEW |