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

Unified Diff: lib/src/runner/browser/server.dart

Issue 1417943004: Use shelf's Server API in browser/server. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 2 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 | « no previous file | lib/src/util/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/browser/server.dart
diff --git a/lib/src/runner/browser/server.dart b/lib/src/runner/browser/server.dart
index b0505d715979bf8c500713cda9f8472c7b02bbab..477f86ca9ccb719d1dd84dd520a7477f01f0aaed 100644
--- a/lib/src/runner/browser/server.dart
+++ b/lib/src/runner/browser/server.dart
@@ -41,13 +41,12 @@ class BrowserServer {
/// the working directory.
static Future<BrowserServer> start(Configuration config, {String root})
async {
- var server = new BrowserServer._(root, config);
- await server._load();
- return server;
+ var server = new shelf_io.IOServer(await HttpMultiServer.loopback(0));
+ return new BrowserServer(server, config, root: root);
}
- /// The underlying HTTP server.
- HttpServer _server;
+ /// The underlying server.
+ final shelf.Server _server;
/// A randomly-generated secret.
///
@@ -56,8 +55,7 @@ class BrowserServer {
final _secret = randomBase64(24, urlSafe: true);
/// The URL for this server.
- Uri get url => baseUrlForAddress(_server.address, _server.port)
- .resolve(_secret + "/");
+ Uri get url => _server.url.resolve(_secret + "/");
/// The test runner configuration.
Configuration _config;
@@ -115,15 +113,12 @@ class BrowserServer {
final _mappers = new Map<String, StackTraceMapper>();
- BrowserServer._(String root, Configuration config)
+ BrowserServer(this._server, Configuration config, {String root})
: _root = root == null ? p.current : root,
_config = config,
_compiledDir = config.pubServeUrl == null ? createTempDir() : null,
_http = config.pubServeUrl == null ? null : new HttpClient(),
- _compilers = new CompilerPool(color: config.color);
-
- /// Starts the underlying server.
- Future _load() async {
+ _compilers = new CompilerPool(color: config.color) {
var cascade = new shelf.Cascade()
.add(_webSocketHandler.handler);
@@ -139,8 +134,7 @@ class BrowserServer {
.addMiddleware(nestingMiddleware(_secret))
.addHandler(cascade.handler);
- _server = await HttpMultiServer.loopback(0);
- shelf_io.serveRequests(_server, pipeline);
+ _server.mount(pipeline);
}
/// Returns a handler that serves the contents of the "packages/" directory
« no previous file with comments | « no previous file | lib/src/util/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698