| 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 "vm/service.h" | 5 #include "vm/service.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 | 10 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 const Error& error = Error::Handle(ApiError::New(error_message)); | 215 const Error& error = Error::Handle(ApiError::New(error_message)); |
| 216 Exceptions::PropagateError(error); | 216 Exceptions::PropagateError(error); |
| 217 return Object::null(); | 217 return Object::null(); |
| 218 } | 218 } |
| 219 return Api::UnwrapHandle(handle); | 219 return Api::UnwrapHandle(handle); |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 223 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 224 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 224 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 225 if (new_ptr == NULL) { |
| 226 OUT_OF_MEMORY(); |
| 227 } |
| 225 return reinterpret_cast<uint8_t*>(new_ptr); | 228 return reinterpret_cast<uint8_t*>(new_ptr); |
| 226 } | 229 } |
| 227 | 230 |
| 228 | 231 |
| 229 static void PrintMissingParamError(JSONStream* js, | 232 static void PrintMissingParamError(JSONStream* js, |
| 230 const char* param) { | 233 const char* param) { |
| 231 js->PrintError(kInvalidParams, | 234 js->PrintError(kInvalidParams, |
| 232 "%s expects the '%s' parameter", js->method(), param); | 235 "%s expects the '%s' parameter", js->method(), param); |
| 233 } | 236 } |
| 234 | 237 |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 void Service::SendEventWithData(const char* stream_id, | 1034 void Service::SendEventWithData(const char* stream_id, |
| 1032 const char* event_type, | 1035 const char* event_type, |
| 1033 const char* metadata, | 1036 const char* metadata, |
| 1034 intptr_t metadata_size, | 1037 intptr_t metadata_size, |
| 1035 const uint8_t* data, | 1038 const uint8_t* data, |
| 1036 intptr_t data_size) { | 1039 intptr_t data_size) { |
| 1037 // Bitstream: [metadata size (big-endian 64 bit)] [metadata (UTF-8)] [data] | 1040 // Bitstream: [metadata size (big-endian 64 bit)] [metadata (UTF-8)] [data] |
| 1038 const intptr_t total_bytes = sizeof(uint64_t) + metadata_size + data_size; | 1041 const intptr_t total_bytes = sizeof(uint64_t) + metadata_size + data_size; |
| 1039 | 1042 |
| 1040 uint8_t* message = static_cast<uint8_t*>(malloc(total_bytes)); | 1043 uint8_t* message = static_cast<uint8_t*>(malloc(total_bytes)); |
| 1044 if (message == NULL) { |
| 1045 OUT_OF_MEMORY(); |
| 1046 } |
| 1041 intptr_t offset = 0; | 1047 intptr_t offset = 0; |
| 1042 | 1048 |
| 1043 // Metadata size. | 1049 // Metadata size. |
| 1044 reinterpret_cast<uint64_t*>(message)[0] = | 1050 reinterpret_cast<uint64_t*>(message)[0] = |
| 1045 Utils::HostToBigEndian64(metadata_size); | 1051 Utils::HostToBigEndian64(metadata_size); |
| 1046 offset += sizeof(uint64_t); | 1052 offset += sizeof(uint64_t); |
| 1047 | 1053 |
| 1048 // Metadata. | 1054 // Metadata. |
| 1049 memmove(&message[offset], metadata, metadata_size); | 1055 memmove(&message[offset], metadata, metadata_size); |
| 1050 offset += metadata_size; | 1056 offset += metadata_size; |
| (...skipping 3172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4223 if (strcmp(method_name, method.name) == 0) { | 4229 if (strcmp(method_name, method.name) == 0) { |
| 4224 return &method; | 4230 return &method; |
| 4225 } | 4231 } |
| 4226 } | 4232 } |
| 4227 return NULL; | 4233 return NULL; |
| 4228 } | 4234 } |
| 4229 | 4235 |
| 4230 #endif // !PRODUCT | 4236 #endif // !PRODUCT |
| 4231 | 4237 |
| 4232 } // namespace dart | 4238 } // namespace dart |
| OLD | NEW |