| 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 | 6 |
| 7 import 'package:mojo/application.dart'; | 7 import 'package:mojo/application.dart'; |
| 8 import 'package:mojo/bindings.dart'; | 8 import 'package:mojo/bindings.dart'; |
| 9 import 'package:mojo/core.dart'; | 9 import 'package:mojo/core.dart'; |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 var targetServiceProxy = new PingPongServiceProxy.unbound(); | 93 var targetServiceProxy = new PingPongServiceProxy.unbound(); |
| 94 _application.connectToService( | 94 _application.connectToService( |
| 95 "mojo:dart_pingpong_target", targetServiceProxy); | 95 "mojo:dart_pingpong_target", targetServiceProxy); |
| 96 | 96 |
| 97 // Pass along the interface request to another implementation of the | 97 // Pass along the interface request to another implementation of the |
| 98 // service. | 98 // service. |
| 99 targetServiceProxy.ptr.getPingPongService(serviceStub); | 99 targetServiceProxy.ptr.getPingPongService(serviceStub); |
| 100 targetServiceProxy.close(); | 100 targetServiceProxy.close(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 getPingPongServiceDelayed(PingPongServiceStub serviceStub) { |
| 104 Timer.run(() { |
| 105 var endpoint = serviceStub.unbind(); |
| 106 new Timer(const Duration(milliseconds: 10), () { |
| 107 var targetServiceProxy = new PingPongServiceProxy.unbound(); |
| 108 _application.connectToService( |
| 109 "mojo:dart_pingpong_target", targetServiceProxy); |
| 110 |
| 111 // Pass along the interface request to another implementation of the |
| 112 // service. |
| 113 serviceStub.bind(endpoint); |
| 114 targetServiceProxy.ptr.getPingPongService(serviceStub); |
| 115 targetServiceProxy.close(); |
| 116 }); |
| 117 }); |
| 118 } |
| 119 |
| 103 void quit() {} | 120 void quit() {} |
| 104 } | 121 } |
| 105 | 122 |
| 106 class PingPongApplication extends Application { | 123 class PingPongApplication extends Application { |
| 107 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); | 124 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); |
| 108 | 125 |
| 109 @override | 126 @override |
| 110 void acceptConnection(String requestorUrl, String resolvedUrl, | 127 void acceptConnection(String requestorUrl, String resolvedUrl, |
| 111 ApplicationConnection connection) { | 128 ApplicationConnection connection) { |
| 112 // No services are required from the remote end. | 129 // No services are required from the remote end. |
| 113 connection.remoteServiceProvider.close(); | 130 connection.remoteServiceProvider.close(); |
| 114 | 131 |
| 115 connection.provideService(PingPongService.serviceName, | 132 connection.provideService(PingPongService.serviceName, |
| 116 (endpoint) => new PingPongServiceImpl(this, endpoint), | 133 (endpoint) => new PingPongServiceImpl(this, endpoint), |
| 117 description: PingPongServiceStub.serviceDescription); | 134 description: PingPongServiceStub.serviceDescription); |
| 118 } | 135 } |
| 119 } | 136 } |
| 120 | 137 |
| 121 main(List args, Object handleToken) { | 138 main(List args, Object handleToken) { |
| 122 MojoHandle appHandle = new MojoHandle(handleToken); | 139 MojoHandle appHandle = new MojoHandle(handleToken); |
| 123 new PingPongApplication.fromHandle(appHandle) | 140 new PingPongApplication.fromHandle(appHandle) |
| 124 ..onError = ((_) { | 141 ..onError = ((_) { |
| 125 MojoHandle.reportLeakedHandles(); | 142 MojoHandle.reportLeakedHandles(); |
| 126 }); | 143 }); |
| 127 } | 144 } |
| OLD | NEW |