Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: tools/dom/src/_HttpRequestUtils.dart

Issue 11800002: "Reverting 16675-16676, 71-73" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/xhr_test.dart ('k') | tools/test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 html; 5 part of html;
6 6
7 class _HttpRequestUtils { 7 class _HttpRequestUtils {
8 8
9 // Helper for factory HttpRequest.get 9 // Helper for factory HttpRequest.get
10 static HttpRequest get(String url, 10 static HttpRequest get(String url,
11 onComplete(HttpRequest request), 11 onSuccess(HttpRequest request),
12 bool withCredentials) { 12 bool withCredentials) {
13 final request = new HttpRequest(); 13 final request = new HttpRequest();
14 request.open('GET', url, true); 14 request.open('GET', url, true);
15 15
16 request.withCredentials = withCredentials; 16 request.withCredentials = withCredentials;
17 17
18 // Status 0 is for local XHR request.
18 request.on.readyStateChange.add((e) { 19 request.on.readyStateChange.add((e) {
19 if (request.readyState == HttpRequest.DONE) { 20 if (request.readyState == HttpRequest.DONE &&
20 // TODO(efortuna): Previously HttpRequest.get only invoked the callback 21 (request.status == 200 || request.status == 0)) {
21 // when request.status was 0 or 200. This 22 onSuccess(request);
22 // causes two problems 1) request.status = 0 for ANY local XHR request
23 // (file found or not found) 2) the user facing function claims that the
24 // callback is called on completion of the request, regardless of
25 // status. Because the new event model is coming in soon, rather than
26 // fixing the callbacks version, we just need to revisit the desired
27 // behavior when we're using streams/futures.
28 // Status 0 is for local XHR request.
29 onComplete(request);
30 } 23 }
31 }); 24 });
32 25
33 request.send(); 26 request.send();
34 27
35 return request; 28 return request;
36 } 29 }
37 } 30 }
OLDNEW
« no previous file with comments | « tests/html/xhr_test.dart ('k') | tools/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698