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" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 157 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
158 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 158 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
159 return reinterpret_cast<uint8_t*>(new_ptr); | 159 return reinterpret_cast<uint8_t*>(new_ptr); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 void JSONStream::PostNullReply(Dart_Port port) { | 163 void JSONStream::PostNullReply(Dart_Port port) { |
164 const Object& reply = Object::Handle(Object::null()); | 164 PortMap::PostMessage(new Message( |
165 ASSERT(reply.IsNull()); | 165 port, reinterpret_cast<uint8_t*>(Object::null()), 0, |
166 | 166 Message::kNormalPriority)); |
Ivan Posva
2015/12/11 21:02:39
Why not call the shortcut constructor?
zra
2015/12/11 22:01:31
Done.
| |
167 uint8_t* data = NULL; | |
168 MessageWriter writer(&data, &allocator, false); | |
169 writer.WriteMessage(reply); | |
170 PortMap::PostMessage(new Message(port, | |
171 data, | |
172 writer.BytesWritten(), | |
173 Message::kNormalPriority)); | |
174 } | 167 } |
175 | 168 |
176 | 169 |
177 void JSONStream::PostReply() { | 170 void JSONStream::PostReply() { |
178 Dart_Port port = reply_port(); | 171 Dart_Port port = reply_port(); |
179 ASSERT(port != ILLEGAL_PORT); | 172 ASSERT(port != ILLEGAL_PORT); |
180 set_reply_port(ILLEGAL_PORT); // Prevent double replies. | 173 set_reply_port(ILLEGAL_PORT); // Prevent double replies. |
181 int64_t process_delta_micros = 0; | 174 int64_t process_delta_micros = 0; |
182 if (FLAG_trace_service) { | 175 if (FLAG_trace_service) { |
183 process_delta_micros = OS::GetCurrentTimeMicros() - setup_time_micros_; | 176 process_delta_micros = OS::GetCurrentTimeMicros() - setup_time_micros_; |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 829 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
837 va_end(args); | 830 va_end(args); |
838 ASSERT(len == len2); | 831 ASSERT(len == len2); |
839 stream_->buffer_.AddChar('"'); | 832 stream_->buffer_.AddChar('"'); |
840 stream_->AddEscapedUTF8String(p); | 833 stream_->AddEscapedUTF8String(p); |
841 stream_->buffer_.AddChar('"'); | 834 stream_->buffer_.AddChar('"'); |
842 free(p); | 835 free(p); |
843 } | 836 } |
844 | 837 |
845 } // namespace dart | 838 } // namespace dart |
OLD | NEW |