| 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 13 matching lines...) Expand all Loading... |
| 24 /** @private */ | 24 /** @private */ |
| 25 this.sessionIdGenerationTime_ = 0; | 25 this.sessionIdGenerationTime_ = 0; |
| 26 /** @private */ | 26 /** @private */ |
| 27 this.sessionStartTime_ = new Date().getTime(); | 27 this.sessionStartTime_ = new Date().getTime(); |
| 28 /** @private */ | 28 /** @private */ |
| 29 this.signalStrategy_ = signalStrategy; | 29 this.signalStrategy_ = signalStrategy; |
| 30 /** @private {string} */ | 30 /** @private {string} */ |
| 31 this.connectionType_ = ''; | 31 this.connectionType_ = ''; |
| 32 /** @private */ | 32 /** @private */ |
| 33 this.authTotalTime_ = 0; | 33 this.authTotalTime_ = 0; |
| 34 /** @private {string} */ |
| 35 this.hostVersion_ = ''; |
| 34 | 36 |
| 35 this.setSessionId_(); | 37 this.setSessionId_(); |
| 36 signalStrategy.sendConnectionSetupResults(this); | 38 signalStrategy.sendConnectionSetupResults(this); |
| 37 }; | 39 }; |
| 38 | 40 |
| 39 // Constants used for generating a session ID. | 41 // Constants used for generating a session ID. |
| 40 /** @private */ | 42 /** @private */ |
| 41 remoting.LogToServer.SESSION_ID_ALPHABET_ = | 43 remoting.LogToServer.SESSION_ID_ALPHABET_ = |
| 42 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; | 44 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; |
| 43 /** @private */ | 45 /** @private */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 * | 57 * |
| 56 * @param {remoting.ClientSession.State} state | 58 * @param {remoting.ClientSession.State} state |
| 57 * @param {!remoting.Error} connectionError | 59 * @param {!remoting.Error} connectionError |
| 58 */ | 60 */ |
| 59 remoting.LogToServer.prototype.logClientSessionStateChange = | 61 remoting.LogToServer.prototype.logClientSessionStateChange = |
| 60 function(state, connectionError) { | 62 function(state, connectionError) { |
| 61 this.maybeExpireSessionId_(); | 63 this.maybeExpireSessionId_(); |
| 62 // Log the session state change. | 64 // Log the session state change. |
| 63 var entry = remoting.ServerLogEntry.makeClientSessionStateChange( | 65 var entry = remoting.ServerLogEntry.makeClientSessionStateChange( |
| 64 state, connectionError); | 66 state, connectionError); |
| 65 entry.addHostFields(); | 67 entry.addClientOSFields(); |
| 66 entry.addChromeVersionField(); | 68 entry.addChromeVersionField(); |
| 67 entry.addWebappVersionField(); | 69 entry.addWebappVersionField(); |
| 68 entry.addSessionIdField(this.sessionId_); | 70 entry.addSessionIdField(this.sessionId_); |
| 69 this.log_(entry); | 71 this.log_(entry); |
| 70 // Don't accumulate connection statistics across state changes. | 72 // Don't accumulate connection statistics across state changes. |
| 71 this.logAccumulatedStatistics_(); | 73 this.logAccumulatedStatistics_(); |
| 72 this.statsAccumulator_.empty(); | 74 this.statsAccumulator_.empty(); |
| 73 // Maybe clear the session ID. | 75 // Maybe clear the session ID. |
| 74 if (remoting.LogToServer.isEndOfSession_(state)) { | 76 if (remoting.LogToServer.isEndOfSession_(state)) { |
| 75 this.clearSessionId_(); | 77 this.clearSessionId_(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 * | 151 * |
| 150 * If all the statistics are zero, then the accumulator is still emptied, | 152 * If all the statistics are zero, then the accumulator is still emptied, |
| 151 * but the statistics are not sent to the log server. | 153 * but the statistics are not sent to the log server. |
| 152 * | 154 * |
| 153 * @private | 155 * @private |
| 154 */ | 156 */ |
| 155 remoting.LogToServer.prototype.logAccumulatedStatistics_ = function() { | 157 remoting.LogToServer.prototype.logAccumulatedStatistics_ = function() { |
| 156 var entry = remoting.ServerLogEntry.makeStats(this.statsAccumulator_, | 158 var entry = remoting.ServerLogEntry.makeStats(this.statsAccumulator_, |
| 157 this.connectionType_); | 159 this.connectionType_); |
| 158 if (entry) { | 160 if (entry) { |
| 159 entry.addHostFields(); | 161 entry.addClientOSFields(); |
| 160 entry.addChromeVersionField(); | 162 entry.addChromeVersionField(); |
| 161 entry.addWebappVersionField(); | 163 entry.addWebappVersionField(); |
| 162 entry.addSessionIdField(this.sessionId_); | 164 entry.addSessionIdField(this.sessionId_); |
| 163 this.log_(entry); | 165 this.log_(entry); |
| 164 } | 166 } |
| 165 this.statsAccumulator_.empty(); | 167 this.statsAccumulator_.empty(); |
| 166 }; | 168 }; |
| 167 | 169 |
| 168 /** | 170 /** |
| 169 * Sends a log entry to the server. | 171 * Sends a log entry to the server. |
| 170 * | 172 * |
| 171 * @private | 173 * @private |
| 172 * @param {remoting.ServerLogEntry} entry | 174 * @param {remoting.ServerLogEntry} entry |
| 173 */ | 175 */ |
| 174 remoting.LogToServer.prototype.log_ = function(entry) { | 176 remoting.LogToServer.prototype.log_ = function(entry) { |
| 175 // Log the time taken to get to this point from the time this session started. | 177 // Log the time taken to get to this point from the time this session started. |
| 176 // Exclude time taken for authorization. | 178 // Exclude time taken for authorization. |
| 177 var sessionDurationInSeconds = | 179 var sessionDurationInSeconds = |
| 178 (new Date().getTime() - this.sessionStartTime_ - | 180 (new Date().getTime() - this.sessionStartTime_ - |
| 179 this.authTotalTime_) / 1000.0; | 181 this.authTotalTime_) / 1000.0; |
| 180 entry.addSessionDuration(sessionDurationInSeconds); | 182 entry.addSessionDuration(sessionDurationInSeconds); |
| 183 // The host-version will be blank for logs before a session has been created. |
| 184 // For example, the signal-strategy log-entries won't have host version info. |
| 185 entry.addHostVersion(this.hostVersion_); |
| 181 | 186 |
| 182 // Send the stanza to the debug log. | 187 // Send the stanza to the debug log. |
| 183 console.log('Enqueueing log entry:'); | 188 console.log('Enqueueing log entry:'); |
| 184 entry.toDebugLog(1); | 189 entry.toDebugLog(1); |
| 185 | 190 |
| 186 var stanza = '<cli:iq to="' + remoting.settings.DIRECTORY_BOT_JID + '" ' + | 191 var stanza = '<cli:iq to="' + remoting.settings.DIRECTORY_BOT_JID + '" ' + |
| 187 'type="set" xmlns:cli="jabber:client">' + | 192 'type="set" xmlns:cli="jabber:client">' + |
| 188 '<gr:log xmlns:gr="google:remoting">' + | 193 '<gr:log xmlns:gr="google:remoting">' + |
| 189 entry.toStanza() + | 194 entry.toStanza() + |
| 190 '</gr:log>' + | 195 '</gr:log>' + |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 }; | 258 }; |
| 254 | 259 |
| 255 /** | 260 /** |
| 256 * @param {number} totalTime The value of time taken to complete authorization. | 261 * @param {number} totalTime The value of time taken to complete authorization. |
| 257 * @return {void} Nothing. | 262 * @return {void} Nothing. |
| 258 */ | 263 */ |
| 259 remoting.LogToServer.prototype.setAuthTotalTime = function(totalTime) { | 264 remoting.LogToServer.prototype.setAuthTotalTime = function(totalTime) { |
| 260 this.authTotalTime_ = totalTime; | 265 this.authTotalTime_ = totalTime; |
| 261 }; | 266 }; |
| 262 | 267 |
| 268 /** |
| 269 * @param {string} hostVersion Version of the host for current session. |
| 270 * @return {void} Nothing. |
| 271 */ |
| 272 remoting.LogToServer.prototype.setHostVersion = function(hostVersion) { |
| 273 this.hostVersion_ = hostVersion; |
| 274 }; |
| 275 |
| OLD | NEW |