| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 10 /** |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 */ | 110 */ |
| 111 this.logToServer_ = null; | 111 this.logToServer_ = null; |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * @type {Array<{strategyType: remoting.SignalStrategy.Type, | 114 * @type {Array<{strategyType: remoting.SignalStrategy.Type, |
| 115 progress: remoting.FallbackSignalStrategy.Progress, | 115 progress: remoting.FallbackSignalStrategy.Progress, |
| 116 * elapsed: number}>} | 116 * elapsed: number}>} |
| 117 */ | 117 */ |
| 118 this.connectionSetupResults_ = []; | 118 this.connectionSetupResults_ = []; |
| 119 | 119 |
| 120 /** | |
| 121 * @type {number} | |
| 122 * @private | |
| 123 */ | |
| 124 this.startTime_ = 0; | |
| 125 }; | 120 }; |
| 126 | 121 |
| 127 /** | 122 /** |
| 128 * @enum {string} | 123 * @enum {string} |
| 129 */ | 124 */ |
| 130 remoting.FallbackSignalStrategy.Progress = { | 125 remoting.FallbackSignalStrategy.Progress = { |
| 131 SUCCEEDED: 'succeeded', | 126 SUCCEEDED: 'succeeded', |
| 132 FAILED: 'failed', | 127 FAILED: 'failed', |
| 133 TIMED_OUT: 'timed-out', | 128 TIMED_OUT: 'timed-out', |
| 134 SUCCEEDED_LATE: 'succeeded-late', | 129 SUCCEEDED_LATE: 'succeeded-late', |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 * @param {string} authToken | 166 * @param {string} authToken |
| 172 */ | 167 */ |
| 173 remoting.FallbackSignalStrategy.prototype.connect = | 168 remoting.FallbackSignalStrategy.prototype.connect = |
| 174 function(server, username, authToken) { | 169 function(server, username, authToken) { |
| 175 base.debug.assert(this.state_ == this.State.NOT_CONNECTED); | 170 base.debug.assert(this.state_ == this.State.NOT_CONNECTED); |
| 176 base.debug.assert(this.onStateChangedCallback_ != null); | 171 base.debug.assert(this.onStateChangedCallback_ != null); |
| 177 this.server_ = server; | 172 this.server_ = server; |
| 178 this.username_ = username; | 173 this.username_ = username; |
| 179 this.authToken_ = authToken; | 174 this.authToken_ = authToken; |
| 180 this.state_ = this.State.PRIMARY_PENDING; | 175 this.state_ = this.State.PRIMARY_PENDING; |
| 181 this.startTime_ = new Date().getTime(); | |
| 182 this.primary_.setIncomingStanzaCallback(this.onIncomingStanzaCallback_); | 176 this.primary_.setIncomingStanzaCallback(this.onIncomingStanzaCallback_); |
| 183 this.primary_.connect(server, username, authToken); | 177 this.primary_.connect(server, username, authToken); |
| 184 this.primaryConnectTimerId_ = | 178 this.primaryConnectTimerId_ = |
| 185 window.setTimeout(this.onPrimaryTimeout_.bind(this), | 179 window.setTimeout(this.onPrimaryTimeout_.bind(this), |
| 186 this.PRIMARY_CONNECT_TIMEOUT_MS_); | 180 this.PRIMARY_CONNECT_TIMEOUT_MS_); |
| 187 }; | 181 }; |
| 188 | 182 |
| 189 /** | 183 /** |
| 190 * Sends a message. Can be called only in CONNECTED state. | 184 * Sends a message. Can be called only in CONNECTED state. |
| 191 * @param {string} message | 185 * @param {string} message |
| (...skipping 12 matching lines...) Expand all Loading... |
| 204 function(logToServer) { | 198 function(logToServer) { |
| 205 this.logToServer_ = logToServer; | 199 this.logToServer_ = logToServer; |
| 206 this.sendConnectionSetupResultsInternal_(); | 200 this.sendConnectionSetupResultsInternal_(); |
| 207 } | 201 } |
| 208 | 202 |
| 209 remoting.FallbackSignalStrategy.prototype.sendConnectionSetupResultsInternal_ = | 203 remoting.FallbackSignalStrategy.prototype.sendConnectionSetupResultsInternal_ = |
| 210 function() { | 204 function() { |
| 211 for (var i = 0; i < this.connectionSetupResults_.length; ++i) { | 205 for (var i = 0; i < this.connectionSetupResults_.length; ++i) { |
| 212 var result = this.connectionSetupResults_[i]; | 206 var result = this.connectionSetupResults_[i]; |
| 213 this.logToServer_.logSignalStrategyProgress(result.strategyType, | 207 this.logToServer_.logSignalStrategyProgress(result.strategyType, |
| 214 result.progress, | 208 result.progress); |
| 215 result.elapsed); | |
| 216 } | 209 } |
| 217 this.connectionSetupResults_ = []; | 210 this.connectionSetupResults_ = []; |
| 218 }; | 211 }; |
| 219 | 212 |
| 220 /** @return {remoting.SignalStrategy.State} Current state */ | 213 /** @return {remoting.SignalStrategy.State} Current state */ |
| 221 remoting.FallbackSignalStrategy.prototype.getState = function() { | 214 remoting.FallbackSignalStrategy.prototype.getState = function() { |
| 222 return (this.externalState_ === null) | 215 return (this.externalState_ === null) |
| 223 ? remoting.SignalStrategy.State.NOT_CONNECTED | 216 ? remoting.SignalStrategy.State.NOT_CONNECTED |
| 224 : this.externalState_; | 217 : this.externalState_; |
| 225 }; | 218 }; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 * @param {remoting.SignalStrategy} strategy | 377 * @param {remoting.SignalStrategy} strategy |
| 385 * @param {remoting.FallbackSignalStrategy.Progress} progress | 378 * @param {remoting.FallbackSignalStrategy.Progress} progress |
| 386 * @private | 379 * @private |
| 387 */ | 380 */ |
| 388 remoting.FallbackSignalStrategy.prototype.updateProgress_ = function( | 381 remoting.FallbackSignalStrategy.prototype.updateProgress_ = function( |
| 389 strategy, progress) { | 382 strategy, progress) { |
| 390 console.log('FallbackSignalStrategy progress: ' + strategy.getType() + ' ' + | 383 console.log('FallbackSignalStrategy progress: ' + strategy.getType() + ' ' + |
| 391 progress); | 384 progress); |
| 392 this.connectionSetupResults_.push({ | 385 this.connectionSetupResults_.push({ |
| 393 'strategyType': strategy.getType(), | 386 'strategyType': strategy.getType(), |
| 394 'progress': progress, | 387 'progress': progress |
| 395 'elapsed': new Date().getTime() - this.startTime_ | |
| 396 }); | 388 }); |
| 397 if (this.logToServer_) { | 389 if (this.logToServer_) { |
| 398 this.sendConnectionSetupResultsInternal_(); | 390 this.sendConnectionSetupResultsInternal_(); |
| 399 } | 391 } |
| 400 }; | 392 }; |
| OLD | NEW |