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

Side by Side Diff: remoting/webapp/crd/js/xhr.js

Issue 955283002: Converted remoting.Error from an enum to a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Requested changes. Created 5 years, 9 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
OLDNEW
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
192 } 192 }
193 xhr.withCredentials = withCredentials; 193 xhr.withCredentials = withCredentials;
194 xhr.send(content); 194 xhr.send(content);
195 return xhr; 195 return xhr;
196 }; 196 };
197 197
198 /** 198 /**
199 * Generic success/failure response proxy. 199 * Generic success/failure response proxy.
200 * 200 *
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 * @return {function(XMLHttpRequest):void} 203 * @return {function(XMLHttpRequest):void}
204 */ 204 */
205 remoting.xhr.defaultResponse = function(onDone, onError) { 205 remoting.xhr.defaultResponse = function(onDone, onError) {
206 /** @param {XMLHttpRequest} xhr */ 206 /** @param {XMLHttpRequest} xhr */
207 var result = function(xhr) { 207 var result = function(xhr) {
208 /** @type {remoting.Error} */
209 var error = 208 var error =
210 remoting.Error.fromHttpStatus(/** @type {number} */ (xhr.status)); 209 remoting.Error.fromHttpStatus(/** @type {number} */ (xhr.status));
211 if (error == remoting.Error.NONE) { 210 if (error.tag == remoting.Error.Tag.NONE) {
212 onDone(); 211 onDone();
213 } else { 212 } else {
214 onError(error); 213 onError(error);
215 } 214 }
216 }; 215 };
217 return result; 216 return result;
218 }; 217 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698