| 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 int _rootPortId; | 9 int _rootPortId; |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 Future<String> route(Message message) { | 28 Future<String> route(Message message) { |
| 29 String isolateParam = message.params['isolateId']; | 29 String isolateParam = message.params['isolateId']; |
| 30 int isolateId; | 30 int isolateId; |
| 31 if (!isolateParam.startsWith('isolates/')) { | 31 if (!isolateParam.startsWith('isolates/')) { |
| 32 message.setErrorResponse('Malformed isolate id $isolateParam'); | 32 message.setErrorResponse('Malformed isolate id $isolateParam'); |
| 33 return message.response; | 33 return message.response; |
| 34 } | 34 } |
| 35 isolateParam = isolateParam.substring('isolates/'.length); | 35 isolateParam = isolateParam.substring('isolates/'.length); |
| 36 if (isolateParam == 'isolates/root') { | 36 if (isolateParam == 'root') { |
| 37 isolateId = _rootPortId; | 37 isolateId = _rootPortId; |
| 38 } else { | 38 } else { |
| 39 try { | 39 try { |
| 40 isolateId = int.parse(isolateParam); | 40 isolateId = int.parse(isolateParam); |
| 41 } catch (e) { | 41 } catch (e) { |
| 42 message.setErrorResponse('Could not parse isolate id: $e'); | 42 message.setErrorResponse('Could not parse isolate id: $e'); |
| 43 return message.response; | 43 return message.response; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 var isolate = isolates[isolateId]; | 46 var isolate = isolates[isolateId]; |
| 47 if (isolate == null) { | 47 if (isolate == null) { |
| 48 message.setErrorResponse('Cannot find isolate id: $isolateId'); | 48 message.setErrorResponse('Cannot find isolate id: $isolateId'); |
| 49 return message.response; | 49 return message.response; |
| 50 } | 50 } |
| 51 return isolate.route(message); | 51 return isolate.route(message); |
| 52 } | 52 } |
| 53 } | 53 } |
| OLD | NEW |