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

Side by Side Diff: runtime/vm/service/running_isolates.dart

Issue 206213004: Add a VM page to the observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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();
11 11
12 void isolateStartup(int portId, SendPort sp, String name) { 12 void isolateStartup(int portId, SendPort sp, String name) {
13 var ri = new RunningIsolate(portId, sp, name); 13 var ri = new RunningIsolate(portId, sp, name);
14 isolates[portId] = ri; 14 isolates[portId] = ri;
15 } 15 }
16 16
17 void isolateShutdown(int portId, SendPort sp) { 17 void isolateShutdown(int portId, SendPort sp) {
18 isolates.remove(portId); 18 isolates.remove(portId);
19 } 19 }
20 20
21 void _isolateCollectionRequest(Message message) {
22 var members = [];
23 var result = {};
24 isolates.forEach((portId, runningIsolate) {
25 members.add({
26 'type': '@Isolate',
27 'id': 'isolates/$portId',
28 'name': '$portId',
29 });
30 });
31 result['type'] = 'IsolateList';
32 result['id'] = 'isolates';
33 result['members'] = members;
34 message.setResponse(JSON.encode(result));
35 }
36
37 Future<String> route(Message message) { 21 Future<String> route(Message message) {
38 if (message.path.length == 0) { 22 if (message.path.length == 0) {
39 message.setErrorResponse('No path.'); 23 message.setErrorResponse('No path.');
40 return message.response; 24 return message.response;
41 } 25 }
42 if (message.path[0] != 'isolates') { 26 if (message.path[0] != 'isolates') {
43 message.setErrorResponse('Path must begin with /isolates/.'); 27 message.setErrorResponse('Path must begin with /isolates/');
44 return message.response; 28 return message.response;
45 } 29 }
46 if (message.path.length == 1) { 30 if (message.path.length < 2) {
47 // Requesting list of running isolates. 31 message.setErrorResponse('An isolate id must be provided');
48 _isolateCollectionRequest(message);
49 return message.response; 32 return message.response;
50 } 33 }
51 var isolateId; 34 var isolateId;
52 try { 35 try {
53 isolateId = int.parse(message.path[1]); 36 isolateId = int.parse(message.path[1]);
54 } catch (e) { 37 } catch (e) {
55 message.setErrorResponse('Could not parse isolate id: $e'); 38 message.setErrorResponse('Could not parse isolate id: $e');
56 return message.response; 39 return message.response;
57 } 40 }
58 var isolate = isolates[isolateId]; 41 var isolate = isolates[isolateId];
59 if (isolate == null) { 42 if (isolate == null) {
60 message.setErrorResponse('Cannot find isolate id: $isolateId'); 43 message.setErrorResponse('Cannot find isolate id: $isolateId');
61 return message.response; 44 return message.response;
62 } 45 }
63 // Consume '/isolates/isolateId' 46 // Consume '/isolates/isolateId'
64 message.path.removeRange(0, 2); 47 message.path.removeRange(0, 2);
65 return isolate.route(message); 48 return isolate.route(message);
66 } 49 }
67 } 50 }
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698