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:nativewrappers'; | 8 import 'dart:nativewrappers'; |
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 28626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
28637 }; | 28637 }; |
28638 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 28638 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
28639 // for details. All rights reserved. Use of this source code is governed by a | 28639 // for details. All rights reserved. Use of this source code is governed by a |
28640 // BSD-style license that can be found in the LICENSE file. | 28640 // BSD-style license that can be found in the LICENSE file. |
28641 | 28641 |
28642 | 28642 |
28643 class _HttpRequestUtils { | 28643 class _HttpRequestUtils { |
28644 | 28644 |
28645 // Helper for factory HttpRequest.get | 28645 // Helper for factory HttpRequest.get |
28646 static HttpRequest get(String url, | 28646 static HttpRequest get(String url, |
28647 onComplete(HttpRequest request), | 28647 onSuccess(HttpRequest request), |
28648 bool withCredentials) { | 28648 bool withCredentials) { |
28649 final request = new HttpRequest(); | 28649 final request = new HttpRequest(); |
28650 request.open('GET', url, true); | 28650 request.open('GET', url, true); |
28651 | 28651 |
28652 request.withCredentials = withCredentials; | 28652 request.withCredentials = withCredentials; |
28653 | 28653 |
| 28654 // Status 0 is for local XHR request. |
28654 request.on.readyStateChange.add((e) { | 28655 request.on.readyStateChange.add((e) { |
28655 if (request.readyState == HttpRequest.DONE) { | 28656 if (request.readyState == HttpRequest.DONE && |
28656 // TODO(efortuna): Previously HttpRequest.get only invoked the callback | 28657 (request.status == 200 || request.status == 0)) { |
28657 // when request.status was 0 or 200. This | 28658 onSuccess(request); |
28658 // causes two problems 1) request.status = 0 for ANY local XHR request | |
28659 // (file found or not found) 2) the user facing function claims that the | |
28660 // callback is called on completion of the request, regardless of | |
28661 // status. Because the new event model is coming in soon, rather than | |
28662 // fixing the callbacks version, we just need to revisit the desired | |
28663 // behavior when we're using streams/futures. | |
28664 // Status 0 is for local XHR request. | |
28665 onComplete(request); | |
28666 } | 28659 } |
28667 }); | 28660 }); |
28668 | 28661 |
28669 request.send(); | 28662 request.send(); |
28670 | 28663 |
28671 return request; | 28664 return request; |
28672 } | 28665 } |
28673 } | 28666 } |
28674 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 28667 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
28675 // for details. All rights reserved. Use of this source code is governed by a | 28668 // for details. All rights reserved. Use of this source code is governed by a |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
29761 bool get isEmpty => Maps.isEmpty(this); | 29754 bool get isEmpty => Maps.isEmpty(this); |
29762 } | 29755 } |
29763 | 29756 |
29764 get _printClosure => (s) { | 29757 get _printClosure => (s) { |
29765 try { | 29758 try { |
29766 window.console.log(s); | 29759 window.console.log(s); |
29767 } catch (_) { | 29760 } catch (_) { |
29768 _Utils.print(s); | 29761 _Utils.print(s); |
29769 } | 29762 } |
29770 }; | 29763 }; |
OLD | NEW |