| 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 #ifndef VM_SERVICE_H_ | 5 #ifndef VM_SERVICE_H_ |
| 6 #define VM_SERVICE_H_ | 6 #define VM_SERVICE_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class DebuggerEvent; | 14 class DebuggerEvent; |
| 15 class GCEvent; |
| 15 class EmbedderServiceHandler; | 16 class EmbedderServiceHandler; |
| 16 class Instance; | 17 class Instance; |
| 17 class Isolate; | 18 class Isolate; |
| 18 class JSONStream; | 19 class JSONStream; |
| 19 class Array; | 20 class Array; |
| 20 class RawInstance; | 21 class RawInstance; |
| 21 class String; | 22 class String; |
| 22 | 23 |
| 23 class Service : public AllStatic { | 24 class Service : public AllStatic { |
| 24 public: | 25 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 static bool IsRunning() { | 36 static bool IsRunning() { |
| 36 return port_ != ILLEGAL_PORT; | 37 return port_ != ILLEGAL_PORT; |
| 37 } | 38 } |
| 38 | 39 |
| 39 static void SetEventMask(uint32_t mask); | 40 static void SetEventMask(uint32_t mask); |
| 40 | 41 |
| 41 // Is the service interested in debugger events? | 42 // Is the service interested in debugger events? |
| 42 static bool NeedsDebuggerEvents() { | 43 static bool NeedsDebuggerEvents() { |
| 43 return IsRunning() && ((event_mask_ & kEventFamilyDebugMask) != 0); | 44 return IsRunning() && ((event_mask_ & kEventFamilyDebugMask) != 0); |
| 44 } | 45 } |
| 46 // Is the service interested in garbage collection events? |
| 47 static bool NeedsGCEvents() { |
| 48 return IsRunning() && ((event_mask_ & kEventFamilyGCMask) != 0); |
| 49 } |
| 45 | 50 |
| 46 static void HandleDebuggerEvent(DebuggerEvent* event); | 51 static void HandleDebuggerEvent(DebuggerEvent* event); |
| 52 static void HandleGCEvent(GCEvent* event); |
| 47 | 53 |
| 48 static void RegisterIsolateEmbedderCallback( | 54 static void RegisterIsolateEmbedderCallback( |
| 49 const char* name, | 55 const char* name, |
| 50 Dart_ServiceRequestCallback callback, | 56 Dart_ServiceRequestCallback callback, |
| 51 void* user_data); | 57 void* user_data); |
| 52 | 58 |
| 53 static void RegisterRootEmbedderCallback( | 59 static void RegisterRootEmbedderCallback( |
| 54 const char* name, | 60 const char* name, |
| 55 Dart_ServiceRequestCallback callback, | 61 Dart_ServiceRequestCallback callback, |
| 56 void* user_data); | 62 void* user_data); |
| 57 | 63 |
| 58 static bool IsServiceIsolate(Isolate* isolate) { | 64 static bool IsServiceIsolate(Isolate* isolate) { |
| 59 return isolate == service_isolate_; | 65 return isolate == service_isolate_; |
| 60 } | 66 } |
| 61 | 67 |
| 62 private: | 68 private: |
| 63 // These must be kept in sync with service/constants.dart | 69 // These must be kept in sync with service/constants.dart |
| 64 static const int kEventFamilyDebug = 0; | 70 static const int kEventFamilyDebug = 0; |
| 71 static const int kEventFamilyGC = 1; |
| 65 static const uint32_t kEventFamilyDebugMask = (1 << kEventFamilyDebug); | 72 static const uint32_t kEventFamilyDebugMask = (1 << kEventFamilyDebug); |
| 73 static const uint32_t kEventFamilyGCMask = (1 << kEventFamilyGC); |
| 66 | 74 |
| 67 static void EmbedderHandleMessage(EmbedderServiceHandler* handler, | 75 static void EmbedderHandleMessage(EmbedderServiceHandler* handler, |
| 68 JSONStream* js); | 76 JSONStream* js); |
| 69 static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name); | 77 static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name); |
| 70 static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name); | 78 static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name); |
| 71 static Dart_Handle GetSource(const char* name); | 79 static Dart_Handle GetSource(const char* name); |
| 72 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, | 80 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, |
| 73 Dart_Handle url); | 81 Dart_Handle url); |
| 74 static void SendEvent(intptr_t eventId, const String& eventMessage); | 82 static void SendEvent(intptr_t eventId, const String& eventMessage); |
| 75 | 83 |
| 76 static EmbedderServiceHandler* isolate_service_handler_head_; | 84 static EmbedderServiceHandler* isolate_service_handler_head_; |
| 77 static EmbedderServiceHandler* root_service_handler_head_; | 85 static EmbedderServiceHandler* root_service_handler_head_; |
| 78 | 86 |
| 79 static Isolate* service_isolate_; | 87 static Isolate* service_isolate_; |
| 80 static Dart_LibraryTagHandler embedder_provided_handler_; | 88 static Dart_LibraryTagHandler embedder_provided_handler_; |
| 81 static Dart_Port port_; | 89 static Dart_Port port_; |
| 82 static uint32_t event_mask_; | 90 static uint32_t event_mask_; |
| 83 }; | 91 }; |
| 84 | 92 |
| 85 } // namespace dart | 93 } // namespace dart |
| 86 | 94 |
| 87 #endif // VM_SERVICE_H_ | 95 #endif // VM_SERVICE_H_ |
| OLD | NEW |