| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 5788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5799 | 5799 |
| 5800 | 5800 |
| 5801 static bool StreamTraceEvents(Dart_StreamConsumer consumer, | 5801 static bool StreamTraceEvents(Dart_StreamConsumer consumer, |
| 5802 void* user_data, | 5802 void* user_data, |
| 5803 JSONStream* js) { | 5803 JSONStream* js) { |
| 5804 ASSERT(js != NULL); | 5804 ASSERT(js != NULL); |
| 5805 // Steal output from JSONStream. | 5805 // Steal output from JSONStream. |
| 5806 char* output = NULL; | 5806 char* output = NULL; |
| 5807 intptr_t output_length = 0; | 5807 intptr_t output_length = 0; |
| 5808 js->Steal(const_cast<const char**>(&output), &output_length); | 5808 js->Steal(const_cast<const char**>(&output), &output_length); |
| 5809 if (output_length < 3) { |
| 5810 // Empty JSON array. |
| 5811 free(output); |
| 5812 return false; |
| 5813 } |
| 5814 // We want to send the JSON array without the leading '[' or trailing ']' |
| 5815 // characters. |
| 5816 ASSERT(output[0] == '['); |
| 5817 ASSERT(output[output_length - 1] == ']'); |
| 5818 // Replace the ']' with the null character. |
| 5819 output[output_length - 1] = '\0'; |
| 5820 // We are skipping the '['. |
| 5821 output_length -= 1; |
| 5809 | 5822 |
| 5810 // Start the stream. | 5823 // Start the stream. |
| 5811 StartStreamToConsumer(consumer, user_data, "timeline"); | 5824 StartStreamToConsumer(consumer, user_data, "timeline"); |
| 5812 | 5825 |
| 5813 DataStreamToConsumer(consumer, | 5826 DataStreamToConsumer(consumer, |
| 5814 user_data, | 5827 user_data, |
| 5815 output, | 5828 &output[1], |
| 5816 output_length, | 5829 output_length, |
| 5817 "timeline"); | 5830 "timeline"); |
| 5818 | 5831 |
| 5819 // We stole the JSONStream's output buffer, free it. | 5832 // We stole the JSONStream's output buffer, free it. |
| 5820 free(output); | 5833 free(output); |
| 5821 | 5834 |
| 5822 // Finish the stream. | 5835 // Finish the stream. |
| 5823 FinishStreamToConsumer(consumer, user_data, "timeline"); | 5836 FinishStreamToConsumer(consumer, user_data, "timeline"); |
| 5824 return true; | 5837 return true; |
| 5825 } | 5838 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6031 ApiReallocate); | 6044 ApiReallocate); |
| 6032 writer.WriteFullSnapshot(); | 6045 writer.WriteFullSnapshot(); |
| 6033 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6046 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 6034 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6047 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 6035 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 6048 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
| 6036 | 6049 |
| 6037 return Api::Success(); | 6050 return Api::Success(); |
| 6038 } | 6051 } |
| 6039 | 6052 |
| 6040 } // namespace dart | 6053 } // namespace dart |
| OLD | NEW |