| Index: runtime/vm/service.cc
|
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
|
| index c28c62148e97b60f264dc2ddbddbfd7e8f0e84f4..797e060b6821e14c14ba8ca61c80ec008caa553b 100644
|
| --- a/runtime/vm/service.cc
|
| +++ b/runtime/vm/service.cc
|
| @@ -103,7 +103,7 @@ ServiceMethodDescriptor* FindMethod(const char* method_name);
|
| // Support for streams defined in embedders.
|
| Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL;
|
| Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL;
|
| -
|
| +Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL;
|
|
|
| // These are the set of streams known to the core VM.
|
| StreamInfo Service::vm_stream("VM");
|
| @@ -144,6 +144,7 @@ bool Service::ListenStream(const char* stream_id) {
|
| return false;
|
| }
|
|
|
| +
|
| void Service::CancelStream(const char* stream_id) {
|
| if (FLAG_trace_service) {
|
| OS::Print("vm-service: stopping stream '%s'\n",
|
| @@ -162,11 +163,49 @@ void Service::CancelStream(const char* stream_id) {
|
| }
|
| }
|
|
|
| +RawObject* Service::RequestAssets() {
|
| + Thread* T = Thread::Current();
|
| + Api::Scope api_scope(T);
|
| + if (get_service_assets_callback_ == NULL) {
|
| + return Object::null();
|
| + }
|
| + Dart_Handle handle = get_service_assets_callback_();
|
| + if (Dart_IsError(handle)) {
|
| + Dart_PropagateError(handle);
|
| + }
|
| + const Object& object = Object::Handle(Api::UnwrapHandle(handle));
|
| + if (object.IsNull()) {
|
| + return Object::null();
|
| + }
|
| + if (!object.IsTypedData()) {
|
| + const String& error_message =
|
| + String::Handle(
|
| + String::New("An implementation of Dart_GetVMServiceAssetsArchive "
|
| + "should return a Uint8Array or null."));
|
| + const Error& error = Error::Handle(ApiError::New(error_message));
|
| + Exceptions::PropagateError(error);
|
| + return Object::null();
|
| + }
|
| + const TypedData& typed_data = TypedData::Cast(object);
|
| + if (typed_data.ElementSizeInBytes() != 1) {
|
| + const String& error_message =
|
| + String::Handle(
|
| + String::New("An implementation of Dart_GetVMServiceAssetsArchive "
|
| + "should return a Uint8Array or null."));
|
| + const Error& error = Error::Handle(ApiError::New(error_message));
|
| + Exceptions::PropagateError(error);
|
| + return Object::null();
|
| + }
|
| + return Api::UnwrapHandle(handle);
|
| +}
|
| +
|
| +
|
| static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
|
| void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
|
| return reinterpret_cast<uint8_t*>(new_ptr);
|
| }
|
|
|
| +
|
| static void PrintMissingParamError(JSONStream* js,
|
| const char* param) {
|
| js->PrintError(kInvalidParams,
|
| @@ -925,6 +964,12 @@ void Service::SetEmbedderStreamCallbacks(
|
| }
|
|
|
|
|
| +void Service::SetGetServiceAssetsCallback(
|
| + Dart_GetVMServiceAssetsArchive get_service_assets) {
|
| + get_service_assets_callback_ = get_service_assets;
|
| +}
|
| +
|
| +
|
| EmbedderServiceHandler* Service::FindRootEmbedderHandler(
|
| const char* name) {
|
| EmbedderServiceHandler* current = root_service_handler_head_;
|
|
|