| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 var obj = /** @type {{data: {items: Array}}} */ | 108 var obj = /** @type {{data: {items: Array}}} */ |
| 109 (base.jsonParseSafe(response.getText())); | 109 (base.jsonParseSafe(response.getText())); |
| 110 if (!obj || !obj.data) { | 110 if (!obj || !obj.data) { |
| 111 console.error('Invalid "hosts" response from server.'); | 111 console.error('Invalid "hosts" response from server.'); |
| 112 onError(remoting.Error.unexpected()); | 112 onError(remoting.Error.unexpected()); |
| 113 } else { | 113 } else { |
| 114 var items = obj.data.items || []; | 114 var items = obj.data.items || []; |
| 115 var hosts = items.map( | 115 var hosts = items.map( |
| 116 function(/** Object */ item) { | 116 function(/** Object */ item) { |
| 117 var host = new remoting.Host(); | 117 var host = new remoting.Host(); |
| 118 host.hostName = getStringAttr(item, 'hostName', ''); | 118 host.hostName = base.getStringAttr(item, 'hostName', ''); |
| 119 host.hostId = getStringAttr(item, 'hostId', ''); | 119 host.hostId = base.getStringAttr(item, 'hostId', ''); |
| 120 host.status = getStringAttr(item, 'status', ''); | 120 host.status = base.getStringAttr(item, 'status', ''); |
| 121 host.jabberId = getStringAttr(item, 'jabberId', ''); | 121 host.jabberId = base.getStringAttr(item, 'jabberId', ''); |
| 122 host.publicKey = getStringAttr(item, 'publicKey', ''); | 122 host.publicKey = base.getStringAttr(item, 'publicKey', ''); |
| 123 host.hostVersion = getStringAttr(item, 'hostVersion', ''); | 123 host.hostVersion = base.getStringAttr(item, 'hostVersion', ''); |
| 124 host.tokenUrlPatterns = getArrayAttr(item, 'tokenUrlPatterns', []); | 124 host.tokenUrlPatterns = |
| 125 host.updatedTime = getStringAttr(item, 'updatedTime', ''); | 125 base.getArrayAttr(item, 'tokenUrlPatterns', []); |
| 126 host.hostOfflineReason = getStringAttr(item, 'hostOfflineReason', ''); | 126 host.updatedTime = base.getStringAttr(item, 'updatedTime', ''); |
| 127 host.hostOfflineReason = |
| 128 base.getStringAttr(item, 'hostOfflineReason', ''); |
| 127 return host; | 129 return host; |
| 128 }); | 130 }); |
| 129 onDone(hosts); | 131 onDone(hosts); |
| 130 } | 132 } |
| 131 } else { | 133 } else { |
| 132 onError(remoting.Error.fromHttpStatus(response.status)); | 134 onError(remoting.Error.fromHttpStatus(response.status)); |
| 133 } | 135 } |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 /** @type {remoting.HostListApi} */ | 138 /** @type {remoting.HostListApi} */ |
| 137 remoting.hostListApi = new remoting.HostListApiImpl(); | 139 remoting.hostListApi = new remoting.HostListApiImpl(); |
| 138 | 140 |
| 139 })(); | 141 })(); |
| OLD | NEW |