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

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

Issue 1004513002: Eliminated named constants for instances of remoting.Error. (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 unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/host_list.js ('k') | remoting/webapp/crd/js/host_screen.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 /** @suppress {duplicate} */ 10 /** @suppress {duplicate} */
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 * @param {XMLHttpRequest} xhr 105 * @param {XMLHttpRequest} xhr
106 * @private 106 * @private
107 */ 107 */
108 remoting.HostListApiImpl.prototype.parseHostListResponse_ = 108 remoting.HostListApiImpl.prototype.parseHostListResponse_ =
109 function(onDone, onError, xhr) { 109 function(onDone, onError, xhr) {
110 if (xhr.status == 200) { 110 if (xhr.status == 200) {
111 var response = /** @type {{data: {items: Array}}} */ 111 var response = /** @type {{data: {items: Array}}} */
112 (base.jsonParseSafe(xhr.responseText)); 112 (base.jsonParseSafe(xhr.responseText));
113 if (!response || !response.data) { 113 if (!response || !response.data) {
114 console.error('Invalid "hosts" response from server.'); 114 console.error('Invalid "hosts" response from server.');
115 onError(remoting.Error.UNEXPECTED); 115 onError(remoting.Error.unexpected());
116 } else { 116 } else {
117 var items = response.data.items || []; 117 var items = response.data.items || [];
118 var hosts = items.map( 118 var hosts = items.map(
119 function(/** Object */ item) { 119 function(/** Object */ item) {
120 var host = new remoting.Host(); 120 var host = new remoting.Host();
121 host.hostName = getStringAttr(item, 'hostName', ''); 121 host.hostName = getStringAttr(item, 'hostName', '');
122 host.hostId = getStringAttr(item, 'hostId', ''); 122 host.hostId = getStringAttr(item, 'hostId', '');
123 host.status = getStringAttr(item, 'status', ''); 123 host.status = getStringAttr(item, 'status', '');
124 host.jabberId = getStringAttr(item, 'jabberId', ''); 124 host.jabberId = getStringAttr(item, 'jabberId', '');
125 host.publicKey = getStringAttr(item, 'publicKey', ''); 125 host.publicKey = getStringAttr(item, 'publicKey', '');
126 host.hostVersion = getStringAttr(item, 'hostVersion', ''); 126 host.hostVersion = getStringAttr(item, 'hostVersion', '');
127 host.tokenUrlPatterns = getArrayAttr(item, 'tokenUrlPatterns', []); 127 host.tokenUrlPatterns = getArrayAttr(item, 'tokenUrlPatterns', []);
128 host.updatedTime = getStringAttr(item, 'updatedTime', ''); 128 host.updatedTime = getStringAttr(item, 'updatedTime', '');
129 host.hostOfflineReason = getStringAttr(item, 'hostOfflineReason', ''); 129 host.hostOfflineReason = getStringAttr(item, 'hostOfflineReason', '');
130 return host; 130 return host;
131 }); 131 });
132 onDone(hosts); 132 onDone(hosts);
133 } 133 }
134 } else { 134 } else {
135 onError(remoting.Error.fromHttpStatus(xhr.status)); 135 onError(remoting.Error.fromHttpStatus(xhr.status));
136 } 136 }
137 }; 137 };
138 138
139 /** @type {remoting.HostListApi} */ 139 /** @type {remoting.HostListApi} */
140 remoting.hostListApi = new remoting.HostListApiImpl(); 140 remoting.hostListApi = new remoting.HostListApiImpl();
141 141
142 })(); 142 })();
143 143
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/host_list.js ('k') | remoting/webapp/crd/js/host_screen.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698