| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Reset the per-connection state so that the object can be re-used for a | 91 * Reset the per-connection state so that the object can be re-used for a |
| 92 * second connection. Note the none of the shared WCS state is reset. | 92 * second connection. Note the none of the shared WCS state is reset. |
| 93 * @private | 93 * @private |
| 94 */ | 94 */ |
| 95 remoting.SessionConnectorImpl.prototype.resetConnection_ = function() { | 95 remoting.SessionConnectorImpl.prototype.resetConnection_ = function() { |
| 96 this.removePlugin_(); | 96 this.removePlugin_(); |
| 97 | 97 |
| 98 // It's OK to initialize these member variables here because the |
| 99 // constructor calls this method. |
| 100 |
| 98 /** @private {remoting.Host} */ | 101 /** @private {remoting.Host} */ |
| 99 this.host_ = null; | 102 this.host_ = null; |
| 100 | 103 |
| 101 /** @private {boolean} */ | 104 /** @private {boolean} */ |
| 102 this.logHostOfflineErrors_ = false; | 105 this.logHostOfflineErrors_ = false; |
| 103 | 106 |
| 104 /** @private {remoting.ClientPlugin} */ | 107 /** @private {remoting.ClientPlugin} */ |
| 105 this.plugin_ = null; | 108 this.plugin_ = null; |
| 106 | 109 |
| 107 /** @private {remoting.ClientSession} */ | 110 /** @private {remoting.ClientSession} */ |
| 108 this.clientSession_ = null; | 111 this.clientSession_ = null; |
| 109 | 112 |
| 110 /** @private {remoting.DesktopConnectedView} */ | 113 /** @private {remoting.DesktopConnectedView} */ |
| 111 this.connectedView_ = null; | 114 this.connectedView_ = null; |
| 112 | 115 |
| 113 /** @private {XMLHttpRequest} */ | |
| 114 this.pendingXhr_ = null; | |
| 115 | |
| 116 /** @private {remoting.CredentialsProvider} */ | 116 /** @private {remoting.CredentialsProvider} */ |
| 117 this.credentialsProvider_ = null; | 117 this.credentialsProvider_ = null; |
| 118 | 118 |
| 119 /** @private {Object<string,remoting.ProtocolExtension>} */ | 119 /** @private {Object<string,remoting.ProtocolExtension>} */ |
| 120 this.protocolExtensions_ = {}; | 120 this.protocolExtensions_ = {}; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * Initiate a Me2Me connection. | 124 * Initiate a Me2Me connection. |
| 125 * | 125 * |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 /** | 339 /** |
| 340 * @param {boolean} initialized | 340 * @param {boolean} initialized |
| 341 * @private | 341 * @private |
| 342 */ | 342 */ |
| 343 remoting.SessionConnectorImpl.prototype.onPluginInitialized_ = function( | 343 remoting.SessionConnectorImpl.prototype.onPluginInitialized_ = function( |
| 344 initialized) { | 344 initialized) { |
| 345 if (!initialized) { | 345 if (!initialized) { |
| 346 console.error('ERROR: remoting plugin not loaded'); | 346 console.error('ERROR: remoting plugin not loaded'); |
| 347 this.pluginError_(remoting.Error.MISSING_PLUGIN); | 347 this.pluginError_(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); |
| 348 return; | 348 return; |
| 349 } | 349 } |
| 350 | 350 |
| 351 if (!this.plugin_.isSupportedVersion()) { | 351 if (!this.plugin_.isSupportedVersion()) { |
| 352 console.error('ERROR: bad plugin version'); | 352 console.error('ERROR: bad plugin version'); |
| 353 this.pluginError_(remoting.Error.BAD_PLUGIN_VERSION); | 353 this.pluginError_(new remoting.Error( |
| 354 remoting.Error.Tag.BAD_PLUGIN_VERSION)); |
| 354 return; | 355 return; |
| 355 } | 356 } |
| 356 | 357 |
| 357 this.clientSession_ = new remoting.ClientSession( | 358 this.clientSession_ = new remoting.ClientSession( |
| 358 this.plugin_, this.host_, this.signalStrategy_, this.connectionMode_, | 359 this.plugin_, this.host_, this.signalStrategy_, this.connectionMode_, |
| 359 this.onProtocolExtensionMessage_.bind(this)); | 360 this.onProtocolExtensionMessage_.bind(this)); |
| 360 remoting.clientSession = this.clientSession_; | 361 remoting.clientSession = this.clientSession_; |
| 361 | 362 |
| 362 this.connectedView_ = new remoting.DesktopConnectedView( | 363 this.connectedView_ = new remoting.DesktopConnectedView( |
| 363 this.plugin_, this.clientContainer_, this.host_, | 364 this.plugin_, this.clientContainer_, this.host_, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 break; | 500 break; |
| 500 | 501 |
| 501 case remoting.ClientSession.State.CLOSED: | 502 case remoting.ClientSession.State.CLOSED: |
| 502 // This class deregisters for state-change callbacks when the CONNECTED | 503 // This class deregisters for state-change callbacks when the CONNECTED |
| 503 // state is reached, so it only sees the CLOSED state in exceptional | 504 // state is reached, so it only sees the CLOSED state in exceptional |
| 504 // circumstances. For example, a CONNECTING -> CLOSED transition happens | 505 // circumstances. For example, a CONNECTING -> CLOSED transition happens |
| 505 // if the host closes the connection without an error message instead of | 506 // if the host closes the connection without an error message instead of |
| 506 // accepting it. Since there's no way of knowing exactly what went wrong, | 507 // accepting it. Since there's no way of knowing exactly what went wrong, |
| 507 // we rely on server-side logs in this case and report a generic error | 508 // we rely on server-side logs in this case and report a generic error |
| 508 // message. | 509 // message. |
| 509 this.onError_(remoting.Error.UNEXPECTED); | 510 this.onError_(remoting.Error.unexpected()); |
| 510 break; | 511 break; |
| 511 | 512 |
| 512 case remoting.ClientSession.State.FAILED: | 513 case remoting.ClientSession.State.FAILED: |
| 513 var error = this.clientSession_.getError(); | 514 var error = this.clientSession_.getError(); |
| 514 console.error('Client plugin reported connection failed: ' + error); | 515 console.error('Client plugin reported connection failed: ' + |
| 516 error.toString()); |
| 515 if (error == null) { | 517 if (error == null) { |
| 516 error = remoting.Error.UNEXPECTED; | 518 error = remoting.Error.unexpected(); |
| 517 } | 519 } |
| 518 this.onConnectionFailed_(error); | 520 this.onConnectionFailed_(error); |
| 519 break; | 521 break; |
| 520 | 522 |
| 521 default: | 523 default: |
| 522 console.error('Unexpected client plugin state: ' + event.current); | 524 console.error('Unexpected client plugin state: ' + event.current); |
| 523 // This should only happen if the web-app and client plugin get out of | 525 // This should only happen if the web-app and client plugin get out of |
| 524 // sync, and even then the version check should ensure compatibility. | 526 // sync, and even then the version check should ensure compatibility. |
| 525 this.onError_(remoting.Error.MISSING_PLUGIN); | 527 this.onError_(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); |
| 526 } | 528 } |
| 527 }; | 529 }; |
| 528 | 530 |
| 529 /** | 531 /** |
| 530 * @constructor | 532 * @constructor |
| 531 * @implements {remoting.SessionConnectorFactory} | 533 * @implements {remoting.SessionConnectorFactory} |
| 532 */ | 534 */ |
| 533 remoting.DefaultSessionConnectorFactory = function() {}; | 535 remoting.DefaultSessionConnectorFactory = function() {}; |
| 534 | 536 |
| 535 /** | 537 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 552 function(clientContainer, onConnected, onError, | 554 function(clientContainer, onConnected, onError, |
| 553 appProtocolExtensionHandler, | 555 appProtocolExtensionHandler, |
| 554 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { | 556 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
| 555 return new remoting.SessionConnectorImpl(clientContainer, onConnected, | 557 return new remoting.SessionConnectorImpl(clientContainer, onConnected, |
| 556 onError, | 558 onError, |
| 557 appProtocolExtensionHandler, | 559 appProtocolExtensionHandler, |
| 558 onConnectionFailed, | 560 onConnectionFailed, |
| 559 requiredCapabilities, | 561 requiredCapabilities, |
| 560 defaultRemapKeys); | 562 defaultRemapKeys); |
| 561 }; | 563 }; |
| OLD | NEW |