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

Side by Side Diff: mojo/dart/apptests/test_apps/pingpong/lib/main.dart

Issue 1983453002: Dart: Refactor Stubs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 7 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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.getPingPongService(serviceStub); 99 targetServiceProxy.getPingPongService(serviceStub);
100 targetServiceProxy.close(); 100 targetServiceProxy.close();
101 } 101 }
102 102
103 getPingPongServiceDelayed(PingPongServiceStub serviceStub) { 103 getPingPongServiceDelayed(PingPongServiceStub serviceStub) {
104 Timer.run(() { 104 Timer.run(() {
105 var endpoint = serviceStub.unbind(); 105 var endpoint = serviceStub.ctrl.unbind();
106 new Timer(const Duration(milliseconds: 10), () { 106 new Timer(const Duration(milliseconds: 10), () {
107 var targetServiceProxy = new PingPongServiceProxy.unbound(); 107 var targetServiceProxy = new PingPongServiceProxy.unbound();
108 _application.connectToService( 108 _application.connectToService(
109 "mojo:dart_pingpong_target", targetServiceProxy); 109 "mojo:dart_pingpong_target", targetServiceProxy);
110 110
111 // Pass along the interface request to another implementation of the 111 // Pass along the interface request to another implementation of the
112 // service. 112 // service.
113 serviceStub.bind(endpoint); 113 serviceStub.ctrl.bind(endpoint);
114 targetServiceProxy.getPingPongService(serviceStub); 114 targetServiceProxy.getPingPongService(serviceStub);
115 targetServiceProxy.close(); 115 targetServiceProxy.close();
116 }); 116 });
117 }); 117 });
118 } 118 }
119 119
120 void quit() {} 120 void quit() {}
121 } 121 }
122 122
123 class PingPongApplication extends Application { 123 class PingPongApplication extends Application {
124 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle); 124 PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);
125 125
126 @override 126 @override
127 void acceptConnection(String requestorUrl, String resolvedUrl, 127 void acceptConnection(String requestorUrl, String resolvedUrl,
128 ApplicationConnection connection) { 128 ApplicationConnection connection) {
129 connection.provideService(PingPongService.serviceName, 129 connection.provideService(PingPongService.serviceName,
130 (endpoint) => new PingPongServiceImpl(this, endpoint), 130 (endpoint) => new PingPongServiceImpl(this, endpoint),
131 description: PingPongServiceStub.serviceDescription); 131 description: PingPongServiceStub.serviceDescription);
132 } 132 }
133 } 133 }
134 134
135 main(List args, Object handleToken) { 135 main(List args, Object handleToken) {
136 MojoHandle appHandle = new MojoHandle(handleToken); 136 MojoHandle appHandle = new MojoHandle(handleToken);
137 new PingPongApplication.fromHandle(appHandle) 137 new PingPongApplication.fromHandle(appHandle)
138 ..onError = ((_) { 138 ..onError = ((_) {
139 MojoHandle.reportLeakedHandles(); 139 MojoHandle.reportLeakedHandles();
140 }); 140 });
141 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698