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

Unified Diff: remoting/webapp/app_remoting/js/app_remoting.js

Issue 1003433002: Updated remoting.xhr API to use promises. Removed access to the native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spy-promise
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/webapp/app_remoting/js/feedback_consent.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/app_remoting/js/app_remoting.js
diff --git a/remoting/webapp/app_remoting/js/app_remoting.js b/remoting/webapp/app_remoting/js/app_remoting.js
index 82983eb68e4f6cdf3111df0a93ad228056e11e40..b3fd07c25fc24c3383d03422c35dd490761d97e7 100644
--- a/remoting/webapp/app_remoting/js/app_remoting.js
+++ b/remoting/webapp/app_remoting/js/app_remoting.js
@@ -105,11 +105,11 @@ remoting.AppRemoting.prototype.start = function(connector, token) {
/** @type {remoting.AppRemoting} */
var that = this;
- /** @param {XMLHttpRequest} xhr */
- var parseAppHostResponse = function(xhr) {
- if (xhr.status == 200) {
+ /** @param {!remoting.Xhr.Response} xhrResponse */
+ var parseAppHostResponse = function(xhrResponse) {
+ if (xhrResponse.status == 200) {
var response = /** @type {remoting.AppRemoting.AppHostResponse} */
- (base.jsonParseSafe(xhr.responseText));
+ (base.jsonParseSafe(xhrResponse.getText()));
if (response &&
response.status &&
response.status == 'done' &&
@@ -157,16 +157,16 @@ remoting.AppRemoting.prototype.start = function(connector, token) {
// TODO(garykac) Start using remoting.Error.fromHttpStatus once it has
// been updated to properly report 'unknown' errors (rather than
// reporting them as AUTHENTICATION_FAILED).
- if (xhr.status == 0) {
+ if (xhrResponse.status == 0) {
that.handleError(new remoting.Error(
remoting.Error.Tag.NETWORK_FAILURE));
- } else if (xhr.status == 401) {
+ } else if (xhrResponse.status == 401) {
that.handleError(new remoting.Error(
remoting.Error.Tag.AUTHENTICATION_FAILED));
- } else if (xhr.status == 403) {
+ } else if (xhrResponse.status == 403) {
that.handleError(new remoting.Error(
remoting.Error.Tag.APP_NOT_AUTHORIZED));
- } else if (xhr.status == 502 || xhr.status == 503) {
+ } else if (xhrResponse.status == 502 || xhrResponse.status == 503) {
that.handleError(new remoting.Error(
remoting.Error.Tag.SERVICE_UNAVAILABLE));
} else {
@@ -175,12 +175,11 @@ remoting.AppRemoting.prototype.start = function(connector, token) {
}
};
- remoting.xhr.start({
+ new remoting.Xhr({
method: 'POST',
url: that.runApplicationUrl(),
- onDone: parseAppHostResponse,
oauthToken: token
- });
+ }).start().then(parseAppHostResponse);
};
/**
« no previous file with comments | « no previous file | remoting/webapp/app_remoting/js/feedback_consent.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698