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

Side by Side Diff: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate

Issue 12224055: Converting XHR from onLoad to onReadyStateChange (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | 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 $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 /** 7 /**
8 * A utility for retrieving data from a URL. 8 * A utility for retrieving data from a URL.
9 * 9 *
10 * HttpRequest can be used to obtain data from http, ftp, and file 10 * HttpRequest can be used to obtain data from http, ftp, and file
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 if (responseType != null) { 89 if (responseType != null) {
90 xhr.responseType = responseType; 90 xhr.responseType = responseType;
91 } 91 }
92 92
93 if (onProgress != null) { 93 if (onProgress != null) {
94 xhr.onProgress.listen(onProgress); 94 xhr.onProgress.listen(onProgress);
95 } 95 }
96 96
97 xhr.onLoad.listen((e) { 97 xhr.onReadyStateChange.listen((e) {
98 if (xhr.status >= 200 && xhr.status < 300 || 98 if (xhr.readyState == HttpRequest.DONE) {
99 xhr.status == 304 ) { 99 if (xhr.status >= 200 && xhr.status < 300 ||
100 completer.complete(xhr); 100 xhr.status == 304 ) {
Emily Fortuna 2013/02/07 20:53:44 This doesn't fix the problem described in dartbug.
101 } else { 101 completer.complete(xhr);
102 completer.completeError(e); 102 } else {
103 completer.completeError(e);
104 }
103 } 105 }
104 }); 106 });
105 107
106 xhr.onError.listen((e) { 108 xhr.onError.listen((e) {
107 completer.completeError(e); 109 completer.completeError(e);
108 }); 110 });
109 111
110 if (sendData != null) { 112 if (sendData != null) {
111 xhr.send(sendData); 113 xhr.send(sendData);
112 } else { 114 } else {
113 xhr.send(); 115 xhr.send();
114 } 116 }
115 117
116 return completer.future; 118 return completer.future;
117 } 119 }
118 120
119 $!MEMBERS 121 $!MEMBERS
120 } 122 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698