OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Simple utilities for making XHRs more pleasant. | 7 * Simple utilities for making XHRs more pleasant. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 * @param {function():void} onDone | 201 * @param {function():void} onDone |
202 * @param {function(!remoting.Error):void} onError | 202 * @param {function(!remoting.Error):void} onError |
203 * @param {Array<remoting.Error.Tag>=} opt_ignoreErrors | 203 * @param {Array<remoting.Error.Tag>=} opt_ignoreErrors |
204 * @return {function(XMLHttpRequest):void} | 204 * @return {function(XMLHttpRequest):void} |
205 */ | 205 */ |
206 remoting.xhr.defaultResponse = function(onDone, onError, opt_ignoreErrors) { | 206 remoting.xhr.defaultResponse = function(onDone, onError, opt_ignoreErrors) { |
207 /** @param {XMLHttpRequest} xhr */ | 207 /** @param {XMLHttpRequest} xhr */ |
208 var result = function(xhr) { | 208 var result = function(xhr) { |
209 var error = | 209 var error = |
210 remoting.Error.fromHttpStatus(/** @type {number} */ (xhr.status)); | 210 remoting.Error.fromHttpStatus(/** @type {number} */ (xhr.status)); |
211 if (!error.isError()) { | 211 if (error.isNone()) { |
212 onDone(); | 212 onDone(); |
213 return; | 213 return; |
214 } | 214 } |
215 | 215 |
216 if (opt_ignoreErrors && opt_ignoreErrors.indexOf(error.tag) !== -1) { | 216 if (opt_ignoreErrors && error.hasTag.apply(error, opt_ignoreErrors)) { |
217 onDone(); | 217 onDone(); |
218 return; | 218 return; |
219 } | 219 } |
220 | 220 |
221 onError(error); | 221 onError(error); |
222 }; | 222 }; |
223 return result; | 223 return result; |
224 }; | 224 }; |
OLD | NEW |