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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// Server component to display inference results using a web app.
6 library dart2js_info.bin.inference.server;
7
8 import 'dart:io';
9 import 'package:shelf/shelf.dart' as shelf;
10 import 'package:shelf/shelf_io.dart' as shelf;
11 import 'package:shelf_static/shelf_static.dart' as shelf_static;
12
13 String jsonDataFile;
14 String indexFile;
15 String scriptFile;
16
17 main(args) async {
18 var host = 'localhost';
19 var port = 8080;
20
21 jsonDataFile = args.length > 0 ? args[0] : 'out.js.stats.json';
22 indexFile = Platform.script.resolve('index.html').path;
23 scriptFile = Platform.script.resolve('client.dart.js').path;
24
25 await shelf.serve(_handler, host, port);
26 }
27
28 _handler(shelf.Request request) async {
29 var path = request.url.path;
30 if (path == 'data') {
31 return new shelf.Response.ok(await new File(jsonDataFile).readAsString());
32 }
33 if (path == 'client.dart.js') {
34 return new shelf.Response.ok(await new File(scriptFile).readAsString(),
35 headers: JS_HEADERS);
36 }
37 if (path.startsWith('file/')) {
38 return _fileHandler(request.change(path: 'file'));
39 }
40 return new shelf.Response.ok(await new File(indexFile).readAsString(),
41 headers: HTML_HEADERS);
42 }
43
44 final _fileHandler = shelf_static.createStaticHandler('/');
45 const HTML_HEADERS = const {'content-type': 'text/html'};
46 const JS_HEADERS = const {'content-type': 'text/javascript'};
OLDNEW
« 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