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

Unified Diff: runtime/vm/service.cc

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/include/dart_tools_api.h ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 83a89e3cfb25b8ffe14107fedf7396e97eef2b04..80607bba42fa084766dd68c0098570c562463657 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -859,7 +859,6 @@ void Service::InvokeMethod(Isolate* I, const Array& msg) {
if (handler != NULL) {
EmbedderHandleMessage(handler, &js);
- js.PostReply();
return;
}
@@ -1126,16 +1125,16 @@ void Service::EmbedderHandleMessage(EmbedderServiceHandler* handler,
ASSERT(handler != NULL);
Dart_ServiceRequestCallback callback = handler->callback();
ASSERT(callback != NULL);
- const char* r = NULL;
- const char* method = js->method();
- const char** keys = js->param_keys();
- const char** values = js->param_values();
- r = callback(method, keys, values, js->num_params(), handler->user_data());
- ASSERT(r != NULL);
- // TODO(johnmccutchan): Allow for NULL returns?
- TextBuffer* buffer = js->buffer();
- buffer->AddString(r);
- free(const_cast<char*>(r));
+ const char* response = NULL;
+ bool success = callback(js->method(), js->param_keys(), js->param_values(),
+ js->num_params(), handler->user_data(), &response);
+ ASSERT(response != NULL);
+ if (!success) {
+ js->SetupError();
+ }
+ js->buffer()->AddString(response);
+ js->PostReply();
+ free(const_cast<char*>(response));
}
« no previous file with comments | « runtime/include/dart_tools_api.h ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698