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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef INCLUDE_DART_TOOLS_API_H_ 5 #ifndef INCLUDE_DART_TOOLS_API_H_
6 #define INCLUDE_DART_TOOLS_API_H_ 6 #define INCLUDE_DART_TOOLS_API_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 /** \mainpage Dart Tools Embedding API Reference 10 /** \mainpage Dart Tools Embedding API Reference
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 * ======= 745 * =======
746 */ 746 */
747 747
748 /** 748 /**
749 * A service request callback function. 749 * A service request callback function.
750 * 750 *
751 * These callbacks, registered by the embedder, are called when the VM receives 751 * These callbacks, registered by the embedder, are called when the VM receives
752 * a service request it can't handle and the service request command name 752 * a service request it can't handle and the service request command name
753 * matches one of the embedder registered handlers. 753 * matches one of the embedder registered handlers.
754 * 754 *
755 * The return value of the callback indicates whether the response
756 * should be used as a regular result or an error result.
757 * Specifically, if the callback returns true, a regular JSON-RPC
758 * response is built in the following way:
759 *
760 * {
761 * "jsonrpc": "2.0",
762 * "result": <json_object>,
763 * "id": <some sequence id>,
764 * }
765 *
766 * If the callback returns false, a JSON-RPC error is built like this:
767 *
768 * {
769 * "jsonrpc": "2.0",
770 * "error": <json_object>,
771 * "id": <some sequence id>,
772 * }
773 *
755 * \param method The rpc method name. 774 * \param method The rpc method name.
756 * \param param_keys Service requests can have key-value pair parameters. The 775 * \param param_keys Service requests can have key-value pair parameters. The
757 * keys and values are flattened and stored in arrays. 776 * keys and values are flattened and stored in arrays.
758 * \param param_values The values associated with the keys. 777 * \param param_values The values associated with the keys.
759 * \param num_params The length of the param_keys and param_values arrays. 778 * \param num_params The length of the param_keys and param_values arrays.
760 * \param user_data The user_data pointer registered with this handler. 779 * \param user_data The user_data pointer registered with this handler.
780 * \param result A C string containing a valid JSON object. The returned
781 * pointer will be freed by the VM by calling free.
761 * 782 *
762 * \return Returns a C string containing a valid JSON object. The returned 783 * \return True if the result is a regular JSON-RPC response, false if the
763 * pointer will be freed by the VM by calling free. 784 * result is a JSON-RPC error.
764 */ 785 */
765 typedef const char* (*Dart_ServiceRequestCallback)( 786 typedef bool (*Dart_ServiceRequestCallback)(
766 const char* method, 787 const char* method,
767 const char** param_keys, 788 const char** param_keys,
768 const char** param_values, 789 const char** param_values,
769 intptr_t num_params, 790 intptr_t num_params,
770 void* user_data); 791 void* user_data,
792 const char** json_object);
771 793
772 794
773 /** 795 /**
774 * Register a Dart_ServiceRequestCallback to be called to handle 796 * Register a Dart_ServiceRequestCallback to be called to handle
775 * requests for the named rpc on a specific isolate. The callback will 797 * requests for the named rpc on a specific isolate. The callback will
776 * be invoked with the current isolate set to the request target. 798 * be invoked with the current isolate set to the request target.
777 * 799 *
778 * \param method The name of the method that this callback is responsible for. 800 * \param method The name of the method that this callback is responsible for.
779 * \param callback The callback to invoke. 801 * \param callback The callback to invoke.
780 * \param user_data The user data passed to the callback. 802 * \param user_data The user data passed to the callback.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 * \param start_recording See Dart_EmbedderTimelineStartRecording. 1061 * \param start_recording See Dart_EmbedderTimelineStartRecording.
1040 * \param stop_recording See Dart_EmbedderTimelineStopRecording. 1062 * \param stop_recording See Dart_EmbedderTimelineStopRecording.
1041 * 1063 *
1042 * NOTE: To avoid races, this should be called before Dart_Initialize. 1064 * NOTE: To avoid races, this should be called before Dart_Initialize.
1043 */ 1065 */
1044 DART_EXPORT void Dart_SetEmbedderTimelineCallbacks( 1066 DART_EXPORT void Dart_SetEmbedderTimelineCallbacks(
1045 Dart_EmbedderTimelineStartRecording start_recording, 1067 Dart_EmbedderTimelineStartRecording start_recording,
1046 Dart_EmbedderTimelineStopRecording stop_recording); 1068 Dart_EmbedderTimelineStopRecording stop_recording);
1047 1069
1048 #endif // INCLUDE_DART_TOOLS_API_H_ 1070 #endif // INCLUDE_DART_TOOLS_API_H_
OLDNEW
« 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