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

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

Issue 145323002: Post-meetup feature extravaganza. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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) { 21 void _isolateCollectionRequest(Message message) {
22 var members = []; 22 var members = [];
23 var result = {}; 23 var result = {};
24 isolates.forEach((portId, runningIsolate) { 24 isolates.forEach((portId, runningIsolate) {
25 members.add({ 25 members.add({
26 'type': 'Isolate', 26 'type': '@Isolate',
27 'id': 'isolates/$portId', 27 'id': 'isolates/$portId',
28 'name': runningIsolate.name, 28 'name': '$portId',
29 }); 29 });
30 }); 30 });
31 result['type'] = 'IsolateList'; 31 result['type'] = 'IsolateList';
32 result['members'] = members; 32 result['members'] = members;
33 message.setResponse(JSON.encode(result)); 33 message.setResponse(JSON.encode(result));
34 } 34 }
35 35
36 Future<String> route(Message message) { 36 Future<String> route(Message message) {
37 if (message.path.length == 0) { 37 if (message.path.length == 0) {
38 message.setErrorResponse('No path.'); 38 message.setErrorResponse('No path.');
39 return message.response; 39 return message.response;
(...skipping 14 matching lines...) Expand all
54 message.setErrorResponse('Could not parse isolate id: $e'); 54 message.setErrorResponse('Could not parse isolate id: $e');
55 return message.response; 55 return message.response;
56 } 56 }
57 var isolate = isolates[isolateId]; 57 var isolate = isolates[isolateId];
58 if (isolate == null) { 58 if (isolate == null) {
59 message.setErrorResponse('Cannot find isolate id: $isolateId'); 59 message.setErrorResponse('Cannot find isolate id: $isolateId');
60 return message.response; 60 return message.response;
61 } 61 }
62 // Consume '/isolates/isolateId' 62 // Consume '/isolates/isolateId'
63 message.path.removeRange(0, 2); 63 message.path.removeRange(0, 2);
64 if (message.path.length == 0) {
65 // The message now has an empty path.
66 message.setErrorResponse('Empty path for isolate: /isolates/$isolateId');
67 return message.response;
68 }
69 return isolate.route(message); 64 return isolate.route(message);
70 } 65 }
71 } 66 }
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