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

Side by Side Diff: pkg/analysis_server/lib/src/get_handler.dart

Issue 237643003: Split analysis server's HttpAnalysisServer into two classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing initialization of socketServer. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library get.handler; 5 library get.handler;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 10
11 import 'package:analysis_server/src/analysis_server.dart'; 11 import 'package:analysis_server/src/socket_server.dart';
12 12
13 /** 13 /**
14 * Instances of the class [GetHandler] handle GET requests. 14 * Instances of the class [GetHandler] handle GET requests.
15 */ 15 */
16 class GetHandler { 16 class GetHandler {
17 /** 17 /**
18 * The path used to request the status of the analysis server as a whole. 18 * The path used to request the status of the analysis server as a whole.
19 */ 19 */
20 static const String STATUS_PATH = '/status'; 20 static const String STATUS_PATH = '/status';
21 21
22 /** 22 /**
23 * The analysis server whose status is to be reported on, or `null` if the 23 * The socket server whose status is to be reported on.
24 * server has not yet been created.
25 */ 24 */
26 AnalysisServer server; 25 SocketServer _server;
27 26
28 /** 27 /**
29 * Initialize a newly created handler for GET requests. 28 * Initialize a newly created handler for GET requests.
30 */ 29 */
31 GetHandler(); 30 GetHandler(SocketServer this._server);
32 31
33 /** 32 /**
34 * Handle a GET request received by the HTTP server. 33 * Handle a GET request received by the HTTP server.
35 */ 34 */
36 void handleGetRequest(HttpRequest request) { 35 void handleGetRequest(HttpRequest request) {
37 String path = request.uri.path; 36 String path = request.uri.path;
38 if (path == STATUS_PATH) { 37 if (path == STATUS_PATH) {
39 _returnServerStatus(request); 38 _returnServerStatus(request);
40 } else { 39 } else {
41 _returnUnknownRequest(request); 40 _returnUnknownRequest(request);
42 } 41 }
43 } 42 }
44 43
45 /** 44 /**
46 * Return a response indicating the status of the analysis server. 45 * Return a response indicating the status of the analysis server.
47 */ 46 */
48 void _returnServerStatus(HttpRequest request) { 47 void _returnServerStatus(HttpRequest request) {
49 HttpResponse response = request.response; 48 HttpResponse response = request.response;
50 response.statusCode = HttpStatus.OK; 49 response.statusCode = HttpStatus.OK;
51 response.headers.add(HttpHeaders.CONTENT_TYPE, "text/html"); 50 response.headers.add(HttpHeaders.CONTENT_TYPE, "text/html");
52 response.write('<html>'); 51 response.write('<html>');
53 response.write('<head>'); 52 response.write('<head>');
54 response.write('<title>Dart Analysis Server - Status</title>'); 53 response.write('<title>Dart Analysis Server - Status</title>');
55 response.write('</head>'); 54 response.write('</head>');
56 response.write('<body>'); 55 response.write('<body>');
57 response.write('<h1>Analysis Server</h1>'); 56 response.write('<h1>Analysis Server</h1>');
58 if (server == null) { 57 if (_server.analysisServer == null) {
59 response.write('<p>Not running</p>'); 58 response.write('<p>Not running</p>');
60 } else { 59 } else {
61 response.write('<p>Running</p>'); 60 response.write('<p>Running</p>');
62 response.write('<h1>Analysis Contexts</h1>'); 61 response.write('<h1>Analysis Contexts</h1>');
63 response.write('<h2>Summary</h2>'); 62 response.write('<h2>Summary</h2>');
64 response.write('<table>'); 63 response.write('<table>');
65 _writeRow( 64 _writeRow(
66 response, 65 response,
67 ['Context', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], 66 ['Context', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'],
68 true); 67 true);
69 server.contextMap.forEach((String key, AnalysisContext context) { 68 _server.analysisServer.contextMap.forEach((String key, AnalysisContext con text) {
70 AnalysisContentStatistics statistics = 69 AnalysisContentStatistics statistics =
71 (context as AnalysisContextImpl).statistics; 70 (context as AnalysisContextImpl).statistics;
72 int errorCount = 0; 71 int errorCount = 0;
73 int flushedCount = 0; 72 int flushedCount = 0;
74 int inProcessCount = 0; 73 int inProcessCount = 0;
75 int invalidCount = 0; 74 int invalidCount = 0;
76 int validCount = 0; 75 int validCount = 0;
77 statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) { 76 statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) {
78 errorCount += row.errorCount; 77 errorCount += row.errorCount;
79 flushedCount += row.flushedCount; 78 flushedCount += row.flushedCount;
80 inProcessCount += row.inProcessCount; 79 inProcessCount += row.inProcessCount;
81 invalidCount += row.invalidCount; 80 invalidCount += row.invalidCount;
82 validCount += row.validCount; 81 validCount += row.validCount;
83 }); 82 });
84 _writeRow(response, [ 83 _writeRow(response, [
85 '<a href="#context_$key">$key</a>', 84 '<a href="#context_$key">$key</a>',
86 errorCount, 85 errorCount,
87 flushedCount, 86 flushedCount,
88 inProcessCount, 87 inProcessCount,
89 invalidCount, 88 invalidCount,
90 validCount]); 89 validCount]);
91 }); 90 });
92 response.write('</table>'); 91 response.write('</table>');
93 server.contextMap.forEach((String key, AnalysisContext context) { 92 _server.analysisServer.contextMap.forEach((String key, AnalysisContext con text) {
94 response.write('<h2><a name="context_$key">Analysis Context: $key}</a></ h2>'); 93 response.write('<h2><a name="context_$key">Analysis Context: $key}</a></ h2>');
95 AnalysisContentStatistics statistics = (context as AnalysisContextImpl). statistics; 94 AnalysisContentStatistics statistics = (context as AnalysisContextImpl). statistics;
96 response.write('<table>'); 95 response.write('<table>');
97 _writeRow( 96 _writeRow(
98 response, 97 response,
99 ['Item', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], 98 ['Item', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'],
100 true); 99 true);
101 statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) { 100 statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) {
102 _writeRow( 101 _writeRow(
103 response, 102 response,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 response.write(value); 150 response.write(value);
152 response.write('</td>'); 151 response.write('</td>');
153 }); 152 });
154 if (header) { 153 if (header) {
155 response.write('</th>'); 154 response.write('</th>');
156 } else { 155 } else {
157 response.write('</tr>'); 156 response.write('</tr>');
158 } 157 }
159 } 158 }
160 } 159 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/http_server.dart ('k') | pkg/analysis_server/lib/src/socket_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698