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

Side by Side Diff: remoting/webapp/crd/js/host_list_api_impl.js

Issue 917093003: Shorten Closure template notation from Array.<*> to Array<*>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove cvox 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 unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/host_list_api.js ('k') | remoting/webapp/crd/js/host_settings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * REST API for host-list management. 7 * REST API for host-list management.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * @constructor 16 * @constructor
17 * @implements {remoting.HostListApi} 17 * @implements {remoting.HostListApi}
18 */ 18 */
19 remoting.HostListApiImpl = function() { 19 remoting.HostListApiImpl = function() {
20 }; 20 };
21 21
22 /** 22 /**
23 * Fetch the list of hosts for a user. 23 * Fetch the list of hosts for a user.
24 * 24 *
25 * @param {function(Array.<remoting.Host>):void} onDone 25 * @param {function(Array<remoting.Host>):void} onDone
26 * @param {function(remoting.Error):void} onError 26 * @param {function(remoting.Error):void} onError
27 */ 27 */
28 remoting.HostListApiImpl.prototype.get = function(onDone, onError) { 28 remoting.HostListApiImpl.prototype.get = function(onDone, onError) {
29 /** @type {function(XMLHttpRequest):void} */ 29 /** @type {function(XMLHttpRequest):void} */
30 var parseHostListResponse = 30 var parseHostListResponse =
31 this.parseHostListResponse_.bind(this, onDone, onError) 31 this.parseHostListResponse_.bind(this, onDone, onError)
32 /** @param {string} token */ 32 /** @param {string} token */
33 var onToken = function(token) { 33 var onToken = function(token) {
34 var headers = { 'Authorization': 'OAuth ' + token }; 34 var headers = { 'Authorization': 'OAuth ' + token };
35 remoting.xhr.get(remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', 35 remoting.xhr.get(remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts',
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 '', headers); 88 '', headers);
89 }; 89 };
90 remoting.identity.callWithToken(onToken, onError); 90 remoting.identity.callWithToken(onToken, onError);
91 }; 91 };
92 92
93 /** 93 /**
94 * Handle the results of the host list request. A success response will 94 * Handle the results of the host list request. A success response will
95 * include a JSON-encoded list of host descriptions, which is parsed and 95 * include a JSON-encoded list of host descriptions, which is parsed and
96 * passed to the callback. 96 * passed to the callback.
97 * 97 *
98 * @param {function(Array.<remoting.Host>):void} onDone 98 * @param {function(Array<remoting.Host>):void} onDone
99 * @param {function(remoting.Error):void} onError 99 * @param {function(remoting.Error):void} onError
100 * @param {XMLHttpRequest} xhr 100 * @param {XMLHttpRequest} xhr
101 * @private 101 * @private
102 */ 102 */
103 remoting.HostListApiImpl.prototype.parseHostListResponse_ = 103 remoting.HostListApiImpl.prototype.parseHostListResponse_ =
104 function(onDone, onError, xhr) { 104 function(onDone, onError, xhr) {
105 if (xhr.status == 200) { 105 if (xhr.status == 200) {
106 var response = /** @type {{data: {items: Array}}} */ 106 var response = /** @type {{data: {items: Array}}} */
107 (base.jsonParseSafe(xhr.responseText)); 107 (base.jsonParseSafe(xhr.responseText));
108 if (!response || !response.data) { 108 if (!response || !response.data) {
109 console.error('Invalid "hosts" response from server.'); 109 console.error('Invalid "hosts" response from server.');
110 onError(remoting.Error.UNEXPECTED); 110 onError(remoting.Error.UNEXPECTED);
111 } else { 111 } else {
112 var hosts = response.data.items || []; 112 var hosts = response.data.items || [];
113 onDone(hosts); 113 onDone(hosts);
114 } 114 }
115 } else { 115 } else {
116 onError(remoting.Error.fromHttpStatus(xhr.status)); 116 onError(remoting.Error.fromHttpStatus(xhr.status));
117 } 117 }
118 }; 118 };
119 119
120 /** @type {remoting.HostListApi} */ 120 /** @type {remoting.HostListApi} */
121 remoting.hostListApi = new remoting.HostListApiImpl(); 121 remoting.hostListApi = new remoting.HostListApiImpl();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/host_list_api.js ('k') | remoting/webapp/crd/js/host_settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698