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

Unified Diff: pkg/compiler/tool/stats/server.dart

Issue 1220043005: dart2js send stats, includes: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
Index: pkg/compiler/tool/stats/server.dart
diff --git a/pkg/compiler/tool/stats/server.dart b/pkg/compiler/tool/stats/server.dart
new file mode 100644
index 0000000000000000000000000000000000000000..049af440fc91685a9285ca53a8f94694d2542470
--- /dev/null
+++ b/pkg/compiler/tool/stats/server.dart
@@ -0,0 +1,47 @@
+// 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 [GlobalResult]s using a web app.
+library compiler.tool.stats.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'};

Powered by Google App Engine
This is Rietveld 408576698