| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 | 6 |
| 7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
| 8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/message.h" | 10 #include "vm/message.h" |
| 11 #include "vm/metrics.h" | 11 #include "vm/metrics.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/service.h" | 13 #include "vm/service.h" |
| 14 #include "vm/service_event.h" | 14 #include "vm/service_event.h" |
| 15 #include "vm/timeline.h" | 15 #include "vm/timeline.h" |
| 16 #include "vm/unicode.h" | 16 #include "vm/unicode.h" |
| 17 | 17 |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 #ifndef PRODUCT | 21 #ifndef PRODUCT |
| 22 | 22 |
| 23 void AppendJSONStreamConsumer(Dart_StreamConsumer_State state, |
| 24 const char* stream_name, |
| 25 const uint8_t* buffer, |
| 26 intptr_t buffer_length, |
| 27 void* user_data) { |
| 28 if ((state == Dart_StreamConsumer_kStart) || |
| 29 (state == Dart_StreamConsumer_kFinish)) { |
| 30 // Ignore. |
| 31 return; |
| 32 } |
| 33 ASSERT(state == Dart_StreamConsumer_kData); |
| 34 JSONStream* js = reinterpret_cast<JSONStream*>(user_data); |
| 35 ASSERT(js != NULL); |
| 36 js->AppendSerializedObject(buffer, buffer_length); |
| 37 } |
| 38 |
| 39 |
| 23 DECLARE_FLAG(bool, trace_service); | 40 DECLARE_FLAG(bool, trace_service); |
| 24 | 41 |
| 25 JSONStream::JSONStream(intptr_t buf_size) | 42 JSONStream::JSONStream(intptr_t buf_size) |
| 26 : open_objects_(0), | 43 : open_objects_(0), |
| 27 buffer_(buf_size), | 44 buffer_(buf_size), |
| 28 default_id_zone_(), | 45 default_id_zone_(), |
| 29 id_zone_(&default_id_zone_), | 46 id_zone_(&default_id_zone_), |
| 30 reply_port_(ILLEGAL_PORT), | 47 reply_port_(ILLEGAL_PORT), |
| 31 seq_(NULL), | 48 seq_(NULL), |
| 32 method_(""), | 49 method_(""), |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 273 } |
| 257 } | 274 } |
| 258 | 275 |
| 259 | 276 |
| 260 void JSONStream::AppendSerializedObject(const char* serialized_object) { | 277 void JSONStream::AppendSerializedObject(const char* serialized_object) { |
| 261 PrintCommaIfNeeded(); | 278 PrintCommaIfNeeded(); |
| 262 buffer_.AddString(serialized_object); | 279 buffer_.AddString(serialized_object); |
| 263 } | 280 } |
| 264 | 281 |
| 265 | 282 |
| 283 void JSONStream::AppendSerializedObject(const uint8_t* buffer, |
| 284 intptr_t buffer_length) { |
| 285 buffer_.AddRaw(buffer, buffer_length); |
| 286 } |
| 287 |
| 266 void JSONStream::AppendSerializedObject(const char* property_name, | 288 void JSONStream::AppendSerializedObject(const char* property_name, |
| 267 const char* serialized_object) { | 289 const char* serialized_object) { |
| 268 PrintCommaIfNeeded(); | 290 PrintCommaIfNeeded(); |
| 269 PrintPropertyName(property_name); | 291 PrintPropertyName(property_name); |
| 270 buffer_.AddString(serialized_object); | 292 buffer_.AddString(serialized_object); |
| 271 } | 293 } |
| 272 | 294 |
| 273 void JSONStream::Clear() { | 295 void JSONStream::Clear() { |
| 274 buffer_.Clear(); | 296 buffer_.Clear(); |
| 275 open_objects_ = 0; | 297 open_objects_ = 0; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 ASSERT(len == len2); | 889 ASSERT(len == len2); |
| 868 stream_->buffer_.AddChar('"'); | 890 stream_->buffer_.AddChar('"'); |
| 869 stream_->AddEscapedUTF8String(p); | 891 stream_->AddEscapedUTF8String(p); |
| 870 stream_->buffer_.AddChar('"'); | 892 stream_->buffer_.AddChar('"'); |
| 871 free(p); | 893 free(p); |
| 872 } | 894 } |
| 873 | 895 |
| 874 #endif // !PRODUCT | 896 #endif // !PRODUCT |
| 875 | 897 |
| 876 } // namespace dart | 898 } // namespace dart |
| OLD | NEW |