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

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

Issue 1232193003: Provide stdout and stderr output in the Observatory debugger. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: before commit Created 5 years, 5 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
« no previous file with comments | « runtime/vm/service/service.md ('k') | runtime/vm/service_event.h » ('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 library vmservice; 5 library vmservice;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 String _encodeResult(Message message, Map result) { 173 String _encodeResult(Message message, Map result) {
174 var response = { 174 var response = {
175 'id' : message.serial, 175 'id' : message.serial,
176 'result' : result, 176 'result' : result,
177 }; 177 };
178 return JSON.encode(response); 178 return JSON.encode(response);
179 } 179 }
180 180
181 bool _isValidStream(String streamId) {
182 final validStreams = [ 'Isolate', 'Debug', 'GC', '_Echo', '_Graph' ];
183 return validStreams.contains(streamId);
184 }
185
186 bool _isAnyClientSubscribed(String streamId) { 181 bool _isAnyClientSubscribed(String streamId) {
187 for (var client in clients) { 182 for (var client in clients) {
188 if (client.streams.contains(streamId)) { 183 if (client.streams.contains(streamId)) {
189 return true; 184 return true;
190 } 185 }
191 } 186 }
192 return false; 187 return false;
193 } 188 }
194 189
195 Future<String> _streamListen(Message message) async { 190 Future<String> _streamListen(Message message) async {
196 var client = message.client; 191 var client = message.client;
197 var streamId = message.params['streamId']; 192 var streamId = message.params['streamId'];
198 193
199 if (!_isValidStream(streamId)) {
200 return _encodeError(
201 message, _kInvalidParams,
202 details:"streamListen: invalid 'streamId' parameter: ${streamId}");
203 }
204 if (client.streams.contains(streamId)) { 194 if (client.streams.contains(streamId)) {
205 return _encodeError(message, _kStreamAlreadySubscribed); 195 return _encodeError(message, _kStreamAlreadySubscribed);
206 } 196 }
207 if (!_isAnyClientSubscribed(streamId)) { 197 if (!_isAnyClientSubscribed(streamId)) {
208 _vmListenStream(streamId); 198 if (!_vmListenStream(streamId)) {
199 return _encodeError(
200 message, _kInvalidParams,
201 details:"streamListen: invalid 'streamId' parameter: ${streamId}");
202 }
209 } 203 }
210 client.streams.add(streamId); 204 client.streams.add(streamId);
211 205
212 var result = { 'type' : 'Success' }; 206 var result = { 'type' : 'Success' };
213 return _encodeResult(message, result); 207 return _encodeResult(message, result);
214 } 208 }
215 209
216 Future<String> _streamCancel(Message message) async { 210 Future<String> _streamCancel(Message message) async {
217 var client = message.client; 211 var client = message.client;
218 var streamId = message.params['streamId']; 212 var streamId = message.params['streamId'];
219 213
220 if (!_isValidStream(streamId)) {
221 return _encodeError(
222 message, _kInvalidParams,
223 details:"streamCancel: invalid 'streamId' parameter: ${streamId}");
224 }
225 if (!client.streams.contains(streamId)) { 214 if (!client.streams.contains(streamId)) {
226 return _encodeError(message, _kStreamNotSubscribed); 215 return _encodeError(message, _kStreamNotSubscribed);
227 } 216 }
228 client.streams.remove(streamId); 217 client.streams.remove(streamId);
229 if (!_isAnyClientSubscribed(streamId)) { 218 if (!_isAnyClientSubscribed(streamId)) {
230 _vmCancelStream(streamId); 219 _vmCancelStream(streamId);
231 } 220 }
232 221
233 var result = { 'type' : 'Success' }; 222 var result = { 'type' : 'Success' };
234 return _encodeResult(message, result); 223 return _encodeResult(message, result);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 313
325 void _registerIsolate(int port_id, SendPort sp, String name) { 314 void _registerIsolate(int port_id, SendPort sp, String name) {
326 var service = new VMService(); 315 var service = new VMService();
327 service.runningIsolates.isolateStartup(port_id, sp, name); 316 service.runningIsolates.isolateStartup(port_id, sp, name);
328 } 317 }
329 318
330 void _onStart() native "VMService_OnStart"; 319 void _onStart() native "VMService_OnStart";
331 320
332 void _onExit() native "VMService_OnExit"; 321 void _onExit() native "VMService_OnExit";
333 322
334 void _vmListenStream(String streamId) native "VMService_ListenStream"; 323 bool _vmListenStream(String streamId) native "VMService_ListenStream";
335 324
336 void _vmCancelStream(String streamId) native "VMService_CancelStream"; 325 void _vmCancelStream(String streamId) native "VMService_CancelStream";
OLDNEW
« no previous file with comments | « runtime/vm/service/service.md ('k') | runtime/vm/service_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698