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

Side by Side Diff: runtime/vm/json_stream.h

Issue 1132323002: Add Service ID zones to service protocol (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/isolate.cc ('k') | runtime/vm/json_stream.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) 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_JSON_STREAM_H_ 5 #ifndef VM_JSON_STREAM_H_
6 #define VM_JSON_STREAM_H_ 6 #define VM_JSON_STREAM_H_
7 7
8 #include "include/dart_api.h" // for Dart_Port 8 #include "include/dart_api.h" // for Dart_Port
9 #include "platform/json.h" 9 #include "platform/json.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
11 #include "vm/service.h"
11 12
12 namespace dart { 13 namespace dart {
13 14
14 class Array; 15 class Array;
15 class Field; 16 class Field;
16 class GrowableObjectArray; 17 class GrowableObjectArray;
17 class Instance; 18 class Instance;
18 class JSONArray; 19 class JSONArray;
19 class JSONObject; 20 class JSONObject;
20 class MessageQueue; 21 class MessageQueue;
(...skipping 12 matching lines...) Expand all
33 void Setup(Zone* zone, 34 void Setup(Zone* zone,
34 Dart_Port reply_port, 35 Dart_Port reply_port,
35 const String& seq, 36 const String& seq,
36 const String& method, 37 const String& method,
37 const Array& param_keys, 38 const Array& param_keys,
38 const Array& param_values); 39 const Array& param_values);
39 void SetupError(); 40 void SetupError();
40 41
41 void PostReply(); 42 void PostReply();
42 43
44 void set_id_zone(ServiceIdZone* id_zone) {
45 id_zone_ = id_zone;
46 }
47 ServiceIdZone* id_zone() {
48 return id_zone_;
49 }
50
43 TextBuffer* buffer() { return &buffer_; } 51 TextBuffer* buffer() { return &buffer_; }
44 const char* ToCString() { return buffer_.buf(); } 52 const char* ToCString() { return buffer_.buf(); }
45 53
46 void set_reply_port(Dart_Port port); 54 void set_reply_port(Dart_Port port);
47 55
48 void SetParams(const char** param_keys, const char** param_values, 56 void SetParams(const char** param_keys, const char** param_values,
49 intptr_t num_params); 57 intptr_t num_params);
50 58
51 Dart_Port reply_port() const { return reply_port_; } 59 Dart_Port reply_port() const { return reply_port_; }
52 60
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void PrintValueNoEscape(const char* s); 97 void PrintValueNoEscape(const char* s);
90 void PrintfValue(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 98 void PrintfValue(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
91 void PrintValue(const Object& o, bool ref = true); 99 void PrintValue(const Object& o, bool ref = true);
92 void PrintValue(SourceBreakpoint* bpt); 100 void PrintValue(SourceBreakpoint* bpt);
93 void PrintValue(const ServiceEvent* event); 101 void PrintValue(const ServiceEvent* event);
94 void PrintValue(Metric* metric); 102 void PrintValue(Metric* metric);
95 void PrintValue(MessageQueue* queue); 103 void PrintValue(MessageQueue* queue);
96 void PrintValue(Isolate* isolate, bool ref = true); 104 void PrintValue(Isolate* isolate, bool ref = true);
97 bool PrintValueStr(const String& s, intptr_t limit); 105 bool PrintValueStr(const String& s, intptr_t limit);
98 106
107 void PrintServiceId(const char* name, const Object& o);
99 void PrintPropertyBool(const char* name, bool b); 108 void PrintPropertyBool(const char* name, bool b);
100 void PrintProperty(const char* name, intptr_t i); 109 void PrintProperty(const char* name, intptr_t i);
101 void PrintProperty64(const char* name, int64_t i); 110 void PrintProperty64(const char* name, int64_t i);
102 void PrintProperty(const char* name, double d); 111 void PrintProperty(const char* name, double d);
103 void PrintProperty(const char* name, const char* s); 112 void PrintProperty(const char* name, const char* s);
104 bool PrintPropertyStr(const char* name, const String& s, intptr_t limit); 113 bool PrintPropertyStr(const char* name, const String& s, intptr_t limit);
105 void PrintPropertyNoEscape(const char* name, const char* s); 114 void PrintPropertyNoEscape(const char* name, const char* s);
106 void PrintfProperty(const char* name, const char* format, ...) 115 void PrintfProperty(const char* name, const char* format, ...)
107 PRINTF_ATTRIBUTE(3, 4); 116 PRINTF_ATTRIBUTE(3, 4);
108 void PrintProperty(const char* name, const Object& o, bool ref = true); 117 void PrintProperty(const char* name, const Object& o, bool ref = true);
109 118
110 void PrintProperty(const char* name, const ServiceEvent* event); 119 void PrintProperty(const char* name, const ServiceEvent* event);
111 void PrintProperty(const char* name, SourceBreakpoint* bpt); 120 void PrintProperty(const char* name, SourceBreakpoint* bpt);
112 void PrintProperty(const char* name, Metric* metric); 121 void PrintProperty(const char* name, Metric* metric);
113 void PrintProperty(const char* name, MessageQueue* queue); 122 void PrintProperty(const char* name, MessageQueue* queue);
114 void PrintProperty(const char* name, Isolate* isolate); 123 void PrintProperty(const char* name, Isolate* isolate);
115 void PrintPropertyName(const char* name); 124 void PrintPropertyName(const char* name);
116 void PrintCommaIfNeeded(); 125 void PrintCommaIfNeeded();
117 bool NeedComma(); 126 bool NeedComma();
118 127
119 bool AddDartString(const String& s, intptr_t limit); 128 bool AddDartString(const String& s, intptr_t limit);
120 void AddEscapedUTF8String(const char* s); 129 void AddEscapedUTF8String(const char* s);
121 void AddEscapedUTF8String(const char* s, intptr_t len); 130 void AddEscapedUTF8String(const char* s, intptr_t len);
122 131
123 intptr_t nesting_level() const { return open_objects_; } 132 intptr_t nesting_level() const { return open_objects_; }
124 133
125 intptr_t open_objects_; 134 intptr_t open_objects_;
126 TextBuffer buffer_; 135 TextBuffer buffer_;
136 // Default service id zone.
137 RingServiceIdZone default_id_zone_;
138 ServiceIdZone* id_zone_;
127 Dart_Port reply_port_; 139 Dart_Port reply_port_;
128 const char* seq_; 140 const char* seq_;
129 const char* method_; 141 const char* method_;
130 const char** param_keys_; 142 const char** param_keys_;
131 const char** param_values_; 143 const char** param_values_;
132 intptr_t num_params_; 144 intptr_t num_params_;
133 int64_t setup_time_micros_; 145 int64_t setup_time_micros_;
134 146
135 friend class JSONObject; 147 friend class JSONObject;
136 friend class JSONArray; 148 friend class JSONArray;
137 }; 149 };
138 150
139 151
140 class JSONObject : public ValueObject { 152 class JSONObject : public ValueObject {
141 public: 153 public:
142 explicit JSONObject(JSONStream* stream) : stream_(stream) { 154 explicit JSONObject(JSONStream* stream) : stream_(stream) {
143 stream_->OpenObject(); 155 stream_->OpenObject();
144 } 156 }
145 JSONObject(const JSONObject* obj, const char* name) : stream_(obj->stream_) { 157 JSONObject(const JSONObject* obj, const char* name) : stream_(obj->stream_) {
146 stream_->OpenObject(name); 158 stream_->OpenObject(name);
147 } 159 }
148 explicit JSONObject(const JSONArray* arr); 160 explicit JSONObject(const JSONArray* arr);
149 161
150 ~JSONObject() { 162 ~JSONObject() {
151 stream_->CloseObject(); 163 stream_->CloseObject();
152 } 164 }
153 165
166 void AddServiceId(const char* name, const Object& o) const {
167 stream_->PrintServiceId(name, o);
168 }
169
154 void AddProperty(const char* name, bool b) const { 170 void AddProperty(const char* name, bool b) const {
155 stream_->PrintPropertyBool(name, b); 171 stream_->PrintPropertyBool(name, b);
156 } 172 }
157 void AddProperty(const char* name, intptr_t i) const { 173 void AddProperty(const char* name, intptr_t i) const {
158 stream_->PrintProperty(name, i); 174 stream_->PrintProperty(name, i);
159 } 175 }
160 void AddProperty64(const char* name, int64_t i) const { 176 void AddProperty64(const char* name, int64_t i) const {
161 stream_->PrintProperty64(name, i); 177 stream_->PrintProperty64(name, i);
162 } 178 }
163 void AddProperty(const char* name, double d) const { 179 void AddProperty(const char* name, double d) const {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 266
251 friend class JSONObject; 267 friend class JSONObject;
252 268
253 DISALLOW_ALLOCATION(); 269 DISALLOW_ALLOCATION();
254 DISALLOW_COPY_AND_ASSIGN(JSONArray); 270 DISALLOW_COPY_AND_ASSIGN(JSONArray);
255 }; 271 };
256 272
257 } // namespace dart 273 } // namespace dart
258 274
259 #endif // VM_JSON_STREAM_H_ 275 #endif // VM_JSON_STREAM_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/json_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698