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:math'; | 8 import 'dart:math'; |
9 import 'dart:svg' as svg; | 9 import 'dart:svg' as svg; |
10 import 'dart:web_audio' as web_audio; | 10 import 'dart:web_audio' as web_audio; |
(...skipping 24006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24017 }; | 24017 }; |
24018 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 24018 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
24019 // for details. All rights reserved. Use of this source code is governed by a | 24019 // for details. All rights reserved. Use of this source code is governed by a |
24020 // BSD-style license that can be found in the LICENSE file. | 24020 // BSD-style license that can be found in the LICENSE file. |
24021 | 24021 |
24022 | 24022 |
24023 class _HttpRequestUtils { | 24023 class _HttpRequestUtils { |
24024 | 24024 |
24025 // Helper for factory HttpRequest.get | 24025 // Helper for factory HttpRequest.get |
24026 static HttpRequest get(String url, | 24026 static HttpRequest get(String url, |
24027 onComplete(HttpRequest request), | 24027 onSuccess(HttpRequest request), |
24028 bool withCredentials) { | 24028 bool withCredentials) { |
24029 final request = new HttpRequest(); | 24029 final request = new HttpRequest(); |
24030 request.open('GET', url, true); | 24030 request.open('GET', url, true); |
24031 | 24031 |
24032 request.withCredentials = withCredentials; | 24032 request.withCredentials = withCredentials; |
24033 | 24033 |
| 24034 // Status 0 is for local XHR request. |
24034 request.on.readyStateChange.add((e) { | 24035 request.on.readyStateChange.add((e) { |
24035 if (request.readyState == HttpRequest.DONE) { | 24036 if (request.readyState == HttpRequest.DONE && |
24036 // TODO(efortuna): Previously HttpRequest.get only invoked the callback | 24037 (request.status == 200 || request.status == 0)) { |
24037 // when request.status was 0 or 200. This | 24038 onSuccess(request); |
24038 // causes two problems 1) request.status = 0 for ANY local XHR request | |
24039 // (file found or not found) 2) the user facing function claims that the | |
24040 // callback is called on completion of the request, regardless of | |
24041 // status. Because the new event model is coming in soon, rather than | |
24042 // fixing the callbacks version, we just need to revisit the desired | |
24043 // behavior when we're using streams/futures. | |
24044 // Status 0 is for local XHR request. | |
24045 onComplete(request); | |
24046 } | 24039 } |
24047 }); | 24040 }); |
24048 | 24041 |
24049 request.send(); | 24042 request.send(); |
24050 | 24043 |
24051 return request; | 24044 return request; |
24052 } | 24045 } |
24053 } | 24046 } |
24054 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 24047 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
24055 // for details. All rights reserved. Use of this source code is governed by a | 24048 // 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... |
25302 T next() { | 25295 T next() { |
25303 if (!hasNext) { | 25296 if (!hasNext) { |
25304 throw new StateError("No more elements"); | 25297 throw new StateError("No more elements"); |
25305 } | 25298 } |
25306 return _array[_pos++]; | 25299 return _array[_pos++]; |
25307 } | 25300 } |
25308 | 25301 |
25309 final List<T> _array; | 25302 final List<T> _array; |
25310 int _pos; | 25303 int _pos; |
25311 } | 25304 } |
OLD | NEW |