| 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 11 matching lines...) Expand all Loading... |
| 22 #include "vm/native_arguments.h" | 22 #include "vm/native_arguments.h" |
| 23 #include "vm/native_symbol.h" | 23 #include "vm/native_symbol.h" |
| 24 #include "vm/object.h" | 24 #include "vm/object.h" |
| 25 #include "vm/object_graph.h" | 25 #include "vm/object_graph.h" |
| 26 #include "vm/object_id_ring.h" | 26 #include "vm/object_id_ring.h" |
| 27 #include "vm/object_store.h" | 27 #include "vm/object_store.h" |
| 28 #include "vm/parser.h" | 28 #include "vm/parser.h" |
| 29 #include "vm/port.h" | 29 #include "vm/port.h" |
| 30 #include "vm/profiler_service.h" | 30 #include "vm/profiler_service.h" |
| 31 #include "vm/reusable_handles.h" | 31 #include "vm/reusable_handles.h" |
| 32 #include "vm/safepoint.h" |
| 32 #include "vm/service_event.h" | 33 #include "vm/service_event.h" |
| 33 #include "vm/service_isolate.h" | 34 #include "vm/service_isolate.h" |
| 34 #include "vm/source_report.h" | 35 #include "vm/source_report.h" |
| 35 #include "vm/stack_frame.h" | 36 #include "vm/stack_frame.h" |
| 36 #include "vm/symbols.h" | 37 #include "vm/symbols.h" |
| 37 #include "vm/timeline.h" | 38 #include "vm/timeline.h" |
| 38 #include "vm/type_table.h" | 39 #include "vm/type_table.h" |
| 39 #include "vm/unicode.h" | 40 #include "vm/unicode.h" |
| 40 #include "vm/version.h" | 41 #include "vm/version.h" |
| 41 | 42 |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 js.PostReply(); | 832 js.PostReply(); |
| 832 } | 833 } |
| 833 | 834 |
| 834 | 835 |
| 835 void Service::InvokeMethod(Isolate* I, | 836 void Service::InvokeMethod(Isolate* I, |
| 836 const Array& msg, | 837 const Array& msg, |
| 837 bool parameters_are_dart_objects) { | 838 bool parameters_are_dart_objects) { |
| 838 Thread* T = Thread::Current(); | 839 Thread* T = Thread::Current(); |
| 839 ASSERT(I == T->isolate()); | 840 ASSERT(I == T->isolate()); |
| 840 ASSERT(I != NULL); | 841 ASSERT(I != NULL); |
| 842 ASSERT(T->execution_state() == Thread::kThreadInVM); |
| 841 ASSERT(!msg.IsNull()); | 843 ASSERT(!msg.IsNull()); |
| 842 ASSERT(msg.Length() == 6); | 844 ASSERT(msg.Length() == 6); |
| 843 | 845 |
| 844 { | 846 { |
| 845 StackZone zone(T); | 847 StackZone zone(T); |
| 846 HANDLESCOPE(T); | 848 HANDLESCOPE(T); |
| 847 | 849 |
| 848 Instance& reply_port = Instance::Handle(Z); | 850 Instance& reply_port = Instance::Handle(Z); |
| 849 Instance& seq = String::Handle(Z); | 851 Instance& seq = String::Handle(Z); |
| 850 String& method_name = String::Handle(Z); | 852 String& method_name = String::Handle(Z); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 EmbedderServiceHandler* next_; | 1190 EmbedderServiceHandler* next_; |
| 1189 }; | 1191 }; |
| 1190 | 1192 |
| 1191 | 1193 |
| 1192 void Service::EmbedderHandleMessage(EmbedderServiceHandler* handler, | 1194 void Service::EmbedderHandleMessage(EmbedderServiceHandler* handler, |
| 1193 JSONStream* js) { | 1195 JSONStream* js) { |
| 1194 ASSERT(handler != NULL); | 1196 ASSERT(handler != NULL); |
| 1195 Dart_ServiceRequestCallback callback = handler->callback(); | 1197 Dart_ServiceRequestCallback callback = handler->callback(); |
| 1196 ASSERT(callback != NULL); | 1198 ASSERT(callback != NULL); |
| 1197 const char* response = NULL; | 1199 const char* response = NULL; |
| 1198 bool success = callback(js->method(), js->param_keys(), js->param_values(), | 1200 bool success; |
| 1199 js->num_params(), handler->user_data(), &response); | 1201 { |
| 1202 TransitionVMToNative transition(Thread::Current()); |
| 1203 success = callback(js->method(), js->param_keys(), js->param_values(), |
| 1204 js->num_params(), handler->user_data(), &response); |
| 1205 } |
| 1200 ASSERT(response != NULL); | 1206 ASSERT(response != NULL); |
| 1201 if (!success) { | 1207 if (!success) { |
| 1202 js->SetupError(); | 1208 js->SetupError(); |
| 1203 } | 1209 } |
| 1204 js->buffer()->AddString(response); | 1210 js->buffer()->AddString(response); |
| 1205 js->PostReply(); | 1211 js->PostReply(); |
| 1206 free(const_cast<char*>(response)); | 1212 free(const_cast<char*>(response)); |
| 1207 } | 1213 } |
| 1208 | 1214 |
| 1209 | 1215 |
| (...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4141 if (strcmp(method_name, method.name) == 0) { | 4147 if (strcmp(method_name, method.name) == 0) { |
| 4142 return &method; | 4148 return &method; |
| 4143 } | 4149 } |
| 4144 } | 4150 } |
| 4145 return NULL; | 4151 return NULL; |
| 4146 } | 4152 } |
| 4147 | 4153 |
| 4148 #endif // !PRODUCT | 4154 #endif // !PRODUCT |
| 4149 | 4155 |
| 4150 } // namespace dart | 4156 } // namespace dart |
| OLD | NEW |