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

Side by Side Diff: runtime/observatory/lib/service_common.dart

Issue 1077823003: Some cleanups in the code that posts results to service clients. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/bin/vmservice/server.dart ('k') | runtime/vm/debugger.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 service_common; 5 library service_common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:typed_data'; 9 import 'dart:typed_data';
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 postServiceEvent(meta, data); 179 postServiceEvent(meta, data);
180 }); 180 });
181 } 181 }
182 182
183 void _onStringMessage(String data) { 183 void _onStringMessage(String data) {
184 var map = JSON.decode(data); 184 var map = JSON.decode(data);
185 if (map == null) { 185 if (map == null) {
186 Logger.root.severe('WebSocketVM got empty message'); 186 Logger.root.severe('WebSocketVM got empty message');
187 return; 187 return;
188 } 188 }
189 // Extract serial and response. 189 // Extract serial and result.
190 var serial; 190 var serial;
191 var response; 191 var result;
192 serial = map['id']; 192 serial = map['id'];
193 response = map['response']; 193 result = map['result'];
194 if (serial == null) { 194 if (serial == null) {
195 // Messages without serial numbers are asynchronous events 195 // Messages without serial numbers are asynchronous events
196 // from the vm. 196 // from the vm.
197 postServiceEvent(response, null); 197 postServiceEvent(result, null);
198 return; 198 return;
199 } 199 }
200 // Complete request. 200 // Complete request.
201 var request = _pendingRequests.remove(serial); 201 var request = _pendingRequests.remove(serial);
202 if (request == null) { 202 if (request == null) {
203 Logger.root.severe('Received unexpected message: ${map}'); 203 Logger.root.severe('Received unexpected message: ${map}');
204 return; 204 return;
205 } 205 }
206 if (request.method != 'getTagProfile' && 206 if (request.method != 'getTagProfile' &&
207 request.method != 'getIsolateMetric' && 207 request.method != 'getIsolateMetric' &&
208 request.method != 'getVMMetric') { 208 request.method != 'getVMMetric') {
209 Logger.root.info( 209 Logger.root.info(
210 'RESPONSE [${serial}] ${request.method}'); 210 'RESPONSE [${serial}] ${request.method}');
211 } 211 }
212 request.completer.complete(response); 212 request.completer.complete(result);
213 } 213 }
214 214
215 // WebSocket message event handler. 215 // WebSocket message event handler.
216 void _onMessage(dynamic data) { 216 void _onMessage(dynamic data) {
217 if (data is! String) { 217 if (data is! String) {
218 _onBinaryMessage(data); 218 _onBinaryMessage(data);
219 } else { 219 } else {
220 _onStringMessage(data); 220 _onStringMessage(data);
221 } 221 }
222 } 222 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 if (request.method != 'getTagProfile' && 288 if (request.method != 'getTagProfile' &&
289 request.method != 'getIsolateMetric' && 289 request.method != 'getIsolateMetric' &&
290 request.method != 'getVMMetric') { 290 request.method != 'getVMMetric') {
291 Logger.root.info( 291 Logger.root.info(
292 'GET [${serial}] ${request.method} from ${target.networkAddress}'); 292 'GET [${serial}] ${request.method} from ${target.networkAddress}');
293 } 293 }
294 // Send message. 294 // Send message.
295 _webSocket.send(message); 295 _webSocket.send(message);
296 } 296 }
297 } 297 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698