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

Side by Side Diff: runtime/vm/json_stream.cc

Issue 2662333002: Start adding vm/cc tests for rewind functionality. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
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 "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/json_stream.h" 10 #include "vm/json_stream.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 204
205 static void Finalizer(void* isolate_callback_data, 205 static void Finalizer(void* isolate_callback_data,
206 Dart_WeakPersistentHandle handle, 206 Dart_WeakPersistentHandle handle,
207 void* buffer) { 207 void* buffer) {
208 free(buffer); 208 free(buffer);
209 } 209 }
210 210
211 211
212 void JSONStream::PostReply() { 212 void JSONStream::PostReply() {
213 ASSERT(seq_ != NULL);
213 Dart_Port port = reply_port(); 214 Dart_Port port = reply_port();
214 ASSERT(port != ILLEGAL_PORT);
215 set_reply_port(ILLEGAL_PORT); // Prevent double replies. 215 set_reply_port(ILLEGAL_PORT); // Prevent double replies.
216 ASSERT(seq_ != NULL);
217 if (seq_->IsString()) { 216 if (seq_->IsString()) {
218 const String& str = String::Cast(*seq_); 217 const String& str = String::Cast(*seq_);
219 PrintProperty("id", str.ToCString()); 218 PrintProperty("id", str.ToCString());
220 } else if (seq_->IsInteger()) { 219 } else if (seq_->IsInteger()) {
221 const Integer& integer = Integer::Cast(*seq_); 220 const Integer& integer = Integer::Cast(*seq_);
222 PrintProperty64("id", integer.AsInt64Value()); 221 PrintProperty64("id", integer.AsInt64Value());
223 } else if (seq_->IsDouble()) { 222 } else if (seq_->IsDouble()) {
224 const Double& dbl = Double::Cast(*seq_); 223 const Double& dbl = Double::Cast(*seq_);
225 PrintProperty("id", dbl.value()); 224 PrintProperty("id", dbl.value());
226 } else if (seq_->IsNull()) { 225 } else if (seq_->IsNull()) {
226 if (port == ILLEGAL_PORT) {
227 // This path is only used in tests.
228 buffer_.AddChar('}'); // Finish our message.
229 char* cstr;
230 intptr_t length;
231 Steal(&cstr, &length);
232 fprintf(stderr, "-----\nDropping reply:\n%s\n-----\n", cstr);
rmacnak 2017/01/31 19:21:00 OS::PrintErr
turnidge 2017/01/31 19:35:46 Done.
233 free(cstr);
234 }
227 // JSON-RPC 2.0 says that a request with a null ID shouldn't get a reply. 235 // JSON-RPC 2.0 says that a request with a null ID shouldn't get a reply.
228 PostNullReply(port); 236 PostNullReply(port);
229 return; 237 return;
230 } 238 }
231 buffer_.AddChar('}'); 239 ASSERT(port != ILLEGAL_PORT);
232 240
241 buffer_.AddChar('}'); // Finish our message.
233 char* cstr; 242 char* cstr;
234 intptr_t length; 243 intptr_t length;
235 Steal(&cstr, &length); 244 Steal(&cstr, &length);
236 245
237 bool result; 246 bool result;
238 { 247 {
239 TransitionVMToNative transition(Thread::Current()); 248 TransitionVMToNative transition(Thread::Current());
240 Dart_CObject bytes; 249 Dart_CObject bytes;
241 bytes.type = Dart_CObject_kExternalTypedData; 250 bytes.type = Dart_CObject_kExternalTypedData;
242 bytes.value.as_external_typed_data.type = Dart_TypedData_kUint8; 251 bytes.value.as_external_typed_data.type = Dart_TypedData_kUint8;
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 ASSERT(len == len2); 1031 ASSERT(len == len2);
1023 stream_->buffer_.AddChar('"'); 1032 stream_->buffer_.AddChar('"');
1024 stream_->AddEscapedUTF8String(p); 1033 stream_->AddEscapedUTF8String(p);
1025 stream_->buffer_.AddChar('"'); 1034 stream_->buffer_.AddChar('"');
1026 free(p); 1035 free(p);
1027 } 1036 }
1028 1037
1029 #endif // !PRODUCT 1038 #endif // !PRODUCT
1030 1039
1031 } // namespace dart 1040 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698