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 MessageRouter { | 7 class RunningIsolates implements MessageRouter { |
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 11 matching lines...) Expand all Loading... |
22 throw new StateError('Unknown isolate.'); | 22 throw new StateError('Unknown isolate.'); |
23 } | 23 } |
24 isolates.remove(portId); | 24 isolates.remove(portId); |
25 } | 25 } |
26 | 26 |
27 void _isolateCollectionRequest(Message message) { | 27 void _isolateCollectionRequest(Message message) { |
28 var members = []; | 28 var members = []; |
29 var result = {}; | 29 var result = {}; |
30 isolates.forEach((portId, runningIsolate) { | 30 isolates.forEach((portId, runningIsolate) { |
31 members.add({ | 31 members.add({ |
32 'id': portId, | 32 'type': 'Isolate', |
33 'name': runningIsolate.name | 33 'id': 'isolates/$portId', |
| 34 'name': runningIsolate.name, |
34 }); | 35 }); |
35 }); | 36 }); |
36 result['type'] = 'IsolateList'; | 37 result['type'] = 'IsolateList'; |
37 result['members'] = members; | 38 result['members'] = members; |
38 message.setResponse(JSON.encode(result)); | 39 message.setResponse(JSON.encode(result)); |
39 } | 40 } |
40 | 41 |
41 Future<String> route(Message message) { | 42 Future<String> route(Message message) { |
42 if (message.path.length == 0) { | 43 if (message.path.length == 0) { |
43 message.setErrorResponse('No path.'); | 44 message.setErrorResponse('No path.'); |
(...skipping 23 matching lines...) Expand all Loading... |
67 // Consume '/isolates/isolateId' | 68 // Consume '/isolates/isolateId' |
68 message.path.removeRange(0, 2); | 69 message.path.removeRange(0, 2); |
69 if (message.path.length == 0) { | 70 if (message.path.length == 0) { |
70 // The message now has an empty path. | 71 // The message now has an empty path. |
71 message.setErrorResponse('Empty path for isolate: /isolates/$isolateId'); | 72 message.setErrorResponse('Empty path for isolate: /isolates/$isolateId'); |
72 return message.response; | 73 return message.response; |
73 } | 74 } |
74 return isolate.route(message); | 75 return isolate.route(message); |
75 } | 76 } |
76 } | 77 } |
OLD | NEW |