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

Unified Diff: sdk/lib/developer/extension.dart

Issue 1537523002: Add dart:developer.postEvent for posting events to the service protocol from Dart code (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « runtime/vm/service_event.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/developer/extension.dart
diff --git a/sdk/lib/developer/extension.dart b/sdk/lib/developer/extension.dart
index 3ccea0e450d8440fa354dc13616154822db578a7..309dca2f1f253b223b9b9cbbff839ea0abbcf508 100644
--- a/sdk/lib/developer/extension.dart
+++ b/sdk/lib/developer/extension.dart
@@ -109,6 +109,25 @@ void registerExtension(String method, ServiceExtensionHandler handler) {
_registerExtension(method, handler);
}
+/// Post an event of [eventKind] with payload of [eventData] to the `Extension`
+/// event stream.
+void postEvent(String eventKind, Map eventData) {
+ if (eventKind is! String) {
+ throw new ArgumentError.value(eventKind,
+ 'eventKind',
+ 'Must be a String');
+ }
+ if (eventData is! Map) {
+ throw new ArgumentError.value(eventData,
+ 'eventData',
+ 'Must be a Map');
+ }
+ String eventDataAsString = JSON.encode(eventData);
+ _postEvent(eventKind, eventDataAsString);
+}
+
+external _postEvent(String eventKind, String eventData);
+
// Both of these functions are written inside C++ to avoid updating the data
// structures in Dart, getting an OOB, and observing stale state. Do not move
// these into Dart code unless you can ensure that the operations will can be
« no previous file with comments | « runtime/vm/service_event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698