| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 * Generic success/failure response proxy. | 192 * Generic success/failure response proxy. |
| 193 * | 193 * |
| 194 * @param {function():void} onDone | 194 * @param {function():void} onDone |
| 195 * @param {function(remoting.Error):void} onError | 195 * @param {function(remoting.Error):void} onError |
| 196 * @return {function(XMLHttpRequest):void} | 196 * @return {function(XMLHttpRequest):void} |
| 197 */ | 197 */ |
| 198 remoting.xhr.defaultResponse = function(onDone, onError) { | 198 remoting.xhr.defaultResponse = function(onDone, onError) { |
| 199 /** @param {XMLHttpRequest} xhr */ | 199 /** @param {XMLHttpRequest} xhr */ |
| 200 var result = function(xhr) { | 200 var result = function(xhr) { |
| 201 /** @type {remoting.Error} */ | 201 /** @type {remoting.Error} */ |
| 202 var error = remoting.Error.fromHttpError(/** @type {number} */ (xhr.status)) | 202 var error = |
| 203 remoting.Error.fromHttpStatus(/** @type {number} */ (xhr.status)); |
| 203 if (error == remoting.Error.NONE) { | 204 if (error == remoting.Error.NONE) { |
| 204 onDone(); | 205 onDone(); |
| 205 } else { | 206 } else { |
| 206 onError(error); | 207 onError(error); |
| 207 } | 208 } |
| 208 }; | 209 }; |
| 209 return result; | 210 return result; |
| 210 }; | 211 }; |
| OLD | NEW |