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

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

Issue 205713004: Add isolate tag-profile and better handling of errors (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
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 int _rootPortId;
9 10
10 RunningIsolates(); 11 RunningIsolates();
11 12
12 void isolateStartup(int portId, SendPort sp, String name) { 13 void isolateStartup(int portId, SendPort sp, String name) {
14 if (_rootPortId == null) {
15 _rootPortId = portId;
16 }
13 var ri = new RunningIsolate(portId, sp, name); 17 var ri = new RunningIsolate(portId, sp, name);
14 isolates[portId] = ri; 18 isolates[portId] = ri;
15 } 19 }
16 20
17 void isolateShutdown(int portId, SendPort sp) { 21 void isolateShutdown(int portId, SendPort sp) {
22 if (_rootPortId == portId) {
23 _rootPortId = null;
24 }
18 isolates.remove(portId); 25 isolates.remove(portId);
19 } 26 }
20 27
21 Future<String> route(Message message) { 28 Future<String> route(Message message) {
22 if (message.path.length == 0) { 29 if (message.path.length == 0) {
23 message.setErrorResponse('No path.'); 30 message.setErrorResponse('No path.');
24 return message.response; 31 return message.response;
25 } 32 }
26 if (message.path[0] != 'isolates') { 33 if (message.path[0] != 'isolates') {
27 message.setErrorResponse('Path must begin with /isolates/'); 34 message.setErrorResponse('Path must begin with /isolates/');
28 return message.response; 35 return message.response;
29 } 36 }
30 if (message.path.length < 2) { 37 if (message.path.length < 2) {
31 message.setErrorResponse('An isolate id must be provided'); 38 message.setErrorResponse('An isolate id must be provided');
32 return message.response; 39 return message.response;
33 } 40 }
34 var isolateId; 41 var isolateId;
35 try { 42 if ((message.path[1] == 'root') && (_rootPortId != null)) {
36 isolateId = int.parse(message.path[1]); 43 isolateId = _rootPortId;
turnidge 2014/03/24 20:22:13 so isolates/root is an alias to whatever the root
Cutch 2014/03/25 14:39:06 This alias will never been seen by Observatory, it
37 } catch (e) { 44 } else {
38 message.setErrorResponse('Could not parse isolate id: $e'); 45 try {
39 return message.response; 46 isolateId = int.parse(message.path[1]);
47 } catch (e) {
48 message.setErrorResponse('Could not parse isolate id: $e');
49 return message.response;
50 }
40 } 51 }
52 assert(isolateId != null);
41 var isolate = isolates[isolateId]; 53 var isolate = isolates[isolateId];
42 if (isolate == null) { 54 if (isolate == null) {
43 message.setErrorResponse('Cannot find isolate id: $isolateId'); 55 message.setErrorResponse('Cannot find isolate id: $isolateId');
44 return message.response; 56 return message.response;
45 } 57 }
46 // Consume '/isolates/isolateId' 58 // Consume '/isolates/isolateId'
47 message.path.removeRange(0, 2); 59 message.path.removeRange(0, 2);
48 return isolate.route(message); 60 return isolate.route(message);
49 } 61 }
50 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698