Chromium Code Reviews| Index: runtime/bin/vmservice_impl.cc |
| diff --git a/runtime/bin/vmservice_impl.cc b/runtime/bin/vmservice_impl.cc |
| index b35c67e00ed72a974a17a9be38bdfd6fb11efb87..ba7acd46d23231c58529b88930e0542ff21a1b17 100644 |
| --- a/runtime/bin/vmservice_impl.cc |
| +++ b/runtime/bin/vmservice_impl.cc |
| @@ -9,7 +9,9 @@ |
| #include "bin/builtin.h" |
| #include "bin/dartutils.h" |
| #include "bin/isolate_data.h" |
| +#include "bin/platform.h" |
| #include "bin/thread.h" |
| +#include "platform/json.h" |
| namespace dart { |
| namespace bin { |
| @@ -86,11 +88,48 @@ class Resources { |
| const char* VmService::error_msg_ = NULL; |
| +static void* embedder_request_callback_user_data = reinterpret_cast<void*>(0x3); |
| + |
| +static const char* embedder_request_callback(const char* name, |
| + const char** arguments, |
| + intptr_t num_arguments, |
| + const char** option_keys, |
| + const char** option_values, |
| + intptr_t num_options, |
| + void* user_data) { |
| + ASSERT(user_data == embedder_request_callback_user_data); |
| + TextBuffer tb(256); |
| + tb.AddString("{\"type\": \"Embedder\",\"value\":\"Standalone\"}"); |
|
turnidge
2014/02/18 22:25:12
Shouldn't this be a root-level request?
Cutch
2014/02/18 22:34:10
I'm dropping these for now.
|
| + return tb.Steal(); |
| +} |
| + |
| + |
| +static const char* embedder_os_callback(const char* name, |
| + const char** arguments, |
| + intptr_t num_arguments, |
| + const char** option_keys, |
| + const char** option_values, |
| + intptr_t num_options, |
| + void* user_data) { |
| + TextBuffer tb(256); |
| + tb.AddString("{\"type\": \"OS\", \"value\":\""); |
| + tb.AddString(Platform::OperatingSystem()); |
| + tb.AddString("\"}"); |
| + return tb.Steal(); |
| +} |
| + |
| + |
| bool VmService::Start(intptr_t server_port) { |
| bool r = _Start(server_port); |
| if (!r) { |
| return r; |
| } |
| + // Register an embedder provided isolate request callback. |
| + Dart_RegisterIsolateServiceRequestCallback( |
| + "_embedder", |
| + embedder_request_callback, |
| + embedder_request_callback_user_data); |
| + Dart_RegisterRootServiceRequestCallback("_os", embedder_os_callback, NULL); |
| // Start processing messages in a new thread. |
| dart::Thread::Start(ThreadMain, NULL); |
| return true; |