OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @constructor */ | 10 /** @constructor */ |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // information won't be in sync for several seconds. We don't know the | 131 // information won't be in sync for several seconds. We don't know the |
132 // host JID or public key, but they can be missing from the cache with | 132 // host JID or public key, but they can be missing from the cache with |
133 // no ill effects (it will be refreshed--we hope that the directory | 133 // no ill effects (it will be refreshed--we hope that the directory |
134 // will have been updated by that point). | 134 // will have been updated by that point). |
135 var localHost = new remoting.Host(); | 135 var localHost = new remoting.Host(); |
136 localHost.hostName = hostName; | 136 localHost.hostName = hostName; |
137 localHost.hostId = newHostId; | 137 localHost.hostId = newHostId; |
138 localHost.status = 'ONLINE'; | 138 localHost.status = 'ONLINE'; |
139 that.setHost(localHost); | 139 that.setHost(localHost); |
140 remoting.hostList.addHost(localHost); | 140 remoting.hostList.addHost(localHost); |
| 141 } else { |
| 142 // Unregister the host if we failed to start it. |
| 143 remoting.HostList.unregisterHostById(newHostId); |
141 } | 144 } |
142 callback(result); | 145 callback(result); |
143 }; | 146 }; |
144 | 147 |
145 /** @param {string} privateKey | 148 /** @param {string} privateKey |
146 * @param {XMLHttpRequest} xhr */ | 149 * @param {XMLHttpRequest} xhr */ |
147 function onRegistered(privateKey, xhr) { | 150 function onRegistered(privateKey, xhr) { |
148 var success = (xhr.status == 200); | 151 var success = (xhr.status == 200); |
149 | 152 |
150 if (success) { | 153 if (success) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } else { | 320 } else { |
318 that.setHost(null); | 321 that.setHost(null); |
319 } | 322 } |
320 onDone(); | 323 onDone(); |
321 }; | 324 }; |
322 this.plugin_.getDaemonConfig(onConfig); | 325 this.plugin_.getDaemonConfig(onConfig); |
323 }; | 326 }; |
324 | 327 |
325 /** @type {remoting.HostController} */ | 328 /** @type {remoting.HostController} */ |
326 remoting.hostController = null; | 329 remoting.hostController = null; |
OLD | NEW |