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

Unified Diff: runtime/include/dart_api.h

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 | « runtime/bin/vmservice_impl.cc ('k') | runtime/platform/json.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/include/dart_api.h
diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h
index 2cc3de7c4c5b4daac72c4667e98e706cdad5f4b6..8e702d1f32e2b289d1b8a36c84b5790a33a478bf 100755
--- a/runtime/include/dart_api.h
+++ b/runtime/include/dart_api.h
@@ -2465,4 +2465,78 @@ DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer);
DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data);
+/**
+ * Returns true if the service is enabled. False otherwise.
+ *
+ * \return Returns true if service is running.
+ */
+DART_EXPORT bool Dart_IsServiceRunning();
+
+
+/**
+ * A service request callback function.
+ *
+ * These callbacks, registered by the embedder, are called when the VM receives
+ * a service request it can't handle and the service request command name
+ * matches one of the embedder registered handlers.
+ *
+ * \param name The service request command name. Always the first entry
+ * in the arguments array. Will match the name the callback was
+ * registered with.
+ * \param arguments The service request command arguments. Incoming service
+ * request paths are split like file system paths and flattened into an array
+ * (e.g. /foo/bar becomes the array ["foo", "bar"].
+ * \param num_arguments The length of the arguments array.
+ * \param option_keys Service requests can have options key-value pairs. The
+ * keys and values are flattened and stored in arrays.
+ * \param option_values The values associated with the keys.
+ * \param num_options The length of the option_keys and option_values array.
+ * \param user_data The user_data pointer registered with this handler.
+ *
+ * \return Returns a C string containing a valid JSON object. The returned
+ * pointer will be freed by the VM by calling free.
+ */
+typedef const char* (*Dart_ServiceRequestCallback)(
+ 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);
+
+/**
+ * Register a Dart_ServiceRequestCallback to be called to handle requests
+ * with name on a specific isolate. The callback will be invoked with the
+ * current isolate set to the request target.
+ *
+ * \param name The name of the command that this callback is responsible for.
+ * \param callback The callback to invoke.
+ * \param user_data The user data passed to the callback.
+ *
+ * NOTE: If multiple callbacks with the same name are registered, only the
+ * last callback registered will be remembered.
+ */
+DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback(
+ const char* name,
+ Dart_ServiceRequestCallback callback,
+ void* user_data);
+
+/**
+ * Register a Dart_ServiceRequestCallback to be called to handle requests
+ * with name. The callback will be invoked without a current isolate.
+ *
+ * \param name The name of the command that this callback is responsible for.
+ * \param callback The callback to invoke.
+ * \param user_data The user data passed to the callback.
+ *
+ * NOTE: If multiple callbacks with the same name are registered, only the
+ * last callback registered will be remembered.
+ */
+DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
+ const char* name,
+ Dart_ServiceRequestCallback callback,
+ void* user_data);
+
+
#endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
« no previous file with comments | « runtime/bin/vmservice_impl.cc ('k') | runtime/platform/json.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698