Chromium Code Reviews| 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 #include "vm/os_thread.h" | 11 #include "vm/os_thread.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class Array; | 15 class Array; |
| 16 class DebuggerEvent; | 16 class DebuggerEvent; |
| 17 class EmbedderServiceHandler; | 17 class EmbedderServiceHandler; |
| 18 class GCEvent; | 18 class GCEvent; |
| 19 class Instance; | 19 class Instance; |
| 20 class Isolate; | 20 class Isolate; |
| 21 class JSONStream; | 21 class JSONStream; |
| 22 class Object; | 22 class Object; |
| 23 class RawInstance; | 23 class RawInstance; |
| 24 class String; | 24 class String; |
| 25 | 25 |
| 26 class Service : public AllStatic { | 26 class Service : public AllStatic { |
| 27 public: | 27 public: |
| 28 static const char* kIsolateName; | 28 static void InvokeMethod(Isolate* isolate, const Array& message); |
| 29 static bool IsServiceIsolateName(const char* name); | |
| 30 | 29 |
| 31 // Handles a message which is not directed to an isolate. | 30 // Handles a message which is not directed to an isolate. |
| 32 static void HandleRootMessage(const Instance& message); | 31 static void HandleRootMessage(const Array& message); |
|
turnidge
2015/02/12 18:08:57
We should either get rid of HandleRootMessage/Hand
Cutch
2015/02/12 18:18:47
I've made InvokeMethod private for now.
| |
| 33 | 32 |
| 34 // Handles a message which is directed to a particular isolate. | 33 // Handles a message which is directed to a particular isolate. |
| 35 static void HandleIsolateMessage(Isolate* isolate, const Array& message); | 34 static void HandleIsolateMessage(Isolate* isolate, const Array& message); |
| 36 | 35 |
| 37 static Isolate* GetServiceIsolate(void* callback_data); | 36 static bool EventMaskHas(uint32_t mask); |
| 38 static bool SendIsolateStartupMessage(); | |
| 39 static bool SendIsolateShutdownMessage(); | |
| 40 | |
| 41 static bool IsRunning(); | |
| 42 static void SetServicePort(Dart_Port port); | |
| 43 static void SetServiceIsolate(Isolate* isolate); | |
| 44 static bool HasServiceIsolate(); | |
| 45 static bool IsServiceIsolate(Isolate* isolate); | |
| 46 | |
| 47 static Dart_Port WaitForLoadPort(); | |
| 48 static Dart_Port LoadPort(); | |
| 49 static void SetLoadPort(Dart_Port port); | |
| 50 | |
| 51 static void SetEventMask(uint32_t mask); | 37 static void SetEventMask(uint32_t mask); |
| 52 | 38 static bool NeedsDebuggerEvents(); |
| 53 // Is the service interested in debugger events? | 39 static bool NeedsGCEvents(); |
| 54 static bool NeedsDebuggerEvents() { | |
| 55 return IsRunning() && ((event_mask_ & kEventFamilyDebugMask) != 0); | |
| 56 } | |
| 57 // Is the service interested in garbage collection events? | |
| 58 static bool NeedsGCEvents() { | |
| 59 return IsRunning() && ((event_mask_ & kEventFamilyGCMask) != 0); | |
| 60 } | |
| 61 | 40 |
| 62 static void HandleDebuggerEvent(DebuggerEvent* event); | 41 static void HandleDebuggerEvent(DebuggerEvent* event); |
| 63 static void HandleGCEvent(GCEvent* event); | 42 static void HandleGCEvent(GCEvent* event); |
| 64 | 43 |
| 65 static void RegisterIsolateEmbedderCallback( | 44 static void RegisterIsolateEmbedderCallback( |
| 66 const char* name, | 45 const char* name, |
| 67 Dart_ServiceRequestCallback callback, | 46 Dart_ServiceRequestCallback callback, |
| 68 void* user_data); | 47 void* user_data); |
| 69 | 48 |
| 70 static void RegisterRootEmbedderCallback( | 49 static void RegisterRootEmbedderCallback( |
| 71 const char* name, | 50 const char* name, |
| 72 Dart_ServiceRequestCallback callback, | 51 Dart_ServiceRequestCallback callback, |
| 73 void* user_data); | 52 void* user_data); |
| 74 | 53 |
| 75 static void SendEchoEvent(Isolate* isolate, const char* text); | 54 static void SendEchoEvent(Isolate* isolate, const char* text); |
| 76 static void SendGraphEvent(Isolate* isolate); | 55 static void SendGraphEvent(Isolate* isolate); |
| 77 | 56 |
| 78 static void MaybeInjectVMServiceLibrary(Isolate* isolate); | |
| 79 | |
| 80 static void RunService(); | |
| 81 | |
| 82 static void FinishedInitializing(); | |
| 83 | |
| 84 static Dart_IsolateCreateCallback create_callback() { | |
| 85 return create_callback_; | |
| 86 } | |
| 87 | |
| 88 private: | 57 private: |
| 89 // These must be kept in sync with service/constants.dart | 58 // These must be kept in sync with service/constants.dart |
| 90 static const int kEventFamilyDebug = 0; | 59 static const int kEventFamilyDebug = 0; |
| 91 static const int kEventFamilyGC = 1; | 60 static const int kEventFamilyGC = 1; |
| 92 static const uint32_t kEventFamilyDebugMask = (1 << kEventFamilyDebug); | 61 static const uint32_t kEventFamilyDebugMask = (1 << kEventFamilyDebug); |
| 93 static const uint32_t kEventFamilyGCMask = (1 << kEventFamilyGC); | 62 static const uint32_t kEventFamilyGCMask = (1 << kEventFamilyGC); |
| 94 | 63 |
| 95 static void EmbedderHandleMessage(EmbedderServiceHandler* handler, | 64 static void EmbedderHandleMessage(EmbedderServiceHandler* handler, |
| 96 JSONStream* js); | 65 JSONStream* js); |
| 97 | 66 |
| 98 static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name); | 67 static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name); |
| 99 static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name); | 68 static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name); |
| 100 static Dart_Handle GetSource(const char* name); | |
| 101 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, | |
| 102 Dart_Handle url); | |
| 103 | 69 |
| 104 static void SendEvent(intptr_t eventId, const Object& eventMessage); | 70 static void SendEvent(intptr_t eventId, const Object& eventMessage); |
| 105 // Does not take ownership of 'data'. | 71 // Does not take ownership of 'data'. |
| 106 static void SendEvent(intptr_t eventId, | 72 static void SendEvent(intptr_t eventId, |
| 107 const String& meta, | 73 const String& meta, |
| 108 const uint8_t* data, | 74 const uint8_t* data, |
| 109 intptr_t size); | 75 intptr_t size); |
| 110 | 76 |
| 111 static EmbedderServiceHandler* isolate_service_handler_head_; | 77 static EmbedderServiceHandler* isolate_service_handler_head_; |
| 112 static EmbedderServiceHandler* root_service_handler_head_; | 78 static EmbedderServiceHandler* root_service_handler_head_; |
| 113 | 79 |
| 114 | |
| 115 static Dart_IsolateCreateCallback create_callback_; | |
| 116 static Monitor* monitor_; | |
| 117 static bool initializing_; | |
| 118 static Isolate* service_isolate_; | |
| 119 static Dart_Port service_port_; | |
| 120 static Dart_Port load_port_; | |
| 121 static uint32_t event_mask_; | 80 static uint32_t event_mask_; |
| 122 }; | 81 }; |
| 123 | 82 |
| 124 } // namespace dart | 83 } // namespace dart |
| 125 | 84 |
| 126 #endif // VM_SERVICE_H_ | 85 #endif // VM_SERVICE_H_ |
| OLD | NEW |