| OLD | NEW |
| 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_html; | 5 library service_html; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 assert(completer != null); | 155 assert(completer != null); |
| 156 _pendingRequests.remove(id); | 156 _pendingRequests.remove(id); |
| 157 completer.complete(data); | 157 completer.complete(data); |
| 158 } | 158 } |
| 159 | 159 |
| 160 Future<String> getString(String path) { | 160 Future<String> getString(String path) { |
| 161 var idString = '$_requestSerial'; | 161 var idString = '$_requestSerial'; |
| 162 Map message = {}; | 162 Map message = {}; |
| 163 message['id'] = idString; | 163 message['id'] = idString; |
| 164 message['method'] = 'observatoryQuery'; | 164 message['method'] = 'observatoryQuery'; |
| 165 message['query'] = '/$path'; | 165 message['query'] = '$path'; |
| 166 _requestSerial++; | 166 _requestSerial++; |
| 167 var completer = new Completer(); | 167 var completer = new Completer(); |
| 168 _pendingRequests[idString] = completer; | 168 _pendingRequests[idString] = completer; |
| 169 window.parent.postMessage(JSON.encode(message), '*'); | 169 window.parent.postMessage(JSON.encode(message), '*'); |
| 170 return completer.future; | 170 return completer.future; |
| 171 } | 171 } |
| 172 } | 172 } |
| OLD | NEW |