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

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

Issue 1028683004: Added better error and OAuth support in xhr.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 52f9377e58a12aa64aa256b4094b69d3cc5397b7..1e0a487748db4bed3ef8d7c236e58394e959cc5c 100644
--- a/remoting/webapp/crd/js/host_list_api_impl.js
+++ b/remoting/webapp/crd/js/host_list_api_impl.js
@@ -53,23 +53,19 @@ remoting.HostListApiImpl.prototype.get = function(onDone, onError) {
*/
remoting.HostListApiImpl.prototype.put =
function(hostId, hostName, hostPublicKey, onDone, onError) {
- /** @param {string} token */
- var onToken = function(token) {
- var newHostDetails = {
+ new remoting.Xhr({
+ method: 'PUT',
+ url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
+ jsonContent: {
'data': {
'hostId': hostId,
'hostName': hostName,
'publicKey': hostPublicKey
}
- };
- new remoting.Xhr({
- method: 'PUT',
- url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
- jsonContent: newHostDetails,
- oauthToken: token
- }).start().then(remoting.Xhr.defaultResponse(onDone, onError));
- };
- remoting.identity.getToken().then(onToken, remoting.Error.handler(onError));
+ },
+ useIdentity: true,
+ ignoreErrors: []
+ }).start().then(onDone, remoting.Error.handler(onError));
};
/**
@@ -80,16 +76,12 @@ remoting.HostListApiImpl.prototype.put =
* @param {string} hostId
*/
remoting.HostListApiImpl.prototype.remove = function(hostId, onDone, onError) {
- /** @param {string} token */
- var onToken = function(token) {
- new remoting.Xhr({
- method: 'DELETE',
- url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
- oauthToken: token
- }).start().then(remoting.Xhr.defaultResponse(
- onDone, onError, [remoting.Error.Tag.NOT_FOUND]));
- };
- remoting.identity.getToken().then(onToken, remoting.Error.handler(onError));
+ new remoting.Xhr({
+ method: 'DELETE',
+ url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
+ useIdentity: true,
+ ignoreErrors: [remoting.Error.Tag.NOT_FOUND]
+ }).start().then(onDone, remoting.Error.handler(onError));
};
/**

Powered by Google App Engine
This is Rietveld 408576698