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 RUNTIME_VM_SERVICE_H_ | 5 #ifndef RUNTIME_VM_SERVICE_H_ |
6 #define RUNTIME_VM_SERVICE_H_ | 6 #define RUNTIME_VM_SERVICE_H_ |
7 | 7 |
8 #include "include/dart_tools_api.h" | 8 #include "include/dart_tools_api.h" |
9 | 9 |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
11 #include "vm/object_graph.h" | 11 #include "vm/object_graph.h" |
12 #include "vm/object_id_ring.h" | 12 #include "vm/object_id_ring.h" |
13 #include "vm/os_thread.h" | 13 #include "vm/os_thread.h" |
14 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
17 #define SERVICE_PROTOCOL_MAJOR_VERSION 3 | 17 #define SERVICE_PROTOCOL_MAJOR_VERSION 3 |
18 #define SERVICE_PROTOCOL_MINOR_VERSION 5 | 18 #define SERVICE_PROTOCOL_MINOR_VERSION 5 |
19 | 19 |
20 class Array; | 20 class Array; |
21 class EmbedderServiceHandler; | 21 class EmbedderServiceHandler; |
22 class Error; | 22 class Error; |
23 class GCEvent; | 23 class GCEvent; |
24 class GrowableObjectArray; | 24 class GrowableObjectArray; |
25 class Instance; | 25 class Instance; |
26 class Isolate; | 26 class Isolate; |
27 class JSONStream; | 27 class JSONStream; |
28 class Object; | 28 class Object; |
29 class RawInstance; | 29 class RawInstance; |
| 30 class RawError; |
30 class ServiceEvent; | 31 class ServiceEvent; |
31 class String; | 32 class String; |
32 | 33 |
33 class ServiceIdZone { | 34 class ServiceIdZone { |
34 public: | 35 public: |
35 ServiceIdZone(); | 36 ServiceIdZone(); |
36 virtual ~ServiceIdZone(); | 37 virtual ~ServiceIdZone(); |
37 | 38 |
38 // Returned string will be zone allocated. | 39 // Returned string will be zone allocated. |
39 virtual char* GetServiceId(const Object& obj) = 0; | 40 virtual char* GetServiceId(const Object& obj) = 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 75 |
75 private: | 76 private: |
76 const char* id_; | 77 const char* id_; |
77 bool enabled_; | 78 bool enabled_; |
78 }; | 79 }; |
79 | 80 |
80 | 81 |
81 class Service : public AllStatic { | 82 class Service : public AllStatic { |
82 public: | 83 public: |
83 // Handles a message which is not directed to an isolate. | 84 // Handles a message which is not directed to an isolate. |
84 static void HandleRootMessage(const Array& message); | 85 static RawError* HandleRootMessage(const Array& message); |
85 | 86 |
86 // Handles a message which is not directed to an isolate and also | 87 // Handles a message which is not directed to an isolate and also |
87 // expects the parameter keys and values to be actual dart objects. | 88 // expects the parameter keys and values to be actual dart objects. |
88 static void HandleObjectRootMessage(const Array& message); | 89 static RawError* HandleObjectRootMessage(const Array& message); |
89 | 90 |
90 // Handles a message which is directed to a particular isolate. | 91 // Handles a message which is directed to a particular isolate. |
91 static void HandleIsolateMessage(Isolate* isolate, const Array& message); | 92 static RawError* HandleIsolateMessage(Isolate* isolate, const Array& message); |
92 | 93 |
93 static void HandleEvent(ServiceEvent* event); | 94 static void HandleEvent(ServiceEvent* event); |
94 | 95 |
95 static void RegisterIsolateEmbedderCallback( | 96 static void RegisterIsolateEmbedderCallback( |
96 const char* name, | 97 const char* name, |
97 Dart_ServiceRequestCallback callback, | 98 Dart_ServiceRequestCallback callback, |
98 void* user_data); | 99 void* user_data); |
99 | 100 |
100 static void RegisterRootEmbedderCallback(const char* name, | 101 static void RegisterRootEmbedderCallback(const char* name, |
101 Dart_ServiceRequestCallback callback, | 102 Dart_ServiceRequestCallback callback, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 163 } |
163 static Dart_ServiceStreamCancelCallback stream_cancel_callback() { | 164 static Dart_ServiceStreamCancelCallback stream_cancel_callback() { |
164 return stream_cancel_callback_; | 165 return stream_cancel_callback_; |
165 } | 166 } |
166 | 167 |
167 static void PrintJSONForVM(JSONStream* js, bool ref); | 168 static void PrintJSONForVM(JSONStream* js, bool ref); |
168 | 169 |
169 static void CheckForPause(Isolate* isolate, JSONStream* stream); | 170 static void CheckForPause(Isolate* isolate, JSONStream* stream); |
170 | 171 |
171 private: | 172 private: |
172 static void InvokeMethod(Isolate* isolate, | 173 static RawError* InvokeMethod(Isolate* isolate, |
173 const Array& message, | 174 const Array& message, |
174 bool parameters_are_dart_objects = false); | 175 bool parameters_are_dart_objects = false); |
175 | 176 |
176 static void EmbedderHandleMessage(EmbedderServiceHandler* handler, | 177 static void EmbedderHandleMessage(EmbedderServiceHandler* handler, |
177 JSONStream* js); | 178 JSONStream* js); |
178 | 179 |
179 static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name); | 180 static EmbedderServiceHandler* FindIsolateEmbedderHandler(const char* name); |
180 static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name); | 181 static EmbedderServiceHandler* FindRootEmbedderHandler(const char* name); |
181 static void ScheduleExtensionHandler(const Instance& handler, | 182 static void ScheduleExtensionHandler(const Instance& handler, |
182 const String& method_name, | 183 const String& method_name, |
183 const Array& parameter_keys, | 184 const Array& parameter_keys, |
184 const Array& parameter_values, | 185 const Array& parameter_values, |
(...skipping 11 matching lines...) Expand all Loading... |
196 const char* metadata, | 197 const char* metadata, |
197 intptr_t metadata_size, | 198 intptr_t metadata_size, |
198 const uint8_t* data, | 199 const uint8_t* data, |
199 intptr_t data_size); | 200 intptr_t data_size); |
200 | 201 |
201 static void PostEvent(Isolate* isolate, | 202 static void PostEvent(Isolate* isolate, |
202 const char* stream_id, | 203 const char* stream_id, |
203 const char* kind, | 204 const char* kind, |
204 JSONStream* event); | 205 JSONStream* event); |
205 | 206 |
206 static void MaybePause(Isolate* isolate); | 207 static RawError* MaybePause(Isolate* isolate, const Error& error); |
207 | 208 |
208 static EmbedderServiceHandler* isolate_service_handler_head_; | 209 static EmbedderServiceHandler* isolate_service_handler_head_; |
209 static EmbedderServiceHandler* root_service_handler_head_; | 210 static EmbedderServiceHandler* root_service_handler_head_; |
210 static Dart_ServiceStreamListenCallback stream_listen_callback_; | 211 static Dart_ServiceStreamListenCallback stream_listen_callback_; |
211 static Dart_ServiceStreamCancelCallback stream_cancel_callback_; | 212 static Dart_ServiceStreamCancelCallback stream_cancel_callback_; |
212 static Dart_GetVMServiceAssetsArchive get_service_assets_callback_; | 213 static Dart_GetVMServiceAssetsArchive get_service_assets_callback_; |
213 | 214 |
214 static bool needs_isolate_events_; | 215 static bool needs_isolate_events_; |
215 static bool needs_debug_events_; | 216 static bool needs_debug_events_; |
216 static bool needs_gc_events_; | 217 static bool needs_gc_events_; |
217 static bool needs_echo_events_; | 218 static bool needs_echo_events_; |
218 static bool needs_graph_events_; | 219 static bool needs_graph_events_; |
219 }; | 220 }; |
220 | 221 |
221 } // namespace dart | 222 } // namespace dart |
222 | 223 |
223 #endif // RUNTIME_VM_SERVICE_H_ | 224 #endif // RUNTIME_VM_SERVICE_H_ |
OLD | NEW |