Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 /** @private {string} */ | 67 /** @private {string} */ |
| 68 this.username_ = ''; | 68 this.username_ = ''; |
| 69 | 69 |
| 70 /** @private {string} */ | 70 /** @private {string} */ |
| 71 this.authToken_ = ''; | 71 this.authToken_ = ''; |
| 72 | 72 |
| 73 /** @private {number} */ | 73 /** @private {number} */ |
| 74 this.primaryConnectTimerId_ = 0; | 74 this.primaryConnectTimerId_ = 0; |
| 75 | 75 |
| 76 /** @private {remoting.Logger} */ | 76 /** @private {remoting.Logger} */ |
| 77 this.logger_ = null; | 77 this.logger_ = new remoting.SessionLogger( |
| 78 remoting.ChromotingEvent.Role.CLIENT, | |
| 79 remoting.TelemetryEventWriter.Client.write | |
| 80 ); | |
| 78 | 81 |
| 79 /** | 82 /** |
| 80 * @type {Array<{strategyType: remoting.SignalStrategy.Type, | 83 * @type {Array<{strategyType: remoting.SignalStrategy.Type, |
| 81 progress: remoting.FallbackSignalStrategy.Progress}>} | 84 progress: remoting.FallbackSignalStrategy.Progress}>} |
| 82 */ | 85 */ |
| 83 this.connectionSetupResults_ = []; | 86 this.connectionSetupResults_ = []; |
| 84 | 87 |
| 85 }; | 88 }; |
| 86 | 89 |
| 87 /** | 90 /** |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 }; | 151 }; |
| 149 | 152 |
| 150 /** | 153 /** |
| 151 * Sends a message. Can be called only in CONNECTED state. | 154 * Sends a message. Can be called only in CONNECTED state. |
| 152 * @param {string} message | 155 * @param {string} message |
| 153 */ | 156 */ |
| 154 remoting.FallbackSignalStrategy.prototype.sendMessage = function(message) { | 157 remoting.FallbackSignalStrategy.prototype.sendMessage = function(message) { |
| 155 this.getConnectedSignalStrategy_().sendMessage(message); | 158 this.getConnectedSignalStrategy_().sendMessage(message); |
| 156 }; | 159 }; |
| 157 | 160 |
| 158 /** | |
| 159 * Send any messages accumulated during connection set-up. | |
| 160 * | |
| 161 * @param {remoting.Logger} logToServer The Logger instance for the | |
| 162 * connection. | |
| 163 */ | |
| 164 remoting.FallbackSignalStrategy.prototype.sendConnectionSetupResults = | |
| 165 function(logToServer) { | |
| 166 this.logger_ = logToServer; | |
| 167 this.sendConnectionSetupResultsInternal_(); | |
| 168 } | |
| 169 | |
| 170 remoting.FallbackSignalStrategy.prototype.sendConnectionSetupResultsInternal_ = | |
| 171 function() { | |
| 172 for (var i = 0; i < this.connectionSetupResults_.length; ++i) { | |
| 173 var result = this.connectionSetupResults_[i]; | |
| 174 this.logger_.logSignalStrategyProgress(result.strategyType, | |
| 175 result.progress); | |
| 176 } | |
| 177 this.connectionSetupResults_ = []; | |
| 178 }; | |
| 179 | |
| 180 /** @return {remoting.SignalStrategy.State} Current state */ | 161 /** @return {remoting.SignalStrategy.State} Current state */ |
| 181 remoting.FallbackSignalStrategy.prototype.getState = function() { | 162 remoting.FallbackSignalStrategy.prototype.getState = function() { |
| 182 return (this.externalState_ === null) | 163 return (this.externalState_ === null) |
| 183 ? remoting.SignalStrategy.State.NOT_CONNECTED | 164 ? remoting.SignalStrategy.State.NOT_CONNECTED |
| 184 : this.externalState_; | 165 : this.externalState_; |
| 185 }; | 166 }; |
| 186 | 167 |
| 187 /** @return {!remoting.Error} Error when in FAILED state. */ | 168 /** @return {!remoting.Error} Error when in FAILED state. */ |
| 188 remoting.FallbackSignalStrategy.prototype.getError = function() { | 169 remoting.FallbackSignalStrategy.prototype.getError = function() { |
| 189 console.assert(this.state_ == this.State.SECONDARY_FAILED, | 170 console.assert(this.state_ == this.State.SECONDARY_FAILED, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 | 331 |
| 351 /** | 332 /** |
| 352 * @param {remoting.SignalStrategy} strategy | 333 * @param {remoting.SignalStrategy} strategy |
| 353 * @param {remoting.FallbackSignalStrategy.Progress} progress | 334 * @param {remoting.FallbackSignalStrategy.Progress} progress |
| 354 * @private | 335 * @private |
| 355 */ | 336 */ |
| 356 remoting.FallbackSignalStrategy.prototype.updateProgress_ = function( | 337 remoting.FallbackSignalStrategy.prototype.updateProgress_ = function( |
| 357 strategy, progress) { | 338 strategy, progress) { |
| 358 console.log('FallbackSignalStrategy progress: ' + strategy.getType() + ' ' + | 339 console.log('FallbackSignalStrategy progress: ' + strategy.getType() + ' ' + |
| 359 progress); | 340 progress); |
| 360 this.connectionSetupResults_.push({ | 341 this.logger_.logSignalStrategyProgress(strategy.getType(), progress); |
|
Jamie
2015/08/14 20:48:00
Right now, this causes errors in the background pa
kelvinp
2015/08/14 21:59:54
I think it is ok to ignore them in the short term
| |
| 361 'strategyType': strategy.getType(), | |
| 362 'progress': progress | |
| 363 }); | |
| 364 if (this.logger_) { | |
| 365 this.sendConnectionSetupResultsInternal_(); | |
| 366 } | |
| 367 }; | 342 }; |
| OLD | NEW |