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

Side by Side Diff: runtime/bin/vmservice/running_isolate.dart

Issue 19870006: Support stacktrace and objecthistogram service commands (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 RunningIsolate implements ServiceRequestRouter { 7 class RunningIsolate implements ServiceRequestRouter {
8 final SendPort sendPort; 8 final SendPort sendPort;
9 String id = 'Unknown'; 9 String name = 'Unknown';
10 10
11 RunningIsolate(this.sendPort); 11 RunningIsolate(this.sendPort);
12 12
13 Future sendMessage(String request) { 13 Future sendMessage(List request) {
14 final completer = new Completer.sync(); 14 final completer = new Completer.sync();
15 final receivePort = new ReceivePort(); 15 final receivePort = new ReceivePort();
16 sendServiceMessage(sendPort, receivePort, request); 16 sendServiceMessage(sendPort, receivePort, request);
17 receivePort.receive((value, ignoreReplyTo) { 17 receivePort.receive((value, ignoreReplyTo) {
18 receivePort.close(); 18 receivePort.close();
19 if (value is Exception) { 19 if (value is Exception) {
20 completer.completeError(value); 20 completer.completeError(value);
21 } else { 21 } else {
22 completer.complete(value); 22 completer.complete(value);
23 } 23 }
24 }); 24 });
25 return completer.future; 25 return completer.future;
26 } 26 }
27 27
28 bool route(ServiceRequest request) { 28 Future route(ServiceRequest request) {
29 // Do nothing for now. 29 // Send message to isolate.
30 return false; 30 var message = request.toServiceCallMessage();
31 return sendMessage(message).then((response) {
32 request.setResponse(response);
33 return new Future.value(request);
34 });
31 } 35 }
32 36
33 void sendIdRequest() { 37 void _sendNameRequest() {
34 var request = JSON.stringify({'p': ['id'], 'k': [], 'v': []}); 38 var request = new ServiceRequest();
35 sendMessage(request).then(_handleIdResponse); 39 request.parse(Uri.parse('/name'));
40 sendMessage(request.toServiceCallMessage()).then(_handleNameResponse);
36 } 41 }
37 42
38 void _handleIdResponse(responseString) { 43 void _handleNameResponse(String responseString) {
39 var response; 44 var response;
40 try { 45 try {
41 response = JSON.parse(responseString); 46 response = JSON.parse(responseString);
42 } catch (e) { 47 } catch (e) {
43 id = 'Error retrieving isolate id.'; 48 name = 'Error retrieving isolate name.';
44 return; 49 return;
45 } 50 }
46 id = response['id']; 51 name = response['name'];
siva 2013/08/01 18:16:18 why not move this line into the try block. respon
Cutch 2013/08/01 22:22:04 Done.
52 if (name == null) {
53 name = 'Error retrieving isolate name.';
54 }
47 } 55 }
48 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698