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

Unified Diff: bin/inference/server.dart

Issue 1372333002: Add measurements and send-metrics to dart2js's info. (Closed) Base URL: git@github.com:dart-lang/dart2js_info.git@master
Patch Set: 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
Index: bin/inference/server.dart
diff --git a/bin/inference/server.dart b/bin/inference/server.dart
new file mode 100644
index 0000000000000000000000000000000000000000..594b7d3542799547cc004b92e9e2382e7f8fbd92
--- /dev/null
+++ b/bin/inference/server.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Server component to display inference results using a web app.
+library dart2js_info.bin.inference.server;
+
+import 'dart:io';
+import 'package:shelf/shelf.dart' as shelf;
+import 'package:shelf/shelf_io.dart' as shelf;
+import 'package:shelf_static/shelf_static.dart' as shelf_static;
+
+String jsonDataFile;
+String indexFile;
+String scriptFile;
+
+main(args) async {
+ var host = 'localhost';
+ var port = 8080;
+
+ jsonDataFile = args.length > 0 ? args[0] : 'out.js.stats.json';
+ indexFile = Platform.script.resolve('index.html').path;
+ scriptFile = Platform.script.resolve('client.dart.js').path;
+
+ await shelf.serve(_handler, host, port);
+}
+
+_handler(shelf.Request request) async {
+ var path = request.url.path;
+ if (path == 'data') {
+ return new shelf.Response.ok(await new File(jsonDataFile).readAsString());
+ }
+ if (path == 'client.dart.js') {
+ return new shelf.Response.ok(await new File(scriptFile).readAsString(),
+ headers: JS_HEADERS);
+ }
+ if (path.startsWith('file/')) {
+ return _fileHandler(request.change(path: 'file'));
+ }
+ return new shelf.Response.ok(await new File(indexFile).readAsString(),
+ headers: HTML_HEADERS);
+}
+
+final _fileHandler = shelf_static.createStaticHandler('/');
+const HTML_HEADERS = const {'content-type': 'text/html'};
+const JS_HEADERS = const {'content-type': 'text/javascript'};
« no previous file with comments | « bin/inference/print_summary.dart ('k') | lib/info.dart » ('j') | lib/src/table.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698