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

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

Issue 1093043004: Do not JSON encode the 'result' of a service rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/service_event.h ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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_event.h" 5 #include "vm/service_event.h"
6 6
7 namespace dart { 7 namespace dart {
8 8
9 // Translate from the legacy DebugEvent to a ServiceEvent. 9 // Translate from the legacy DebugEvent to a ServiceEvent.
10 static ServiceEvent::EventType TranslateEventType( 10 static ServiceEvent::EventType TranslateEventType(
(...skipping 18 matching lines...) Expand all
29 UNREACHABLE(); 29 UNREACHABLE();
30 return ServiceEvent::kIllegal; 30 return ServiceEvent::kIllegal;
31 } 31 }
32 } 32 }
33 33
34 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) 34 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event)
35 : isolate_(debugger_event->isolate()), 35 : isolate_(debugger_event->isolate()),
36 type_(TranslateEventType(debugger_event->type())), 36 type_(TranslateEventType(debugger_event->type())),
37 breakpoint_(NULL), 37 breakpoint_(NULL),
38 top_frame_(NULL), 38 top_frame_(NULL),
39 exception_(NULL) { 39 exception_(NULL),
40 gc_stats_(NULL) {
40 DebuggerEvent::EventType type = debugger_event->type(); 41 DebuggerEvent::EventType type = debugger_event->type();
41 if (type == DebuggerEvent::kBreakpointReached) { 42 if (type == DebuggerEvent::kBreakpointReached) {
42 set_breakpoint(debugger_event->breakpoint()); 43 set_breakpoint(debugger_event->breakpoint());
43 } 44 }
44 if (type == DebuggerEvent::kExceptionThrown) { 45 if (type == DebuggerEvent::kExceptionThrown) {
45 set_exception(debugger_event->exception()); 46 set_exception(debugger_event->exception());
46 } 47 }
47 if (type == DebuggerEvent::kBreakpointReached || 48 if (type == DebuggerEvent::kBreakpointReached ||
48 type == DebuggerEvent::kIsolateInterrupted || 49 type == DebuggerEvent::kIsolateInterrupted ||
49 type == DebuggerEvent::kExceptionThrown) { 50 type == DebuggerEvent::kExceptionThrown) {
(...skipping 21 matching lines...) Expand all
71 case kPauseException: 72 case kPauseException:
72 return "PauseException"; 73 return "PauseException";
73 case kResume: 74 case kResume:
74 return "Resume"; 75 return "Resume";
75 case kBreakpointAdded: 76 case kBreakpointAdded:
76 return "BreakpointAdded"; 77 return "BreakpointAdded";
77 case kBreakpointResolved: 78 case kBreakpointResolved:
78 return "BreakpointResolved"; 79 return "BreakpointResolved";
79 case kBreakpointRemoved: 80 case kBreakpointRemoved:
80 return "BreakpointRemoved"; 81 return "BreakpointRemoved";
82 case kGC:
83 return "GC"; // TODO(koda): Change to GarbageCollected.
81 default: 84 default:
82 UNREACHABLE(); 85 UNREACHABLE();
83 return "Unknown"; 86 return "Unknown";
84 } 87 }
85 } 88 }
86 89
87 90
88 void ServiceEvent::PrintJSON(JSONStream* js) const { 91 void ServiceEvent::PrintJSON(JSONStream* js) const {
89 JSONObject jsobj(js); 92 JSONObject jsobj(js);
90 jsobj.AddProperty("type", "ServiceEvent"); 93 jsobj.AddProperty("type", "ServiceEvent");
91 jsobj.AddProperty("eventType", EventTypeToCString(type())); 94 jsobj.AddProperty("eventType", EventTypeToCString(type()));
92 jsobj.AddProperty("isolate", isolate()); 95 jsobj.AddProperty("isolate", isolate());
93 if (breakpoint() != NULL) { 96 if (breakpoint() != NULL) {
94 jsobj.AddProperty("breakpoint", breakpoint()); 97 jsobj.AddProperty("breakpoint", breakpoint());
95 } 98 }
96 if (top_frame() != NULL) { 99 if (top_frame() != NULL) {
97 JSONObject jsFrame(&jsobj, "topFrame"); 100 JSONObject jsFrame(&jsobj, "topFrame");
98 top_frame()->PrintToJSONObject(&jsFrame); 101 top_frame()->PrintToJSONObject(&jsFrame);
99 } 102 }
100 if (exception() != NULL) { 103 if (exception() != NULL) {
101 jsobj.AddProperty("exception", *(exception())); 104 jsobj.AddProperty("exception", *(exception()));
102 } 105 }
106 if (gc_stats() != NULL) {
107 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_));
108 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj);
109 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj);
110 }
103 } 111 }
104 112
105 } // namespace dart 113 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_event.h ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698