OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of vmservice; | 5 part of vmservice; |
6 | 6 |
7 class RunningIsolates implements ServiceRequestRouter { | 7 class RunningIsolates implements ServiceRequestRouter { |
8 final Map<int, RunningIsolate> isolates = new Map<int, RunningIsolate>(); | 8 final Map<int, RunningIsolate> isolates = new Map<int, RunningIsolate>(); |
9 | 9 |
10 RunningIsolates(); | 10 RunningIsolates(); |
(...skipping 17 matching lines...) Expand all Loading... |
28 var members = []; | 28 var members = []; |
29 var result = {}; | 29 var result = {}; |
30 isolates.forEach((sp, ri) { | 30 isolates.forEach((sp, ri) { |
31 members.add({ | 31 members.add({ |
32 'id': sp, | 32 'id': sp, |
33 'name': ri.name | 33 'name': ri.name |
34 }); | 34 }); |
35 }); | 35 }); |
36 result['type'] = 'IsolateList'; | 36 result['type'] = 'IsolateList'; |
37 result['members'] = members; | 37 result['members'] = members; |
38 request.setResponse(JSON.stringify(result)); | 38 request.setResponse(JSON.encode(result)); |
39 } | 39 } |
40 | 40 |
41 Future route(ServiceRequest request) { | 41 Future route(ServiceRequest request) { |
42 if (request.pathSegments.length == 0) { | 42 if (request.pathSegments.length == 0) { |
43 return null; | 43 return null; |
44 } | 44 } |
45 if (request.pathSegments[0] != 'isolates') { | 45 if (request.pathSegments[0] != 'isolates') { |
46 return null; | 46 return null; |
47 } | 47 } |
48 if (request.pathSegments.length == 1) { | 48 if (request.pathSegments.length == 1) { |
(...skipping 16 matching lines...) Expand all Loading... |
65 // Consume '/isolates/isolateId' | 65 // Consume '/isolates/isolateId' |
66 request.pathSegments.removeRange(0, 2); | 66 request.pathSegments.removeRange(0, 2); |
67 if (request.pathSegments.length == 0) { | 67 if (request.pathSegments.length == 0) { |
68 // The request is now empty. | 68 // The request is now empty. |
69 request.setErrorResponse('No request for isolate: /isolates/$isolateId'); | 69 request.setErrorResponse('No request for isolate: /isolates/$isolateId'); |
70 return new Future.value(request); | 70 return new Future.value(request); |
71 } | 71 } |
72 return isolate.route(request); | 72 return isolate.route(request); |
73 } | 73 } |
74 } | 74 } |
OLD | NEW |