| 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 list.SetAt(0, stream_id_str); | 637 list.SetAt(0, stream_id_str); |
| 638 list.SetAt(1, event_message); | 638 list.SetAt(1, event_message); |
| 639 | 639 |
| 640 // Push the event to port_. | 640 // Push the event to port_. |
| 641 uint8_t* data = NULL; | 641 uint8_t* data = NULL; |
| 642 MessageWriter writer(&data, &allocator, false); | 642 MessageWriter writer(&data, &allocator, false); |
| 643 writer.WriteMessage(list); | 643 writer.WriteMessage(list); |
| 644 intptr_t len = writer.BytesWritten(); | 644 intptr_t len = writer.BytesWritten(); |
| 645 if (FLAG_trace_service) { | 645 if (FLAG_trace_service) { |
| 646 OS::Print( | 646 OS::Print( |
| 647 "vm-service: Pushing event of type %s to stream %s, len %" Pd "\n", | 647 "vm-service: Pushing event of type %s to stream %s (%s), len %" Pd "\n", |
| 648 event_type, stream_id, len); | 648 event_type, stream_id, isolate->name(), len); |
| 649 } | 649 } |
| 650 // TODO(turnidge): For now we ignore failure to send an event. Revisit? | 650 // TODO(turnidge): For now we ignore failure to send an event. Revisit? |
| 651 PortMap::PostMessage( | 651 PortMap::PostMessage( |
| 652 new Message(ServiceIsolate::Port(), data, len, Message::kNormalPriority)); | 652 new Message(ServiceIsolate::Port(), data, len, Message::kNormalPriority)); |
| 653 } | 653 } |
| 654 | 654 |
| 655 | 655 |
| 656 // TODO(turnidge): Rewrite this method to use Post_CObject instead. | 656 // TODO(turnidge): Rewrite this method to use Post_CObject instead. |
| 657 void Service::SendEventWithData(const char* stream_id, | 657 void Service::SendEventWithData(const char* stream_id, |
| 658 const char* event_type, | 658 const char* event_type, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 stream_id_cobj.type = Dart_CObject_kString; | 729 stream_id_cobj.type = Dart_CObject_kString; |
| 730 stream_id_cobj.value.as_string = const_cast<char*>(stream_id); | 730 stream_id_cobj.value.as_string = const_cast<char*>(stream_id); |
| 731 list_values[0] = &stream_id_cobj; | 731 list_values[0] = &stream_id_cobj; |
| 732 | 732 |
| 733 Dart_CObject json_cobj; | 733 Dart_CObject json_cobj; |
| 734 json_cobj.type = Dart_CObject_kString; | 734 json_cobj.type = Dart_CObject_kString; |
| 735 json_cobj.value.as_string = const_cast<char*>(event->ToCString()); | 735 json_cobj.value.as_string = const_cast<char*>(event->ToCString()); |
| 736 list_values[1] = &json_cobj; | 736 list_values[1] = &json_cobj; |
| 737 | 737 |
| 738 if (FLAG_trace_service) { | 738 if (FLAG_trace_service) { |
| 739 Isolate* isolate = Isolate::Current(); |
| 740 ASSERT(isolate != NULL); |
| 739 OS::Print( | 741 OS::Print( |
| 740 "vm-service: Pushing event of type %s to stream %s\n", kind, stream_id); | 742 "vm-service: Pushing event of type %s to stream %s (%s)\n", |
| 743 kind, stream_id, isolate->name()); |
| 741 } | 744 } |
| 742 | 745 |
| 743 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); | 746 Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); |
| 744 } | 747 } |
| 745 | 748 |
| 746 | 749 |
| 747 class EmbedderServiceHandler { | 750 class EmbedderServiceHandler { |
| 748 public: | 751 public: |
| 749 explicit EmbedderServiceHandler(const char* name) : name_(NULL), | 752 explicit EmbedderServiceHandler(const char* name) : name_(NULL), |
| 750 callback_(NULL), | 753 callback_(NULL), |
| (...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 ServiceMethodDescriptor& method = service_methods_[i]; | 3139 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3137 if (strcmp(method_name, method.name) == 0) { | 3140 if (strcmp(method_name, method.name) == 0) { |
| 3138 return &method; | 3141 return &method; |
| 3139 } | 3142 } |
| 3140 } | 3143 } |
| 3141 return NULL; | 3144 return NULL; |
| 3142 } | 3145 } |
| 3143 | 3146 |
| 3144 | 3147 |
| 3145 } // namespace dart | 3148 } // namespace dart |
| OLD | NEW |