Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: runtime/vm/service.cc

Issue 2962593002: Added Editor stream and sendObjectToEditor RPC into Service Protocol (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // These are the set of streams known to the core VM. 122 // These are the set of streams known to the core VM.
123 StreamInfo Service::vm_stream("VM"); 123 StreamInfo Service::vm_stream("VM");
124 StreamInfo Service::isolate_stream("Isolate"); 124 StreamInfo Service::isolate_stream("Isolate");
125 StreamInfo Service::debug_stream("Debug"); 125 StreamInfo Service::debug_stream("Debug");
126 StreamInfo Service::gc_stream("GC"); 126 StreamInfo Service::gc_stream("GC");
127 StreamInfo Service::echo_stream("_Echo"); 127 StreamInfo Service::echo_stream("_Echo");
128 StreamInfo Service::graph_stream("_Graph"); 128 StreamInfo Service::graph_stream("_Graph");
129 StreamInfo Service::logging_stream("_Logging"); 129 StreamInfo Service::logging_stream("_Logging");
130 StreamInfo Service::extension_stream("Extension"); 130 StreamInfo Service::extension_stream("Extension");
131 StreamInfo Service::timeline_stream("Timeline"); 131 StreamInfo Service::timeline_stream("Timeline");
132 StreamInfo Service::editor_stream("_Editor");
132 133
133 static StreamInfo* streams_[] = { 134 static StreamInfo* streams_[] = {
134 &Service::vm_stream, &Service::isolate_stream, 135 &Service::vm_stream, &Service::isolate_stream,
135 &Service::debug_stream, &Service::gc_stream, 136 &Service::debug_stream, &Service::gc_stream,
136 &Service::echo_stream, &Service::graph_stream, 137 &Service::echo_stream, &Service::graph_stream,
137 &Service::logging_stream, &Service::extension_stream, 138 &Service::logging_stream, &Service::extension_stream,
138 &Service::timeline_stream, 139 &Service::timeline_stream, &Service::editor_stream};
139 };
140 140
141 141
142 bool Service::ListenStream(const char* stream_id) { 142 bool Service::ListenStream(const char* stream_id) {
143 if (FLAG_trace_service) { 143 if (FLAG_trace_service) {
144 OS::Print("vm-service: starting stream '%s'\n", stream_id); 144 OS::Print("vm-service: starting stream '%s'\n", stream_id);
145 } 145 }
146 intptr_t num_streams = sizeof(streams_) / sizeof(streams_[0]); 146 intptr_t num_streams = sizeof(streams_) / sizeof(streams_[0]);
147 for (intptr_t i = 0; i < num_streams; i++) { 147 for (intptr_t i = 0; i < num_streams; i++) {
148 if (strcmp(stream_id, streams_[i]->id()) == 0) { 148 if (strcmp(stream_id, streams_[i]->id()) == 0) {
149 streams_[i]->set_enabled(true); 149 streams_[i]->set_enabled(true);
(...skipping 4046 matching lines...) Expand 10 before | Expand all | Expand 10 after
4196 PrintInvalidParamError(js, "classId"); 4196 PrintInvalidParamError(js, "classId");
4197 return true; 4197 return true;
4198 } 4198 }
4199 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); 4199 const Class& cls = Class::Handle(GetClassForId(isolate, cid));
4200 ASSERT(!cls.IsNull()); 4200 ASSERT(!cls.IsNull());
4201 cls.SetTraceAllocation(enable); 4201 cls.SetTraceAllocation(enable);
4202 PrintSuccess(js); 4202 PrintSuccess(js);
4203 return true; 4203 return true;
4204 } 4204 }
4205 4205
4206 static const MethodParameter* send_object_to_editor_params[] = {
4207 RUNNABLE_ISOLATE_PARAMETER, new StringParameter("editor", true),
4208 new StringParameter("objectId", true), NULL,
4209 };
4210
4211 static bool SendObjectToEditor(Thread* thread, JSONStream* js) {
4212 // Handle heap objects.
4213 ObjectIdRing::LookupResult lookup_result;
4214 const Object& obj = Object::Handle(
4215 LookupHeapObject(thread, js->LookupParam("objectId"), &lookup_result));
rmacnak 2017/06/27 16:47:56 It looks like the only thing we do with the object
cbernaschina 2017/06/27 17:03:25 In the event it is sent as an ObjectRef. Looking i
rmacnak 2017/06/28 16:32:42 Add a comment here explaining we're effectively re
cbernaschina 2017/06/29 17:29:38 Done.
4216 if (obj.raw() != Object::sentinel().raw()) {
4217 // We found a heap object for this id. Return it.
4218 if (Service::editor_stream.enabled()) {
4219 ServiceEvent event(thread->isolate(),
4220 ServiceEvent::kEditorObjectSelected);
4221 ServiceEvent::EditorEvent editor_event;
4222 editor_event.object = &obj;
4223 editor_event.editor = js->LookupParam("editor");
4224 event.set_editor_event(editor_event);
4225 Service::HandleEvent(&event);
4226 }
4227 PrintSuccess(js);
4228 return true;
4229 } else if (lookup_result == ObjectIdRing::kCollected) {
4230 PrintSentinel(js, kCollectedSentinel);
4231 return true;
4232 } else if (lookup_result == ObjectIdRing::kExpired) {
4233 PrintSentinel(js, kExpiredSentinel);
4234 return true;
4235 }
4236 PrintInvalidParamError(js, "objectId");
4237
4238 return true;
4239 }
4240
4206 4241
4207 // clang-format off 4242 // clang-format off
4208 static const ServiceMethodDescriptor service_methods_[] = { 4243 static const ServiceMethodDescriptor service_methods_[] = {
4209 { "_dumpIdZone", DumpIdZone, NULL }, 4244 { "_dumpIdZone", DumpIdZone, NULL },
4210 { "_echo", Echo, 4245 { "_echo", Echo,
4211 NULL }, 4246 NULL },
4212 { "_respondWithMalformedJson", RespondWithMalformedJson, 4247 { "_respondWithMalformedJson", RespondWithMalformedJson,
4213 NULL }, 4248 NULL },
4214 { "_respondWithMalformedObject", RespondWithMalformedObject, 4249 { "_respondWithMalformedObject", RespondWithMalformedObject,
4215 NULL }, 4250 NULL },
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4314 { "setName", SetName, 4349 { "setName", SetName,
4315 set_name_params }, 4350 set_name_params },
4316 { "_setTraceClassAllocation", SetTraceClassAllocation, 4351 { "_setTraceClassAllocation", SetTraceClassAllocation,
4317 set_trace_class_allocation_params }, 4352 set_trace_class_allocation_params },
4318 { "setVMName", SetVMName, 4353 { "setVMName", SetVMName,
4319 set_vm_name_params }, 4354 set_vm_name_params },
4320 { "_setVMTimelineFlags", SetVMTimelineFlags, 4355 { "_setVMTimelineFlags", SetVMTimelineFlags,
4321 set_vm_timeline_flags_params }, 4356 set_vm_timeline_flags_params },
4322 { "_collectAllGarbage", CollectAllGarbage, 4357 { "_collectAllGarbage", CollectAllGarbage,
4323 collect_all_garbage_params }, 4358 collect_all_garbage_params },
4359 { "_sendObjectToEditor", SendObjectToEditor,
4360 send_object_to_editor_params },
4324 }; 4361 };
4325 // clang-format on 4362 // clang-format on
4326 4363
4327 const ServiceMethodDescriptor* FindMethod(const char* method_name) { 4364 const ServiceMethodDescriptor* FindMethod(const char* method_name) {
4328 intptr_t num_methods = sizeof(service_methods_) / sizeof(service_methods_[0]); 4365 intptr_t num_methods = sizeof(service_methods_) / sizeof(service_methods_[0]);
4329 for (intptr_t i = 0; i < num_methods; i++) { 4366 for (intptr_t i = 0; i < num_methods; i++) {
4330 const ServiceMethodDescriptor& method = service_methods_[i]; 4367 const ServiceMethodDescriptor& method = service_methods_[i];
4331 if (strcmp(method_name, method.name) == 0) { 4368 if (strcmp(method_name, method.name) == 0) {
4332 return &method; 4369 return &method;
4333 } 4370 }
4334 } 4371 }
4335 return NULL; 4372 return NULL;
4336 } 4373 }
4337 4374
4338 #endif // !PRODUCT 4375 #endif // !PRODUCT
4339 4376
4340 } // namespace dart 4377 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698