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

Unified Diff: runtime/vm/json_stream.cc

Issue 1093043004: Do not JSON encode the 'result' of a service rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 8 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/vm/json_stream.h ('k') | runtime/vm/service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/json_stream.cc
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index 06c13fc645efc95043c7a72242c861576ee33a26..f894c712fedc1b5794c33d4624a46cd9df89dd76 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -22,6 +22,7 @@ JSONStream::JSONStream(intptr_t buf_size)
: open_objects_(0),
buffer_(buf_size),
reply_port_(ILLEGAL_PORT),
+ seq_(""),
method_(""),
param_keys_(NULL),
param_values_(NULL),
@@ -35,10 +36,12 @@ JSONStream::~JSONStream() {
void JSONStream::Setup(Zone* zone,
Dart_Port reply_port,
+ const String& seq,
const String& method,
const Array& param_keys,
const Array& param_values) {
set_reply_port(reply_port);
+ seq_ = seq.ToCString();
method_ = method.ToCString();
String& string_iterator = String::Handle();
@@ -66,6 +69,13 @@ void JSONStream::Setup(Zone* zone,
isolate_name, method_);
setup_time_micros_ = OS::GetCurrentTimeMicros();
}
+ buffer_.Printf("{\"result\":");
+}
+
+
+void JSONStream::SetupError() {
+ buffer_.Clear();
+ buffer_.Printf("{\"error\":");
}
@@ -83,6 +93,8 @@ void JSONStream::PostReply() {
if (FLAG_trace_service) {
process_delta_micros = OS::GetCurrentTimeMicros() - setup_time_micros_;
}
+ // TODO(turnidge): Handle non-string sequence numbers.
+ buffer_.Printf(", \"id\":\"%s\"}", seq());
const String& reply = String::Handle(String::New(ToCString()));
ASSERT(!reply.IsNull());
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698