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

Unified Diff: lib/src/isolate.dart

Issue 1670283002: add sendRequest to VMIsolateRef Base URL: git@github.com:yjbanov/vm_service_client.git@master
Patch Set: onServiceExtensionAdded; Future<Object> Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: lib/src/isolate.dart
diff --git a/lib/src/isolate.dart b/lib/src/isolate.dart
index d9363daa37947af26664dde7e475026e8286fba8..1d4792ff9f93bce77119c7e818dc3f6e1dc97c0a 100644
--- a/lib/src/isolate.dart
+++ b/lib/src/isolate.dart
@@ -19,6 +19,7 @@ import 'sentinel.dart';
import 'stack.dart';
import 'stream_manager.dart';
import 'utils.dart';
+import 'extension.dart';
VMIsolateRef newVMIsolateRef(rpc.Peer peer, StreamManager streams, Map json) {
if (json == null) return null;
@@ -86,6 +87,11 @@ class VMIsolateRef {
Stream<List<int>> get stderr => _stderr;
Stream<List<int>> _stderr;
+ /// A broadcast stream that emits the name of VM service extensions
+ Stream<VMServiceExtension> get onServiceExtensionAdded =>
+ _onServiceExtensionAdded;
+ Stream<VMServiceExtension> _onServiceExtensionAdded;
+
/// A future that fires when the isolate exits.
///
/// If the isolate has already exited, this will complete immediately.
@@ -126,6 +132,11 @@ class VMIsolateRef {
sink.add(new VMIsolateRef._(_scope, json["isolate"]));
});
+ _onServiceExtensionAdded = _transform(_scope.streams.isolate, (json, sink) {
+ if (json["kind"] != "ServiceExtensionAdded") return;
+ sink.add(newVMServiceExtension(json["extensionRPC"]));
+ });
+
_onPauseOrResume = _transform(_scope.streams.debug, (json, sink) {
var event = newVMPauseEvent(_scope, json);
if (event != null) sink.add(event);
@@ -264,6 +275,22 @@ class VMIsolateRef {
}
}
+ /// Makes a raw RPC to a VM service extension registered in this isolate
+ /// corresponding to the ID [number].
+ ///
+ /// [method] must correspond to a VM service extension installed on the VM
+ /// isolate and it must begin with prefix "ext.".
+ ///
+ /// [params] are passed to the extension handler and must be serializable to
+ /// a JSON string.
+ Future<Object> invokeExtension(String method, [Map<String, String> params]) {
+ if (!method.startsWith('ext.')) {
+ throw new ArgumentError.value(method, 'method',
+ 'must begin with "ext." prefix');
+ }
+ return _scope.sendRequest(method, params);
+ }
+
bool operator ==(other) => other is VMIsolateRef &&
other._scope.isolateId == _scope.isolateId;
@@ -365,4 +392,4 @@ class VMStep {
const VMStep._(this._value);
String toString() => _value;
-}
+}

Powered by Google App Engine
This is Rietveld 408576698