Index: runtime/vm/dart_api_impl.cc |
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
index 99e9a559bad7bb12151f6bce0e208c75782ef4da..4cee7e86fe666c40a492fbf8786145044225e996 100644 |
--- a/runtime/vm/dart_api_impl.cc |
+++ b/runtime/vm/dart_api_impl.cc |
@@ -5692,6 +5692,67 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
} |
+DART_EXPORT Dart_Handle Dart_SetServiceStreamCallbacks( |
+ Dart_ServiceStreamListenCallback listen_callback, |
+ Dart_ServiceStreamCancelCallback cancel_callback) { |
+ if (listen_callback != NULL) { |
+ if (Service::stream_listen_callback() != NULL) { |
+ return Api::NewError( |
+ "%s permits only one listen callback to be registered, please " |
+ "remove the existing callback and then add this callback", |
+ CURRENT_FUNC); |
+ } |
+ } else { |
+ if (Service::stream_listen_callback() == NULL) { |
+ return Api::NewError( |
+ "%s expects 'listen_callback' to be present in the callback set.", |
+ CURRENT_FUNC); |
+ } |
+ } |
+ if (cancel_callback != NULL) { |
+ if (Service::stream_cancel_callback() != NULL) { |
+ return Api::NewError( |
+ "%s permits only one cancel callback to be registered, please " |
+ "remove the existing callback and then add this callback", |
+ CURRENT_FUNC); |
+ } |
+ } else { |
+ if (Service::stream_cancel_callback() == NULL) { |
+ return Api::NewError( |
+ "%s expects 'cancel_callback' to be present in the callback set.", |
+ CURRENT_FUNC); |
+ } |
+ } |
+ Service::SetEmbedderStreamCallbacks(listen_callback, cancel_callback); |
+ return Api::Success(); |
+} |
+ |
+ |
+DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id, |
+ const char* event_kind, |
+ const uint8_t* bytes, |
+ intptr_t bytes_length) { |
+ Isolate* isolate = Isolate::Current(); |
+ DARTSCOPE(isolate); |
+ if (stream_id == NULL) { |
+ RETURN_NULL_ERROR(stream_id); |
+ } |
+ if (event_kind == NULL) { |
+ RETURN_NULL_ERROR(event_kind); |
+ } |
+ if (bytes == NULL) { |
+ RETURN_NULL_ERROR(bytes); |
+ } |
+ if (bytes_length < 0) { |
+ return Api::NewError("%s expects argument 'bytes_length' to be >= 0.", |
+ CURRENT_FUNC); |
+ } |
+ Service::SendEmbedderEvent(isolate, stream_id, event_kind, |
+ bytes, bytes_length); |
+ return Api::Success(); |
+} |
+ |
+ |
DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label, |
int64_t start_micros, |
int64_t end_micros) { |