Chromium Code Reviews| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 | 7 |
| 8 import 'package:async/async.dart'; | 8 import 'package:async/async.dart'; |
| 9 import 'package:crypto/crypto.dart'; | 9 import 'package:crypto/crypto.dart'; |
| 10 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; | 10 import 'package:json_rpc_2/json_rpc_2.dart' as rpc; |
| 11 | 11 |
| 12 import 'breakpoint.dart'; | 12 import 'breakpoint.dart'; |
| 13 import 'error.dart'; | 13 import 'error.dart'; |
| 14 import 'exceptions.dart'; | 14 import 'exceptions.dart'; |
| 15 import 'library.dart'; | 15 import 'library.dart'; |
| 16 import 'pause_event.dart'; | 16 import 'pause_event.dart'; |
| 17 import 'scope.dart'; | 17 import 'scope.dart'; |
| 18 import 'sentinel.dart'; | 18 import 'sentinel.dart'; |
| 19 import 'stack.dart'; | 19 import 'stack.dart'; |
| 20 import 'stream_manager.dart'; | 20 import 'stream_manager.dart'; |
| 21 import 'utils.dart'; | 21 import 'utils.dart'; |
| 22 import 'extension.dart'; | |
| 22 | 23 |
| 23 VMIsolateRef newVMIsolateRef(rpc.Peer peer, StreamManager streams, Map json) { | 24 VMIsolateRef newVMIsolateRef(rpc.Peer peer, StreamManager streams, Map json) { |
| 24 if (json == null) return null; | 25 if (json == null) return null; |
| 25 assert(json["type"] == "@Isolate" || json["type"] == "Isolate"); | 26 assert(json["type"] == "@Isolate" || json["type"] == "Isolate"); |
| 26 var scope = new Scope(peer, streams, json["id"]); | 27 var scope = new Scope(peer, streams, json["id"]); |
| 27 return new VMIsolateRef._(scope, json); | 28 return new VMIsolateRef._(scope, json); |
| 28 } | 29 } |
| 29 | 30 |
| 30 /// A reference to an isolate on the remote VM. | 31 /// A reference to an isolate on the remote VM. |
| 31 /// | 32 /// |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 /// [sdk#24351]: https://github.com/dart-lang/sdk/issues/24351 | 80 /// [sdk#24351]: https://github.com/dart-lang/sdk/issues/24351 |
| 80 Stream<List<int>> get stdout => _stdout; | 81 Stream<List<int>> get stdout => _stdout; |
| 81 Stream<List<int>> _stdout; | 82 Stream<List<int>> _stdout; |
| 82 | 83 |
| 83 /// A broadcast stream that emits this isolate's standard error. | 84 /// A broadcast stream that emits this isolate's standard error. |
| 84 /// | 85 /// |
| 85 /// This is only usable for embedders that provide access to `dart:io`. | 86 /// This is only usable for embedders that provide access to `dart:io`. |
| 86 Stream<List<int>> get stderr => _stderr; | 87 Stream<List<int>> get stderr => _stderr; |
| 87 Stream<List<int>> _stderr; | 88 Stream<List<int>> _stderr; |
| 88 | 89 |
| 90 /// A broadcast stream that emits the name of VM service extensions | |
| 91 Stream<VMServiceExtension> get onServiceExtensionAdded => | |
| 92 _onServiceExtensionAdded; | |
| 93 Stream<VMServiceExtension> _onServiceExtensionAdded; | |
| 94 | |
| 89 /// A future that fires when the isolate exits. | 95 /// A future that fires when the isolate exits. |
| 90 /// | 96 /// |
| 91 /// If the isolate has already exited, this will complete immediately. | 97 /// If the isolate has already exited, this will complete immediately. |
| 92 Future get onExit => _onExitMemo.runOnce(() async { | 98 Future get onExit => _onExitMemo.runOnce(() async { |
| 93 try { | 99 try { |
| 94 await _scope.getInState(_scope.streams.isolate, () async { | 100 await _scope.getInState(_scope.streams.isolate, () async { |
| 95 try { | 101 try { |
| 96 await load(); | 102 await load(); |
| 97 return null; | 103 return null; |
| 98 } on VMSentinelException catch (_) { | 104 } on VMSentinelException catch (_) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 119 name = json["name"] { | 125 name = json["name"] { |
| 120 _onGC = _transform(_scope.streams.gc, (json, sink) { | 126 _onGC = _transform(_scope.streams.gc, (json, sink) { |
| 121 if (json["kind"] == "GC") sink.add(null); | 127 if (json["kind"] == "GC") sink.add(null); |
| 122 }); | 128 }); |
| 123 | 129 |
| 124 _onUpdate = _transform(_scope.streams.isolate, (json, sink) { | 130 _onUpdate = _transform(_scope.streams.isolate, (json, sink) { |
| 125 if (json["kind"] != "IsolateUpdate") return; | 131 if (json["kind"] != "IsolateUpdate") return; |
| 126 sink.add(new VMIsolateRef._(_scope, json["isolate"])); | 132 sink.add(new VMIsolateRef._(_scope, json["isolate"])); |
| 127 }); | 133 }); |
| 128 | 134 |
| 135 _onServiceExtensionAdded = _transform(_scope.streams.isolate, (json, sink) { | |
| 136 if (json["kind"] != "ServiceExtensionAdded") return; | |
| 137 sink.add(newVMServiceExtension(json["extensionRPC"])); | |
| 138 }); | |
| 139 | |
| 129 _onPauseOrResume = _transform(_scope.streams.debug, (json, sink) { | 140 _onPauseOrResume = _transform(_scope.streams.debug, (json, sink) { |
| 130 var event = newVMPauseEvent(_scope, json); | 141 var event = newVMPauseEvent(_scope, json); |
| 131 if (event != null) sink.add(event); | 142 if (event != null) sink.add(event); |
| 132 }); | 143 }); |
| 133 | 144 |
| 134 _onBreakpointAdded = _transform(_scope.streams.debug, (json, sink) { | 145 _onBreakpointAdded = _transform(_scope.streams.debug, (json, sink) { |
| 135 if (json["kind"] != "BreakpointAdded") return; | 146 if (json["kind"] != "BreakpointAdded") return; |
| 136 sink.add(newVMBreakpoint(_scope, json["breakpoint"])); | 147 sink.add(newVMBreakpoint(_scope, json["breakpoint"])); |
| 137 }); | 148 }); |
| 138 | 149 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 var response = await _scope.sendRequest( | 268 var response = await _scope.sendRequest( |
| 258 "addBreakpointWithScriptUri", params); | 269 "addBreakpointWithScriptUri", params); |
| 259 return newVMBreakpoint(_scope, response); | 270 return newVMBreakpoint(_scope, response); |
| 260 } on rpc.RpcException catch (error) { | 271 } on rpc.RpcException catch (error) { |
| 261 // Error 102 indicates that the breakpoint couldn't be created. | 272 // Error 102 indicates that the breakpoint couldn't be created. |
| 262 if (error.code == 102) return null; | 273 if (error.code == 102) return null; |
| 263 rethrow; | 274 rethrow; |
| 264 } | 275 } |
| 265 } | 276 } |
| 266 | 277 |
| 278 /// Makes a raw RPC to a VM service extension registered in this isolate | |
| 279 /// corresponding to the ID [number]. | |
| 280 /// | |
| 281 /// [method] must correspond to a VM service extension installed on the VM | |
| 282 /// isolate and it must begin with prefix "ext.". | |
| 283 /// | |
| 284 /// [params] are passed to the extension handler and must be serializable to | |
| 285 /// a JSON string. | |
| 286 Future<Object> invokeExtension(String method, [Map<String, String> params]) { | |
| 287 if (!method.startsWith('ext.')) { | |
| 288 throw new ArgumentError.value(method, 'method', | |
| 289 'must begin with "ext." prefix'); | |
| 290 } | |
| 291 return _scope.sendRequest(method, params); | |
| 292 } | |
| 293 | |
| 267 bool operator ==(other) => other is VMIsolateRef && | 294 bool operator ==(other) => other is VMIsolateRef && |
| 268 other._scope.isolateId == _scope.isolateId; | 295 other._scope.isolateId == _scope.isolateId; |
| 269 | 296 |
| 270 int get hashCode => _scope.isolateId.hashCode; | 297 int get hashCode => _scope.isolateId.hashCode; |
| 271 | 298 |
| 272 String toString() => name; | 299 String toString() => name; |
| 273 } | 300 } |
| 274 | 301 |
| 275 /// A full isolate on the remote VM. | 302 /// A full isolate on the remote VM. |
| 276 class VMIsolate extends VMIsolateRef { | 303 class VMIsolate extends VMIsolateRef { |
|
nweiz
2016/02/16 22:03:20
Could you add VMIsolate.extensionRpcs as well?
yjbanov
2016/02/16 22:31:49
Done.
| |
| 277 /// The time that the isolate started running. | 304 /// The time that the isolate started running. |
| 278 final DateTime startTime; | 305 final DateTime startTime; |
| 279 | 306 |
| 280 /// The number of live ports on this isolate. | 307 /// The number of live ports on this isolate. |
| 281 final int livePorts; | 308 final int livePorts; |
| 282 | 309 |
| 283 /// Whether this isolate will pause before it exits. | 310 /// Whether this isolate will pause before it exits. |
| 284 final bool pauseOnExit; | 311 final bool pauseOnExit; |
| 285 | 312 |
| 286 /// The last pause event delivered to this isolate. | 313 /// The last pause event delivered to this isolate. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 | 385 |
| 359 /// The isolate continues until it exits the current function. | 386 /// The isolate continues until it exits the current function. |
| 360 static const out = const VMStep._("Out"); | 387 static const out = const VMStep._("Out"); |
| 361 | 388 |
| 362 /// The string name of the step type. | 389 /// The string name of the step type. |
| 363 final String _value; | 390 final String _value; |
| 364 | 391 |
| 365 const VMStep._(this._value); | 392 const VMStep._(this._value); |
| 366 | 393 |
| 367 String toString() => _value; | 394 String toString() => _value; |
| 368 } | 395 } |
| OLD | NEW |