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

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

Issue 823403004: Begin migrating the vm service from a rest-style interface to a json-rpc style interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove old-style standalone tests. Created 5 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/protocol.md ('k') | runtime/vm/service/service.idl » ('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 int _rootPortId; 9 int _rootPortId;
10 10
11 RunningIsolates(); 11 RunningIsolates();
12 12
13 void isolateStartup(int portId, SendPort sp, String name) { 13 void isolateStartup(int portId, SendPort sp, String name) {
14 if (_rootPortId == null) { 14 if (_rootPortId == null) {
15 _rootPortId = portId; 15 _rootPortId = portId;
16 } 16 }
17 var ri = new RunningIsolate(portId, sp, name); 17 var ri = new RunningIsolate(portId, sp, name);
18 isolates[portId] = ri; 18 isolates[portId] = ri;
19 } 19 }
20 20
21 void isolateShutdown(int portId, SendPort sp) { 21 void isolateShutdown(int portId, SendPort sp) {
22 if (_rootPortId == portId) { 22 if (_rootPortId == portId) {
23 _rootPortId = null; 23 _rootPortId = null;
24 } 24 }
25 isolates.remove(portId); 25 isolates.remove(portId);
26 } 26 }
27 27
28 Future<String> route(Message message) { 28 Future<String> route(Message message) {
29 if (message.isOld) {
30 return routeOld(message);
31 }
32
33 String isolateParam = message.params['isolate'];
34 int isolateId;
35 if (!isolateParam.startsWith('isolates/')) {
36 message.setErrorResponse('Malformed isolate id $isolateParam');
37 return message.response;
38 }
39 isolateParam = isolateParam.substring('isolates/'.length);
40 if (isolateParam == 'isolates/root') {
41 isolateId = _rootPortId;
42 } else {
43 try {
44 isolateId = int.parse(isolateParam);
45 } catch (e) {
46 message.setErrorResponse('Could not parse isolate id: $e');
47 return message.response;
48 }
49 }
50 var isolate = isolates[isolateId];
51 if (isolate == null) {
52 message.setErrorResponse('Cannot find isolate id: $isolateId');
53 return message.response;
54 }
55 return isolate.route(message);
56 }
57
58 Future<String> routeOld(Message message) {
29 if (message.path.length == 0) { 59 if (message.path.length == 0) {
30 message.setErrorResponse('No path.'); 60 message.setErrorResponse('No path.');
31 return message.response; 61 return message.response;
32 } 62 }
33 if (message.path[0] != 'isolates') { 63 if (message.path[0] != 'isolates') {
34 message.setErrorResponse('Path must begin with /isolates/'); 64 message.setErrorResponse('Path must begin with /isolates/');
35 return message.response; 65 return message.response;
36 } 66 }
37 if (message.path.length < 2) { 67 if (message.path.length < 2) {
38 message.setErrorResponse('An isolate id must be provided'); 68 message.setErrorResponse('An isolate id must be provided');
(...skipping 14 matching lines...) Expand all
53 var isolate = isolates[isolateId]; 83 var isolate = isolates[isolateId];
54 if (isolate == null) { 84 if (isolate == null) {
55 message.setErrorResponse('Cannot find isolate id: $isolateId'); 85 message.setErrorResponse('Cannot find isolate id: $isolateId');
56 return message.response; 86 return message.response;
57 } 87 }
58 // Consume '/isolates/isolateId' 88 // Consume '/isolates/isolateId'
59 message.path.removeRange(0, 2); 89 message.path.removeRange(0, 2);
60 return isolate.route(message); 90 return isolate.route(message);
61 } 91 }
62 } 92 }
OLDNEW
« no previous file with comments | « runtime/vm/service/protocol.md ('k') | runtime/vm/service/service.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698