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

Unified Diff: remoting/webapp/crd/js/host_list_api_impl.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, 10 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
Index: remoting/webapp/crd/js/host_list_api_impl.js
diff --git a/remoting/webapp/crd/js/host_list_api_impl.js b/remoting/webapp/crd/js/host_list_api_impl.js
index 9516e3ca45ea59134dddea265224fa5c15943649..e7538779c3b83e5781bf58e5b9111d8e48efbd65 100644
--- a/remoting/webapp/crd/js/host_list_api_impl.js
+++ b/remoting/webapp/crd/js/host_list_api_impl.js
@@ -28,12 +28,15 @@ remoting.HostListApiImpl = function() {
remoting.HostListApiImpl.prototype.get = function(onDone, onError) {
/** @type {function(XMLHttpRequest):void} */
var parseHostListResponse =
- this.parseHostListResponse_.bind(this, onDone, onError)
+ this.parseHostListResponse_.bind(this, onDone, onError);
/** @param {string} token */
var onToken = function(token) {
- var headers = { 'Authorization': 'OAuth ' + token };
- remoting.xhr.get(remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
- parseHostListResponse, '', headers);
+ remoting.xhr.start({
+ method: 'GET',
+ url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
+ onDone: parseHostListResponse,
+ oauthToken: token
+ });
};
remoting.identity.callWithToken(onToken, onError);
};
@@ -51,10 +54,6 @@ remoting.HostListApiImpl.prototype.put =
function(hostId, hostName, hostPublicKey, onDone, onError) {
/** @param {string} token */
var onToken = function(token) {
- var headers = {
- 'Authorization': 'OAuth ' + token,
- 'Content-type' : 'application/json; charset=UTF-8'
- };
var newHostDetails = {
'data': {
'hostId': hostId,
@@ -62,11 +61,13 @@ remoting.HostListApiImpl.prototype.put =
'publicKey': hostPublicKey
}
};
- remoting.xhr.put(
- remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
- remoting.xhr.defaultResponse(onDone, onError),
- JSON.stringify(newHostDetails),
- headers);
+ remoting.xhr.start({
+ method: 'PUT',
+ url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
+ onDone: remoting.xhr.defaultResponse(onDone, onError),
+ jsonContent: newHostDetails,
+ oauthToken: token
+ });
};
remoting.identity.callWithToken(onToken, onError);
};
@@ -81,11 +82,12 @@ remoting.HostListApiImpl.prototype.put =
remoting.HostListApiImpl.prototype.remove = function(hostId, onDone, onError) {
/** @param {string} token */
var onToken = function(token) {
- var headers = { 'Authorization': 'OAuth ' + token };
- remoting.xhr.remove(
- remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
- remoting.xhr.defaultResponse(onDone, onError),
- '', headers);
+ remoting.xhr.start({
+ method: 'DELETE',
+ url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
+ onDone: remoting.xhr.defaultResponse(onDone, onError),
+ oauthToken: token
+ });
};
remoting.identity.callWithToken(onToken, onError);
};

Powered by Google App Engine
This is Rietveld 408576698