| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Connect set-up state machine for Me2Me and IT2Me | 7 * Connect set-up state machine for Me2Me and IT2Me |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Initialize/declare per-connection state. | 79 // Initialize/declare per-connection state. |
| 80 this.resetConnection_(); | 80 this.resetConnection_(); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Reset the per-connection state so that the object can be re-used for a | 84 * Reset the per-connection state so that the object can be re-used for a |
| 85 * second connection. Note the none of the shared WCS state is reset. | 85 * second connection. Note the none of the shared WCS state is reset. |
| 86 * @private | 86 * @private |
| 87 */ | 87 */ |
| 88 remoting.SessionConnectorImpl.prototype.resetConnection_ = function() { | 88 remoting.SessionConnectorImpl.prototype.resetConnection_ = function() { |
| 89 this.removePlugin_(); | 89 this.closeSession(); |
| 90 | 90 |
| 91 /** @private {remoting.Host} */ | 91 /** @private {remoting.Host} */ |
| 92 this.host_ = null; | 92 this.host_ = null; |
| 93 | 93 |
| 94 /** @private {boolean} */ | 94 /** @private {boolean} */ |
| 95 this.logHostOfflineErrors_ = false; | 95 this.logHostOfflineErrors_ = false; |
| 96 | 96 |
| 97 /** @private {remoting.ClientPlugin} */ | 97 /** @private {remoting.ClientPlugin} */ |
| 98 this.plugin_ = null; | 98 this.plugin_ = null; |
| 99 | 99 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 }; | 317 }; |
| 318 | 318 |
| 319 /** | 319 /** |
| 320 * Creates ClientSession object. | 320 * Creates ClientSession object. |
| 321 */ | 321 */ |
| 322 remoting.SessionConnectorImpl.prototype.createSession_ = function() { | 322 remoting.SessionConnectorImpl.prototype.createSession_ = function() { |
| 323 // In some circumstances, the WCS <iframe> can get reloaded, which results | 323 // In some circumstances, the WCS <iframe> can get reloaded, which results |
| 324 // in a new clientJid and a new callback. In this case, remove the old | 324 // in a new clientJid and a new callback. In this case, remove the old |
| 325 // client plugin before instantiating a new one. | 325 // client plugin before instantiating a new one. |
| 326 this.removePlugin_(); | 326 this.closeSession(); |
| 327 | 327 |
| 328 var pluginContainer = this.clientContainer_.querySelector( | 328 var pluginContainer = this.clientContainer_.querySelector( |
| 329 '.client-plugin-container'); | 329 '.client-plugin-container'); |
| 330 | 330 |
| 331 this.plugin_ = remoting.ClientPlugin.factory.createPlugin( | 331 this.plugin_ = remoting.ClientPlugin.factory.createPlugin( |
| 332 pluginContainer, this.requiredCapabilities_); | 332 pluginContainer, this.requiredCapabilities_); |
| 333 | 333 |
| 334 var that = this; | 334 var that = this; |
| 335 this.host_.options.load().then(function(){ | 335 this.host_.options.load().then(function(){ |
| 336 that.plugin_.initialize(that.onPluginInitialized_.bind(that)); | 336 that.plugin_.initialize(that.onPluginInitialized_.bind(that)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 this.host_, this.signalStrategy_.getJid(), this.credentialsProvider_); | 375 this.host_, this.signalStrategy_.getJid(), this.credentialsProvider_); |
| 376 }; | 376 }; |
| 377 | 377 |
| 378 /** | 378 /** |
| 379 * @param {!remoting.Error} error | 379 * @param {!remoting.Error} error |
| 380 * @private | 380 * @private |
| 381 */ | 381 */ |
| 382 remoting.SessionConnectorImpl.prototype.pluginError_ = function(error) { | 382 remoting.SessionConnectorImpl.prototype.pluginError_ = function(error) { |
| 383 this.signalStrategy_.setIncomingStanzaCallback(null); | 383 this.signalStrategy_.setIncomingStanzaCallback(null); |
| 384 this.clientSession_.disconnect(error); | 384 this.clientSession_.disconnect(error); |
| 385 this.removePlugin_(); | 385 this.closeSession(); |
| 386 }; | 386 }; |
| 387 | 387 |
| 388 /** @private */ | 388 remoting.SessionConnectorImpl.prototype.closeSession = function() { |
| 389 remoting.SessionConnectorImpl.prototype.removePlugin_ = function() { | 389 base.dispose(this.clientSession_); |
| 390 if (this.clientSession_) { | |
| 391 this.clientSession_.removePlugin(); | |
| 392 } | |
| 393 this.clientSession_ = null; | 390 this.clientSession_ = null; |
| 394 remoting.clientSession = null; | 391 remoting.clientSession = null; |
| 395 | 392 |
| 396 base.dispose(this.connectedView_); | 393 base.dispose(this.connectedView_); |
| 397 this.connectedView_ = null; | 394 this.connectedView_ = null; |
| 398 remoting.desktopConnectedView = null; | 395 remoting.desktopConnectedView = null; |
| 399 | 396 |
| 400 base.dispose(this.plugin_); | 397 base.dispose(this.plugin_); |
| 401 this.plugin_ = null; | 398 this.plugin_ = null; |
| 402 }; | 399 }; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 */ | 584 */ |
| 588 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 585 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
| 589 function(clientContainer, onConnected, onError, | 586 function(clientContainer, onConnected, onError, |
| 590 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { | 587 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
| 591 return new remoting.SessionConnectorImpl(clientContainer, onConnected, | 588 return new remoting.SessionConnectorImpl(clientContainer, onConnected, |
| 592 onError, | 589 onError, |
| 593 onConnectionFailed, | 590 onConnectionFailed, |
| 594 requiredCapabilities, | 591 requiredCapabilities, |
| 595 defaultRemapKeys); | 592 defaultRemapKeys); |
| 596 }; | 593 }; |
| OLD | NEW |