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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart

Issue 182413007: Add new <curly-block> element. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js / fix bugs with reload Created 6 years, 9 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
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 part of observatory; 5 part of observatory;
6 6
7 /// A request response interceptor is called for each response. 7 /// A request response interceptor is called for each response.
8 typedef void RequestResponseInterceptor(); 8 typedef void RequestResponseInterceptor();
9 9
10 abstract class RequestManager extends Observable { 10 abstract class RequestManager extends Observable {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 request(requestString).then((responseString) { 226 request(requestString).then((responseString) {
227 parseResponses(responseString); 227 parseResponses(responseString);
228 }).catchError(_requestCatchError); 228 }).catchError(_requestCatchError);
229 } 229 }
230 230
231 /// Abstract method. Given the [requestString], return a String in the 231 /// Abstract method. Given the [requestString], return a String in the
232 /// future which contains the reply from the VM service. 232 /// future which contains the reply from the VM service.
233 Future<String> request(String requestString); 233 Future<String> request(String requestString);
234 234
235 Future<Map> requestMap(String requestString) { 235 Future<ObservableMap> requestMap(String requestString) {
236 if (requestString.startsWith('#')) { 236 if (requestString.startsWith('#')) {
237 requestString = requestString.substring(1); 237 requestString = requestString.substring(1);
238 } 238 }
239 return request(requestString).then((response) { 239 return request(requestString).then((response) {
240 try { 240 try {
241 var m = JSON.decode(response); 241 var m = JSON.decode(response);
242 return m; 242 return toObservable(m);
243 } catch (e) { } 243 } catch (e) { }
244 return null; 244 return null;
245 }); 245 });
246 } 246 }
247 } 247 }
248 248
249 249
250 class HttpRequestManager extends RequestManager { 250 class HttpRequestManager extends RequestManager {
251 Future<String> request(String requestString) { 251 Future<String> request(String requestString) {
252 Logger.root.info('Requesting $requestString'); 252 Logger.root.info('Requesting $requestString');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 message['query'] = requestString; 286 message['query'] = requestString;
287 _requestSerial++; 287 _requestSerial++;
288 288
289 var completer = new Completer(); 289 var completer = new Completer();
290 _outstandingRequests[idString] = completer; 290 _outstandingRequests[idString] = completer;
291 291
292 window.parent.postMessage(JSON.encode(message), '*'); 292 window.parent.postMessage(JSON.encode(message), '*');
293 return completer.future; 293 return completer.future;
294 } 294 }
295 } 295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698