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

Side by Side Diff: runtime/vm/service/vmservice.dart

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/service/service.idl ('k') | runtime/vm/service_isolate.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 library vmservice; 5 library vmservice;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 var members = []; 135 var members = [];
136 var result = {}; 136 var result = {};
137 clients.forEach((client) { 137 clients.forEach((client) {
138 members.add(client.toJson()); 138 members.add(client.toJson());
139 }); 139 });
140 result['type'] = 'ClientList'; 140 result['type'] = 'ClientList';
141 result['members'] = members; 141 result['members'] = members;
142 message.setResponse(JSON.encode(result)); 142 message.setResponse(JSON.encode(result));
143 } 143 }
144 144
145 // TODO(johnmccutchan): Turn this into a command line tool that uses the
146 // service library.
145 Future<String> _getCrashDump() async { 147 Future<String> _getCrashDump() async {
146 final perIsolateRequests = [ 148 final perIsolateRequests = [
147 // ?isolateId=<isolate id> will be appended to each of these requests. 149 // ?isolateId=<isolate id> will be appended to each of these requests.
148 Uri.parse('getIsolate'), // Isolate information. 150 // Isolate information.
149 Uri.parse('_getAllocationProfile'), // State of heap. 151 Uri.parse('getIsolate'),
150 Uri.parse('getStack?full=true'), // Call stack + local variables. 152 // State of heap.
153 Uri.parse('_getAllocationProfile'),
154 // Call stack + local variables.
155 Uri.parse('getStack?_full=true'),
151 ]; 156 ];
152 157
153 // Snapshot of running isolates. 158 // Snapshot of running isolates.
154 var isolates = runningIsolates.isolates.values.toList(); 159 var isolates = runningIsolates.isolates.values.toList();
155 160
156 // Collect the mapping from request uris to responses. 161 // Collect the mapping from request uris to responses.
157 var responses = { 162 var responses = {
158 }; 163 };
159 164
160 // Request VM. 165 // Request VM.
(...skipping 10 matching lines...) Expand all
171 176
172 // Make requests to each isolate. 177 // Make requests to each isolate.
173 for (var isolate in isolates) { 178 for (var isolate in isolates) {
174 for (var request in perIsolateRequests) { 179 for (var request in perIsolateRequests) {
175 var message = new Message.forIsolate(request, isolate); 180 var message = new Message.forIsolate(request, isolate);
176 // Decode the JSON and and insert it into the map. The map key 181 // Decode the JSON and and insert it into the map. The map key
177 // is the request Uri. 182 // is the request Uri.
178 var response = JSON.decode(await isolate.route(message)); 183 var response = JSON.decode(await isolate.route(message));
179 responses[message.toUri().toString()] = response['result']; 184 responses[message.toUri().toString()] = response['result'];
180 } 185 }
186 // Dump the object id ring requests.
187 var message =
188 new Message.forIsolate(Uri.parse('_dumpIdZone'), isolate);
189 var response = JSON.decode(await isolate.route(message));
190 // Insert getObject requests into responses map.
191 for (var object in response['result']['objects']) {
192 final requestUri =
193 'getObject&isolateId=${isolate.serviceId}?objectId=${object["id"]}';
194 responses[requestUri] = object;
195 }
181 } 196 }
182 197
183 // Encode the entire crash dump. 198 // Encode the entire crash dump.
184 return JSON.encode({ 199 return JSON.encode({
185 'id' : null, 200 'id' : null,
186 'result' : responses, 201 'result' : responses,
187 }); 202 });
188 } 203 }
189 204
190 Future<String> route(Message message) { 205 Future<String> route(Message message) {
(...skipping 21 matching lines...) Expand all
212 } 227 }
213 228
214 void _registerIsolate(int port_id, SendPort sp, String name) { 229 void _registerIsolate(int port_id, SendPort sp, String name) {
215 var service = new VMService(); 230 var service = new VMService();
216 service.runningIsolates.isolateStartup(port_id, sp, name); 231 service.runningIsolates.isolateStartup(port_id, sp, name);
217 } 232 }
218 233
219 void _onStart() native "VMService_OnStart"; 234 void _onStart() native "VMService_OnStart";
220 235
221 void _onExit() native "VMService_OnExit"; 236 void _onExit() native "VMService_OnExit";
OLDNEW
« no previous file with comments | « runtime/vm/service/service.idl ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698