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

Unified Diff: tests/standalone/io/http_advanced_test.dart

Issue 10837070: Remove old isolate API and update all code in the repository to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 5 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
« no previous file with comments | « tests/standalone/io/echo_server_test.dart ('k') | tests/standalone/io/http_basic_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_advanced_test.dart
diff --git a/tests/standalone/io/http_advanced_test.dart b/tests/standalone/io/http_advanced_test.dart
index 3b0ee32de26037997580657f23b1e7b1ba8b4ea1..aa96e683575ba75b9473d9a1c0ae4cbd45a493ae 100644
--- a/tests/standalone/io/http_advanced_test.dart
+++ b/tests/standalone/io/http_advanced_test.dart
@@ -14,9 +14,7 @@ class TestServerMain {
TestServerMain()
: _statusPort = new ReceivePort(),
_serverPort = null {
- new TestServer().spawn().then((SendPort port) {
- _serverPort = port;
- });
+ _serverPort = spawnFunction(startTestServer);
}
void setServerStartedHandler(void startedCallback(int port)) {
@@ -91,7 +89,14 @@ class TestServerStatus {
}
-class TestServer extends Isolate {
+void startTestServer() {
+ var server = new TestServer();
+ server.init();
+ port.receive(server.dispatch);
+}
+
+
+class TestServer {
// Return a 404.
void _notFoundHandler(HttpRequest request, HttpResponse response) {
response.statusCode = HttpStatus.NOT_FOUND;
@@ -173,7 +178,7 @@ class TestServer extends Isolate {
response.outputStream.close();
}
- void main() {
+ void init() {
// Setup request handlers.
_requestHandlers = new Map();
_requestHandlers["/host"] =
@@ -204,27 +209,27 @@ class TestServer extends Isolate {
(HttpRequest request, HttpResponse response) {
_cookie2Handler(request, response);
};
+ }
- this.port.receive((var message, SendPort replyTo) {
- if (message.isStart) {
- _server = new HttpServer();
- try {
- _server.listen("127.0.0.1", 0);
- _server.defaultRequestHandler = (HttpRequest req, HttpResponse rsp) {
- _requestReceivedHandler(req, rsp);
- };
- replyTo.send(new TestServerStatus.started(_server.port), null);
- } catch (var e) {
- replyTo.send(new TestServerStatus.error(), null);
- }
- } else if (message.isStop) {
- _server.close();
- this.port.close();
- replyTo.send(new TestServerStatus.stopped(), null);
- } else if (message.isChunkedEncoding) {
- _chunkedEncoding = true;
+ void dispatch(message, replyTo) {
+ if (message.isStart) {
+ _server = new HttpServer();
+ try {
+ _server.listen("127.0.0.1", 0);
+ _server.defaultRequestHandler = (HttpRequest req, HttpResponse rsp) {
+ _requestReceivedHandler(req, rsp);
+ };
+ replyTo.send(new TestServerStatus.started(_server.port), null);
+ } catch (var e) {
+ replyTo.send(new TestServerStatus.error(), null);
}
- });
+ } else if (message.isStop) {
+ _server.close();
+ port.close();
+ replyTo.send(new TestServerStatus.stopped(), null);
+ } else if (message.isChunkedEncoding) {
+ _chunkedEncoding = true;
+ }
}
void _requestReceivedHandler(HttpRequest request, HttpResponse response) {
« no previous file with comments | « tests/standalone/io/echo_server_test.dart ('k') | tests/standalone/io/http_basic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698