| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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<Map> requestMap(String requestString) { |
| 236 if (requestString.startsWith('#')) { |
| 237 requestString = requestString.substring(1); |
| 238 } |
| 236 return request(requestString).then((response) { | 239 return request(requestString).then((response) { |
| 237 try { | 240 try { |
| 238 var m = JSON.decode(response); | 241 var m = JSON.decode(response); |
| 239 return m; | 242 return m; |
| 240 } catch (e) { } | 243 } catch (e) { } |
| 241 return null; | 244 return null; |
| 242 }); | 245 }); |
| 243 } | 246 } |
| 244 } | 247 } |
| 245 | 248 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 message['query'] = requestString; | 286 message['query'] = requestString; |
| 284 _requestSerial++; | 287 _requestSerial++; |
| 285 | 288 |
| 286 var completer = new Completer(); | 289 var completer = new Completer(); |
| 287 _outstandingRequests[idString] = completer; | 290 _outstandingRequests[idString] = completer; |
| 288 | 291 |
| 289 window.parent.postMessage(JSON.encode(message), '*'); | 292 window.parent.postMessage(JSON.encode(message), '*'); |
| 290 return completer.future; | 293 return completer.future; |
| 291 } | 294 } |
| 292 } | 295 } |
| OLD | NEW |