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

Unified Diff: remoting/webapp/crd/js/host_controller.js

Issue 945033002: Updated XHR API so call sites are more descriptive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@xhr-test
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 | « remoting/webapp/crd/js/dns_blackhole_checker.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/host_controller.js
diff --git a/remoting/webapp/crd/js/host_controller.js b/remoting/webapp/crd/js/host_controller.js
index 1a70ccda3e9d7be56489bbaf8b90d5e0e107b55b..57c24f8ec038eae6a42c451fcb2ae1d09bb0fc76 100644
--- a/remoting/webapp/crd/js/host_controller.js
+++ b/remoting/webapp/crd/js/host_controller.js
@@ -234,14 +234,14 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
* @param {string} hostName
* @param {string} publicKey
* @param {string} privateKey
- * @param {XMLHttpRequest} xhr
+ * @param {remoting.Xhr.Response} xhrr
*/
function onRegistered(
- hostName, publicKey, privateKey, xhr) {
- var success = (xhr.status == 200);
+ hostName, publicKey, privateKey, xhrr) {
+ var success = (xhrr.status == 200);
if (success) {
- var result = base.jsonParseSafe(xhr.responseText);
+ var result = base.jsonParseSafe(xhrr.responseText);
if ('data' in result && 'authorizationCode' in result['data']) {
that.hostDaemonFacade_.getCredentialsFromAuthCode(
result['data']['authorizationCode'],
@@ -260,8 +260,8 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
});
}
} else {
- console.log('Failed to register the host. Status: ' + xhr.status +
- ' response: ' + xhr.responseText);
+ console.log('Failed to register the host. Status: ' + xhrr.status +
+ ' response: ' + xhrr.responseText);
onError(remoting.Error.REGISTRATION_FAILED);
}
}
@@ -281,16 +281,15 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
publicKey: publicKey
} };
- remoting.xhr.start({
+ new remoting.Xhr({
method: 'POST',
url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
urlParams: {
hostClientId: hostClientId
},
- onDone: onRegistered.bind(null, hostName, publicKey, privateKey),
jsonContent: newHostDetails,
oauthToken: oauthToken
- });
+ }).then(onRegistered.bind(null, hostName, publicKey, privateKey));
}
/**
« no previous file with comments | « remoting/webapp/crd/js/dns_blackhole_checker.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698