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

Unified Diff: runtime/include/dart_tools_api.h

Issue 2041293003: Allow embedder service request handlers to return JSON-RPC errors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/main.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/include/dart_tools_api.h
diff --git a/runtime/include/dart_tools_api.h b/runtime/include/dart_tools_api.h
index da43d94f830187f432ec625bd885b3c83f6e9aff..961c444d702bf9f75bc00c9507106a61f0efc70c 100644
--- a/runtime/include/dart_tools_api.h
+++ b/runtime/include/dart_tools_api.h
@@ -752,22 +752,44 @@ DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate isolate);
* a service request it can't handle and the service request command name
* matches one of the embedder registered handlers.
*
+ * The return value of the callback indicates whether the response
+ * should be used as a regular result or an error result.
+ * Specifically, if the callback returns true, a regular JSON-RPC
+ * response is built in the following way:
+ *
+ * {
+ * "jsonrpc": "2.0",
+ * "result": <json_object>,
+ * "id": <some sequence id>,
+ * }
+ *
+ * If the callback returns false, a JSON-RPC error is built like this:
+ *
+ * {
+ * "jsonrpc": "2.0",
+ * "error": <json_object>,
+ * "id": <some sequence id>,
+ * }
+ *
* \param method The rpc method name.
* \param param_keys Service requests can have key-value pair parameters. The
* keys and values are flattened and stored in arrays.
* \param param_values The values associated with the keys.
* \param num_params The length of the param_keys and param_values arrays.
* \param user_data The user_data pointer registered with this handler.
+ * \param result A C string containing a valid JSON object. The returned
+ * pointer will be freed by the VM by calling free.
*
- * \return Returns a C string containing a valid JSON object. The returned
- * pointer will be freed by the VM by calling free.
+ * \return True if the result is a regular JSON-RPC response, false if the
+ * result is a JSON-RPC error.
*/
-typedef const char* (*Dart_ServiceRequestCallback)(
+typedef bool (*Dart_ServiceRequestCallback)(
const char* method,
const char** param_keys,
const char** param_values,
intptr_t num_params,
- void* user_data);
+ void* user_data,
+ const char** json_object);
/**
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698