| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Module for sending log entries to the server. | 7 * Module for sending log entries to the server. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 remoting.LogToServer.shouldAddDuration_ = function(state) { | 153 remoting.LogToServer.shouldAddDuration_ = function(state) { |
| 154 // Duration is added to log entries at the end of the session, as well as at | 154 // Duration is added to log entries at the end of the session, as well as at |
| 155 // some intermediate states where it is relevant (e.g. to determine how long | 155 // some intermediate states where it is relevant (e.g. to determine how long |
| 156 // it took for a session to become CONNECTED). | 156 // it took for a session to become CONNECTED). |
| 157 return (remoting.LogToServer.isEndOfSession_(state) || | 157 return (remoting.LogToServer.isEndOfSession_(state) || |
| 158 (state == remoting.ClientSession.State.CONNECTED)); | 158 (state == remoting.ClientSession.State.CONNECTED)); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * Logs connection statistics. | 162 * Logs connection statistics. |
| 163 * @param {Object.<string, number>} stats The connection statistics | 163 * @param {Object<string, number>} stats The connection statistics |
| 164 */ | 164 */ |
| 165 remoting.LogToServer.prototype.logStatistics = function(stats) { | 165 remoting.LogToServer.prototype.logStatistics = function(stats) { |
| 166 this.maybeExpireSessionId_(); | 166 this.maybeExpireSessionId_(); |
| 167 // Store the statistics. | 167 // Store the statistics. |
| 168 this.statsAccumulator_.add(stats); | 168 this.statsAccumulator_.add(stats); |
| 169 // Send statistics to the server if they've been accumulating for at least | 169 // Send statistics to the server if they've been accumulating for at least |
| 170 // 60 seconds. | 170 // 60 seconds. |
| 171 if (this.statsAccumulator_.getTimeSinceFirstValue() >= | 171 if (this.statsAccumulator_.getTimeSinceFirstValue() >= |
| 172 remoting.LogToServer.CONNECTION_STATS_ACCUMULATE_TIME) { | 172 remoting.LogToServer.CONNECTION_STATS_ACCUMULATE_TIME) { |
| 173 this.logAccumulatedStatistics_(); | 173 this.logAccumulatedStatistics_(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 remoting.LogToServer.generateSessionId_ = function() { | 270 remoting.LogToServer.generateSessionId_ = function() { |
| 271 var idArray = []; | 271 var idArray = []; |
| 272 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) { | 272 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) { |
| 273 var index = | 273 var index = |
| 274 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length; | 274 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length; |
| 275 idArray.push( | 275 idArray.push( |
| 276 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1)); | 276 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1)); |
| 277 } | 277 } |
| 278 return idArray.join(''); | 278 return idArray.join(''); |
| 279 }; | 279 }; |
| OLD | NEW |