OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart._vmservice; | 5 library dart._vmservice; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 return encodeRpcError(message, kStreamNotSubscribed); | 288 return encodeRpcError(message, kStreamNotSubscribed); |
289 } | 289 } |
290 client.streams.remove(streamId); | 290 client.streams.remove(streamId); |
291 if (!_isAnyClientSubscribed(streamId)) { | 291 if (!_isAnyClientSubscribed(streamId)) { |
292 _vmCancelStream(streamId); | 292 _vmCancelStream(streamId); |
293 } | 293 } |
294 | 294 |
295 return encodeSuccess(message); | 295 return encodeSuccess(message); |
296 } | 296 } |
297 | 297 |
298 Future<String> _spawnUri(Message message) async { | |
299 var token = message.params['token']; | |
300 if (token == null) { | |
301 return encodeMissingParamError(message, 'token'); | |
Cutch
2016/07/07 16:17:45
here you allow for any object as the token but in
turnidge
2016/07/11 21:24:59
Done.
| |
302 } | |
303 var uri = message.params['uri']; | |
304 if (uri == null) { | |
305 return encodeMissingParamError(message, 'uri'); | |
306 } | |
307 if (uri is! String) { | |
308 return encodeInvalidParamError(message, 'uri'); | |
309 } | |
310 var args = message.params['args']; | |
311 if (args != null && | |
312 args is! List<String>) { | |
313 return encodeInvalidParamError(message, 'args'); | |
314 } | |
315 var msg = message.params['message']; | |
316 | |
317 Isolate.spawnUri(Uri.parse(uri), args, msg).then((isolate) { | |
318 _spawnUriNotify(isolate.controlPort, token); | |
319 }).catchError((e) { | |
320 _spawnUriNotify(e.toString(), token); | |
321 }); | |
322 | |
323 return encodeSuccess(message); | |
324 } | |
325 | |
298 // TODO(johnmccutchan): Turn this into a command line tool that uses the | 326 // TODO(johnmccutchan): Turn this into a command line tool that uses the |
299 // service library. | 327 // service library. |
300 Future<String> _getCrashDump(Message message) async { | 328 Future<String> _getCrashDump(Message message) async { |
301 var client = message.client; | 329 var client = message.client; |
302 final perIsolateRequests = [ | 330 final perIsolateRequests = [ |
303 // ?isolateId=<isolate id> will be appended to each of these requests. | 331 // ?isolateId=<isolate id> will be appended to each of these requests. |
304 // Isolate information. | 332 // Isolate information. |
305 Uri.parse('getIsolate'), | 333 Uri.parse('getIsolate'), |
306 // State of heap. | 334 // State of heap. |
307 Uri.parse('_getAllocationProfile'), | 335 Uri.parse('_getAllocationProfile'), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 // TODO(turnidge): Update to json rpc. BEFORE SUBMIT. | 388 // TODO(turnidge): Update to json rpc. BEFORE SUBMIT. |
361 if (message.method == '_getCrashDump') { | 389 if (message.method == '_getCrashDump') { |
362 return _getCrashDump(message); | 390 return _getCrashDump(message); |
363 } | 391 } |
364 if (message.method == 'streamListen') { | 392 if (message.method == 'streamListen') { |
365 return _streamListen(message); | 393 return _streamListen(message); |
366 } | 394 } |
367 if (message.method == 'streamCancel') { | 395 if (message.method == 'streamCancel') { |
368 return _streamCancel(message); | 396 return _streamCancel(message); |
369 } | 397 } |
398 if (message.method == '_spawnUri') { | |
399 return _spawnUri(message); | |
400 } | |
370 if (_devfs.shouldHandleMessage(message)) { | 401 if (_devfs.shouldHandleMessage(message)) { |
371 return _devfs.handleMessage(message); | 402 return _devfs.handleMessage(message); |
372 } | 403 } |
373 if (message.params['isolateId'] != null) { | 404 if (message.params['isolateId'] != null) { |
374 return runningIsolates.route(message); | 405 return runningIsolates.route(message); |
375 } | 406 } |
376 return message.sendToVM(); | 407 return message.sendToVM(); |
377 } | 408 } |
378 } | 409 } |
379 | 410 |
(...skipping 17 matching lines...) Expand all Loading... | |
397 external void onServerAddressChange(String address); | 428 external void onServerAddressChange(String address); |
398 | 429 |
399 /// Subscribe to a service stream. | 430 /// Subscribe to a service stream. |
400 external bool _vmListenStream(String streamId); | 431 external bool _vmListenStream(String streamId); |
401 | 432 |
402 /// Cancel a subscription to a service stream. | 433 /// Cancel a subscription to a service stream. |
403 external void _vmCancelStream(String streamId); | 434 external void _vmCancelStream(String streamId); |
404 | 435 |
405 /// Get the bytes to the tar archive. | 436 /// Get the bytes to the tar archive. |
406 external Uint8List _requestAssets(); | 437 external Uint8List _requestAssets(); |
438 | |
439 /// Notify the vm service that an isolate has been spawned via rpc. | |
440 external void _spawnUriNotify(obj, String token); | |
OLD | NEW |