| 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 838bafa9e6d0a46b9cb7eac776a1e7452f73f149..f82ad1a1a9fbf08c3b1817600988987adb1c45a2 100644
|
| --- a/remoting/webapp/crd/js/host_list_api_impl.js
|
| +++ b/remoting/webapp/crd/js/host_list_api_impl.js
|
| @@ -26,17 +26,16 @@ remoting.HostListApiImpl = function() {
|
| * @param {function(!remoting.Error):void} onError
|
| */
|
| remoting.HostListApiImpl.prototype.get = function(onDone, onError) {
|
| - /** @type {function(XMLHttpRequest):void} */
|
| + /** @type {function(remoting.Xhr.Response):void} */
|
| var parseHostListResponse =
|
| this.parseHostListResponse_.bind(this, onDone, onError);
|
| /** @param {string} token */
|
| var onToken = function(token) {
|
| - remoting.xhr.start({
|
| + new remoting.Xhr({
|
| method: 'GET',
|
| url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
|
| - onDone: parseHostListResponse,
|
| oauthToken: token
|
| - });
|
| + }).then(parseHostListResponse);
|
| };
|
| remoting.identity.getToken().then(onToken, remoting.Error.handler(onError));
|
| };
|
| @@ -61,13 +60,12 @@ remoting.HostListApiImpl.prototype.put =
|
| 'publicKey': hostPublicKey
|
| }
|
| };
|
| - remoting.xhr.start({
|
| + new remoting.Xhr({
|
| method: 'PUT',
|
| url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
|
| - onDone: remoting.xhr.defaultResponse(onDone, onError),
|
| jsonContent: newHostDetails,
|
| oauthToken: token
|
| - });
|
| + }).then(remoting.Xhr.defaultResponse(onDone, onError));
|
| };
|
| remoting.identity.getToken().then(onToken, remoting.Error.handler(onError));
|
| };
|
| @@ -82,12 +80,11 @@ remoting.HostListApiImpl.prototype.put =
|
| remoting.HostListApiImpl.prototype.remove = function(hostId, onDone, onError) {
|
| /** @param {string} token */
|
| var onToken = function(token) {
|
| - remoting.xhr.start({
|
| + new remoting.Xhr({
|
| method: 'DELETE',
|
| url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts/' + hostId,
|
| - onDone: remoting.xhr.defaultResponse(onDone, onError),
|
| oauthToken: token
|
| - });
|
| + }).then(remoting.Xhr.defaultResponse(onDone, onError));
|
| };
|
| remoting.identity.getToken().then(onToken, remoting.Error.handler(onError));
|
| };
|
| @@ -99,14 +96,14 @@ remoting.HostListApiImpl.prototype.remove = function(hostId, onDone, onError) {
|
| *
|
| * @param {function(Array<remoting.Host>):void} onDone
|
| * @param {function(!remoting.Error):void} onError
|
| - * @param {XMLHttpRequest} xhr
|
| + * @param {remoting.Xhr.Response} xhrr
|
| * @private
|
| */
|
| remoting.HostListApiImpl.prototype.parseHostListResponse_ =
|
| - function(onDone, onError, xhr) {
|
| - if (xhr.status == 200) {
|
| + function(onDone, onError, xhrr) {
|
| + if (xhrr.status == 200) {
|
| var response = /** @type {{data: {items: Array}}} */
|
| - (base.jsonParseSafe(xhr.responseText));
|
| + (base.jsonParseSafe(xhrr.responseText));
|
| if (!response || !response.data) {
|
| console.error('Invalid "hosts" response from server.');
|
| onError(remoting.Error.UNEXPECTED);
|
| @@ -129,7 +126,7 @@ remoting.HostListApiImpl.prototype.parseHostListResponse_ =
|
| onDone(hosts);
|
| }
|
| } else {
|
| - onError(remoting.Error.fromHttpStatus(xhr.status));
|
| + onError(remoting.Error.fromHttpStatus(xhrr.status));
|
| }
|
| };
|
|
|
|
|