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

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: rename to invokeExtension; enforce ext. prefix 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
« no previous file with comments | « no previous file | test/isolate_test.dart » ('j') | test/isolate_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/isolate.dart
diff --git a/lib/src/isolate.dart b/lib/src/isolate.dart
index d9363daa37947af26664dde7e475026e8286fba8..8b8f367e07abd6cd77763952085136226a1628e0 100644
--- a/lib/src/isolate.dart
+++ b/lib/src/isolate.dart
@@ -264,6 +264,21 @@ class VMIsolateRef {
}
}
+ /// Makes a raw RPC to a VM service extension registered in the isolate
+ /// corresponding to the ID [number].
nweiz 2016/02/10 22:17:11 "the isolate ..." -> "this isolate."
+ ///
+ /// [method] must correspond to a VM service extension installed on the VM
+ /// isolate and it must begin with prefix "ext.".
nweiz 2016/02/10 21:28:28 It sort of feels like this should just automatical
yjbanov 2016/02/10 22:06:06 I think there's value in having `invokeExtension`
nweiz 2016/02/10 22:17:11 SGTM
+ ///
+ /// [params] are passed to the extension handler and must be serializable to
+ /// a JSON string.
+ Future<Map> invokeExtension(String method, [Map<String, Object> params]) {
nweiz 2016/02/10 21:28:28 Based on the ServiceExtensionHandler API, I think
yjbanov 2016/02/10 22:06:06 I thought so too initially, but turns out the JSON
nweiz 2016/02/10 22:17:11 I think we should only allow strings here. We defi
+ if (!method.startsWith('ext.')) {
+ throw new ArgumentError('Extension method names must begin with "ext." prefix: ${method}');
nweiz 2016/02/10 21:28:28 Long line. Also, you can make this a little more
yjbanov 2016/02/10 22:06:06 Done.
+ }
+ return _scope.sendRequest(method, params);
+ }
+
bool operator ==(other) => other is VMIsolateRef &&
other._scope.isolateId == _scope.isolateId;
@@ -365,4 +380,4 @@ class VMStep {
const VMStep._(this._value);
String toString() => _value;
-}
+}
« no previous file with comments | « no previous file | test/isolate_test.dart » ('j') | test/isolate_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698