OLD | NEW |
1 library html; | 1 library html; |
2 | 2 |
3 import 'dart:collection'; | 3 import 'dart:collection'; |
4 import 'dart:html_common'; | 4 import 'dart:html_common'; |
5 import 'dart:indexed_db'; | 5 import 'dart:indexed_db'; |
6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
7 import 'dart:json'; | 7 import 'dart:json'; |
8 import 'dart:svg' as svg; | 8 import 'dart:svg' as svg; |
9 import 'dart:web_audio' as web_audio; | 9 import 'dart:web_audio' as web_audio; |
10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
(...skipping 24201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24212 }; | 24212 }; |
24213 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 24213 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
24214 // for details. All rights reserved. Use of this source code is governed by a | 24214 // for details. All rights reserved. Use of this source code is governed by a |
24215 // BSD-style license that can be found in the LICENSE file. | 24215 // BSD-style license that can be found in the LICENSE file. |
24216 | 24216 |
24217 | 24217 |
24218 class _HttpRequestUtils { | 24218 class _HttpRequestUtils { |
24219 | 24219 |
24220 // Helper for factory HttpRequest.get | 24220 // Helper for factory HttpRequest.get |
24221 static HttpRequest get(String url, | 24221 static HttpRequest get(String url, |
24222 onSuccess(HttpRequest request), | 24222 onComplete(HttpRequest request), |
24223 bool withCredentials) { | 24223 bool withCredentials) { |
24224 final request = new HttpRequest(); | 24224 final request = new HttpRequest(); |
24225 request.open('GET', url, true); | 24225 request.open('GET', url, true); |
24226 | 24226 |
24227 request.withCredentials = withCredentials; | 24227 request.withCredentials = withCredentials; |
24228 | 24228 |
24229 // Status 0 is for local XHR request. | |
24230 request.on.readyStateChange.add((e) { | 24229 request.on.readyStateChange.add((e) { |
24231 if (request.readyState == HttpRequest.DONE && | 24230 if (request.readyState == HttpRequest.DONE) { |
24232 (request.status == 200 || request.status == 0)) { | 24231 // TODO(efortuna): Previously the HttpRequest.get only called the |
24233 onSuccess(request); | 24232 // callback with the additional constraints below on the status. This |
| 24233 // causes two problems 1) request.status = 0 for ANY local XHR request |
| 24234 // (file found or not found) 2) the user facing function claims that the |
| 24235 // callback is called on completion of the request, regardless of |
| 24236 // status. Because the new event model is coming in soon, rather than |
| 24237 // fixing the callbacks version, we just need to revisit the desired |
| 24238 // behavior when we're using streams/futures. |
| 24239 // Status 0 is for local XHR request. |
| 24240 //(request.status == 200 || request.status == 0)) { |
| 24241 onComplete(request); |
24234 } | 24242 } |
24235 }); | 24243 }); |
24236 | 24244 |
24237 request.send(); | 24245 request.send(); |
24238 | 24246 |
24239 return request; | 24247 return request; |
24240 } | 24248 } |
24241 } | 24249 } |
24242 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 24250 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
24243 // for details. All rights reserved. Use of this source code is governed by a | 24251 // for details. All rights reserved. Use of this source code is governed by a |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25490 T next() { | 25498 T next() { |
25491 if (!hasNext) { | 25499 if (!hasNext) { |
25492 throw new StateError("No more elements"); | 25500 throw new StateError("No more elements"); |
25493 } | 25501 } |
25494 return _array[_pos++]; | 25502 return _array[_pos++]; |
25495 } | 25503 } |
25496 | 25504 |
25497 final List<T> _array; | 25505 final List<T> _array; |
25498 int _pos; | 25506 int _pos; |
25499 } | 25507 } |
OLD | NEW |