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

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

Issue 993613002: Implement 'print', 'up', 'down', and 'frame' commands in the Observatory debugger. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix deadlock, etc. Created 5 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
« no previous file with comments | « runtime/vm/service/client.dart ('k') | runtime/vm/service_isolate.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 Message { 7 class Message {
8 final Completer _completer = new Completer.sync(); 8 final Completer _completer = new Completer.sync();
9 bool get completed => _completer.isCompleted; 9 bool get completed => _completer.isCompleted;
10 /// Future of response. 10 /// Future of response.
11 Future<String> get response => _completer.future; 11 Future<String> get response => _completer.future;
12 12
13 // Client-side identifier for this message.
14 final serial;
15
13 // In new messages. 16 // In new messages.
14 final String method; 17 final String method;
15 18
16 // In old messages. 19 // In old messages.
17 final List path = new List(); 20 final List path = new List();
18 21
19 final Map params = new Map(); 22 final Map params = new Map();
20 23
21 void _setPath(List<String> pathSegments) { 24 void _setPath(List<String> pathSegments) {
22 if (pathSegments == null) { 25 if (pathSegments == null) {
23 return; 26 return;
24 } 27 }
25 pathSegments.forEach((String segment) { 28 pathSegments.forEach((String segment) {
26 if (segment == null || segment == '') { 29 if (segment == null || segment == '') {
27 return; 30 return;
28 } 31 }
29 path.add(segment); 32 path.add(segment);
30 }); 33 });
31 } 34 }
32 35
33 Message.fromJsonRpc(this.method, Map rpcParams) { 36 Message.fromJsonRpc(Map map) : serial = map['id'], method = map['method'] {
34 params.addAll(rpcParams); 37 params.addAll(map['params']);
35 } 38 }
36 39
37 static String _methodNameFromUri(Uri uri) { 40 static String _methodNameFromUri(Uri uri) {
38 if (uri == null) { 41 if (uri == null) {
39 return ''; 42 return '';
40 } 43 }
41 if (uri.pathSegments.length == 0) { 44 if (uri.pathSegments.length == 0) {
42 return ''; 45 return '';
43 } 46 }
44 return uri.pathSegments[0]; 47 return uri.pathSegments[0];
(...skipping 24 matching lines...) Expand all
69 } 72 }
70 list[i] = list[i].toString(); 73 list[i] = list[i].toString();
71 } 74 }
72 return list; 75 return list;
73 } 76 }
74 77
75 Future<String> send(SendPort sendPort) { 78 Future<String> send(SendPort sendPort) {
76 final receivePort = new RawReceivePort(); 79 final receivePort = new RawReceivePort();
77 receivePort.handler = (value) { 80 receivePort.handler = (value) {
78 receivePort.close(); 81 receivePort.close();
79 if (value is Exception) { 82 assert(value is String);
80 _completer.completeError(value); 83 _completer.complete(value);
81 } else {
82 _completer.complete(value);
83 }
84 }; 84 };
85 var keys = _makeAllString(params.keys.toList(growable:false)); 85 var keys = _makeAllString(params.keys.toList(growable:false));
86 var values = _makeAllString(params.values.toList(growable:false)); 86 var values = _makeAllString(params.values.toList(growable:false));
87 var request = new List(5) 87 var request = new List(5)
88 ..[0] = 0 // Make room for OOB message type. 88 ..[0] = 0 // Make room for OOB message type.
89 ..[1] = receivePort.sendPort 89 ..[1] = receivePort.sendPort
90 ..[2] = method 90 ..[2] = method
91 ..[3] = keys 91 ..[3] = keys
92 ..[4] = values; 92 ..[4] = values;
93 sendIsolateServiceMessage(sendPort, request); 93 if (!sendIsolateServiceMessage(sendPort, request)) {
94 _completer.complete(JSON.encode({
95 'type': 'ServiceError',
96 'id': '',
97 'kind': 'InternalError',
98 'message': 'could not send message to isolate',
Cutch 2015/03/10 00:00:18 might want to include the serial here.
99 }));
100 }
94 return _completer.future; 101 return _completer.future;
95 } 102 }
96 103
97 Future<String> sendToVM() { 104 Future<String> sendToVM() {
98 final receivePort = new RawReceivePort(); 105 final receivePort = new RawReceivePort();
99 receivePort.handler = (value) { 106 receivePort.handler = (value) {
100 receivePort.close(); 107 receivePort.close();
101 if (value is Exception) { 108 assert(value is String);
102 _completer.completeError(value); 109 _completer.complete(value);
103 } else {
104 _completer.complete(value);
105 }
106 }; 110 };
107 var keys = _makeAllString(params.keys.toList(growable:false)); 111 var keys = _makeAllString(params.keys.toList(growable:false));
108 var values = _makeAllString(params.values.toList(growable:false)); 112 var values = _makeAllString(params.values.toList(growable:false));
109 var request = new List(5) 113 var request = new List(5)
110 ..[0] = 0 // Make room for OOB message type. 114 ..[0] = 0 // Make room for OOB message type.
111 ..[1] = receivePort.sendPort 115 ..[1] = receivePort.sendPort
112 ..[2] = method 116 ..[2] = method
113 ..[3] = keys 117 ..[3] = keys
114 ..[4] = values; 118 ..[4] = values;
115 sendRootServiceMessage(request); 119 sendRootServiceMessage(request);
116 return _completer.future; 120 return _completer.future;
117 } 121 }
118 122
119 void setResponse(String response) { 123 void setResponse(String response) {
120 _completer.complete(response); 124 _completer.complete(response);
121 } 125 }
122 126
123 void setErrorResponse(String error) { 127 void setErrorResponse(String error) {
124 _completer.complete(JSON.encode({ 128 _completer.complete(JSON.encode({
125 'type': 'ServiceError', 129 'type': 'ServiceError',
126 'id': '', 130 'id': '',
127 'kind': 'RequestError', 131 'kind': 'RequestError',
128 'message': error, 132 'message': error,
129 'path': path, 133 'path': path,
130 'params': params 134 'params': params
131 })); 135 }));
132 } 136 }
133 } 137 }
134 138
135 void sendIsolateServiceMessage(SendPort sp, List m) 139 bool sendIsolateServiceMessage(SendPort sp, List m)
136 native "VMService_SendIsolateServiceMessage"; 140 native "VMService_SendIsolateServiceMessage";
137 141
138 void sendRootServiceMessage(List m) 142 void sendRootServiceMessage(List m)
139 native "VMService_SendRootServiceMessage"; 143 native "VMService_SendRootServiceMessage";
OLDNEW
« no previous file with comments | « runtime/vm/service/client.dart ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698