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

Unified Diff: services/dart/test/pingpong/main.dart

Issue 959993002: Dart: Removes name conflicts from generated bindings. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Removes unused constructors Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: services/dart/test/pingpong/main.dart
diff --git a/services/dart/test/pingpong/main.dart b/services/dart/test/pingpong/main.dart
index 40f53057a56b84764586c609e274791b4e5c424e..01dd1cb95cce6bd5b101c3a4da5d7c214bbc850f 100644
--- a/services/dart/test/pingpong/main.dart
+++ b/services/dart/test/pingpong/main.dart
@@ -9,95 +9,102 @@ import 'mojo:core';
import 'package:services/dart/test/pingpong_service.mojom.dart';
-class PingPongClientImpl extends PingPongClient {
+class PingPongClientImpl implements PingPongClient {
+ final PingPongClientStub stub;
Completer _completer;
int _count;
- PingPongClientImpl.unbound(this._count, this._completer) : super.unbound() {
- super.delegate = this;
+ PingPongClientImpl.unbound(this._count, this._completer)
+ : stub = new PingPongClientStub.unbound() {
+ stub.delegate = this;
}
void pong(int pongValue) {
if (pongValue == _count) {
_completer.complete(null);
- close();
+ stub.close();
}
}
}
-class PingPongServiceImpl extends PingPongService {
+class PingPongServiceImpl implements PingPongService {
+ PingPongServiceStub _stub;
Application _application;
- PingPongClientProxy _proxy;
+ PingPongClientProxy _pingPongClient;
PingPongServiceImpl(Application application, MojoMessagePipeEndpoint endpoint)
- : _application = application, super(endpoint) {
- super.delegate = this;
+ : _application = application {
+ _stub = new PingPongServiceStub.fromEndpoint(endpoint)
+ ..delegate = this
+ ..listen();
}
- PingPongServiceImpl.fromStub(PingPongServiceStub stub)
- : super.fromStub(stub) {
- super.delegate = this;
+ PingPongServiceImpl.fromStub(this._stub) {
+ _stub.delegate = this;
}
- void setClient(PingPongClientProxy proxy) {
- assert(_proxy == null);
- _proxy = proxy;
+ listen() => _stub.listen();
+
+ void setClient(ProxyBase proxyBase) {
+ assert(_pingPongClient== null);
+ _pingPongClient = proxyBase;
}
void ping(int pingValue) {
- if (_proxy != null) {
- _proxy.pong(pingValue + 1);
+ if (_pingPongClient != null) {
+ _pingPongClient.ptr.pong(pingValue + 1);
}
}
- pingTargetUrl(String url, int count, Function responseFactory) async {
+ Future pingTargetUrl(String url, int count, Function responseFactory) async {
if (_application == null) {
return responseFactory(false);
}
var completer = new Completer();
- var pingPongService = new PingPongServiceProxy.unbound();
+ var pingPongService= new PingPongServiceProxy.unbound();
_application.connectToService(url, pingPongService);
var pingPongClient = new PingPongClientImpl.unbound(count, completer);
- pingPongService.setClient(pingPongClient.stub);
- pingPongClient.listen();
+ pingPongService.ptr.setClient(pingPongClient.stub);
+ pingPongClient.stub.listen();
for (var i = 0; i < count; i++) {
- pingPongService.ping(i);
+ pingPongService.ptr.ping(i);
}
await completer.future;
- pingPongService.quit();
+ pingPongService.ptr.quit();
return responseFactory(true);
}
- pingTargetService(PingPongServiceProxy pingPongService,
- int count,
- Function responseFactory) async {
+ Future pingTargetService(ProxyBase proxyBase,
+ int count,
+ Function responseFactory) async {
+ var pingPongService = proxyBase;
var completer = new Completer();
var client = new PingPongClientImpl.unbound(count, completer);
- pingPongService.setClient(client.stub);
- client.listen();
+ pingPongService.ptr.setClient(client.stub);
+ client.stub.listen();
for (var i = 0; i < count; i++) {
- pingPongService.ping(i);
+ pingPongService.ptr.ping(i);
}
await completer.future;
- pingPongService.quit();
+ pingPongService.ptr.quit();
return responseFactory(true);
}
getPingPongService(PingPongServiceStub serviceStub) {
- var pingPongService = new PingPongServiceImpl.fromStub(serviceStub);
- pingPongService.listen();
+ new PingPongServiceImpl.fromStub(serviceStub)..listen();
}
void quit() {
- if (_proxy != null) {
- _proxy.close();
+ if (_pingPongClient != null) {
+ _pingPongClient.close();
+ _pingPongClient = null;
}
- super.close();
+ _stub.close();
if (_application != null) {
_application.close();
}
@@ -108,7 +115,7 @@ class PingPongApplication extends Application {
PingPongApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);
void acceptConnection(String requestorUrl, ApplicationConnection connection) {
- connection.provideService(PingPongService.name,
+ connection.provideService(PingPongServiceName,
(endpoint) => new PingPongServiceImpl(this, endpoint));
connection.listen();
}
@@ -117,6 +124,5 @@ class PingPongApplication extends Application {
main(List args) {
MojoHandle appHandle = new MojoHandle(args[0]);
String url = args[1];
- var pingPongApplication = new PingPongApplication.fromHandle(appHandle);
- pingPongApplication.listen();
+ new PingPongApplication.fromHandle(appHandle);
}

Powered by Google App Engine
This is Rietveld 408576698