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

Unified Diff: runtime/bin/vmservice_impl.cc

Issue 170943003: Allow for embedder provided service request handlers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | runtime/include/dart_api.h » ('j') | runtime/vm/service.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | runtime/vm/service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698