| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = base.getStringAttr(item, 'hostName', ''); |
| 122 host.hostId = getStringAttr(item, 'hostId', ''); | 122 host.hostId = base.getStringAttr(item, 'hostId', ''); |
| 123 host.status = getStringAttr(item, 'status', ''); | 123 host.status = base.getStringAttr(item, 'status', ''); |
| 124 host.jabberId = getStringAttr(item, 'jabberId', ''); | 124 host.jabberId = base.getStringAttr(item, 'jabberId', ''); |
| 125 host.publicKey = getStringAttr(item, 'publicKey', ''); | 125 host.publicKey = base.getStringAttr(item, 'publicKey', ''); |
| 126 host.hostVersion = getStringAttr(item, 'hostVersion', ''); | 126 host.hostVersion = base.getStringAttr(item, 'hostVersion', ''); |
| 127 host.tokenUrlPatterns = getArrayAttr(item, 'tokenUrlPatterns', []); | 127 host.tokenUrlPatterns = |
| 128 host.updatedTime = getStringAttr(item, 'updatedTime', ''); | 128 base.getArrayAttr(item, 'tokenUrlPatterns', []); |
| 129 host.hostOfflineReason = getStringAttr(item, 'hostOfflineReason', ''); | 129 host.updatedTime = base.getStringAttr(item, 'updatedTime', ''); |
| 130 host.hostOfflineReason = |
| 131 base.getStringAttr(item, 'hostOfflineReason', ''); |
| 130 return host; | 132 return host; |
| 131 }); | 133 }); |
| 132 onDone(hosts); | 134 onDone(hosts); |
| 133 } | 135 } |
| 134 } else { | 136 } else { |
| 135 onError(remoting.Error.fromHttpStatus(xhr.status)); | 137 onError(remoting.Error.fromHttpStatus(xhr.status)); |
| 136 } | 138 } |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 /** @type {remoting.HostListApi} */ | 141 /** @type {remoting.HostListApi} */ |
| 140 remoting.hostListApi = new remoting.HostListApiImpl(); | 142 remoting.hostListApi = new remoting.HostListApiImpl(); |
| 141 | 143 |
| 142 })(); | 144 })(); |
| 143 | 145 |
| OLD | NEW |