Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: remoting/webapp/me2mom/log_to_server.js

Issue 9139023: Enable logging from the client to the cloud. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 10 matching lines...) Expand all
21 /** @type {remoting.StatsAccumulator} */ 21 /** @type {remoting.StatsAccumulator} */
22 this.statsAccumulator = new remoting.StatsAccumulator(); 22 this.statsAccumulator = new remoting.StatsAccumulator();
23 /** @type string */ 23 /** @type string */
24 this.sessionId = ''; 24 this.sessionId = '';
25 /** @type number */ 25 /** @type number */
26 this.sessionIdGenerationTime = 0; 26 this.sessionIdGenerationTime = 0;
27 /** @type number */ 27 /** @type number */
28 this.sessionStartTime = 0; 28 this.sessionStartTime = 0;
29 }; 29 };
30 30
31 // Local storage key.
32 /** @private */
33 remoting.LogToServer.KEY_ENABLED_ = 'remoting.LogToServer.enabled';
34
35 // Constants used for generating a session ID. 31 // Constants used for generating a session ID.
36 /** @private */ 32 /** @private */
37 remoting.LogToServer.SESSION_ID_ALPHABET_ = 33 remoting.LogToServer.SESSION_ID_ALPHABET_ =
38 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; 34 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
39 /** @private */ 35 /** @private */
40 remoting.LogToServer.SESSION_ID_LEN_ = 20; 36 remoting.LogToServer.SESSION_ID_LEN_ = 20;
41 37
42 // The maximum age of a session ID, in milliseconds. 38 // The maximum age of a session ID, in milliseconds.
43 remoting.LogToServer.MAX_SESSION_ID_AGE = 24 * 60 * 60 * 1000; 39 remoting.LogToServer.MAX_SESSION_ID_AGE = 24 * 60 * 60 * 1000;
44 40
45 // The time over which to accumulate connection statistics before logging them 41 // The time over which to accumulate connection statistics before logging them
46 // to the server, in milliseconds. 42 // to the server, in milliseconds.
47 remoting.LogToServer.CONNECTION_STATS_ACCUMULATE_TIME = 60 * 1000; 43 remoting.LogToServer.CONNECTION_STATS_ACCUMULATE_TIME = 60 * 1000;
48 44
49 /** 45 /**
50 * Enables or disables logging.
51 *
52 * @param {boolean} enabled whether logging is enabled
53 */
54 remoting.LogToServer.prototype.setEnabled = function(enabled) {
55 window.localStorage.setItem(remoting.LogToServer.KEY_ENABLED_,
56 enabled ? 'true' : 'false');
57 }
58
59 /**
60 * Logs a client session state change. 46 * Logs a client session state change.
61 * 47 *
62 * @param {remoting.ClientSession.State} state 48 * @param {remoting.ClientSession.State} state
63 * @param {remoting.ClientSession.ConnectionError} connectionError 49 * @param {remoting.ClientSession.ConnectionError} connectionError
64 */ 50 */
65 remoting.LogToServer.prototype.logClientSessionStateChange = 51 remoting.LogToServer.prototype.logClientSessionStateChange =
66 function(state, connectionError) { 52 function(state, connectionError) {
67 this.maybeExpireSessionId(); 53 this.maybeExpireSessionId();
68 // Maybe set the session ID and start time. 54 // Maybe set the session ID and start time.
69 if (remoting.LogToServer.isStartOfSession(state)) { 55 if (remoting.LogToServer.isStartOfSession(state)) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 remoting.wcs.sendIq(stanza); 179 remoting.wcs.sendIq(stanza);
194 }; 180 };
195 181
196 /** 182 /**
197 * Whether logging is enabled. 183 * Whether logging is enabled.
198 * 184 *
199 * @private 185 * @private
200 * @return {boolean} whether logging is enabled 186 * @return {boolean} whether logging is enabled
201 */ 187 */
202 remoting.LogToServer.prototype.isEnabled = function() { 188 remoting.LogToServer.prototype.isEnabled = function() {
203 var value = window.localStorage.getItem(remoting.LogToServer.KEY_ENABLED_); 189 return true;
Jamie 2012/01/11 20:52:51 Is it worth keeping isEnabled at all? The only rea
simonmorris 2012/01/11 21:23:34 Done.
204 return (value == 'true');
205 }; 190 };
206 191
207 /** 192 /**
208 * Sets the session ID to a random string. 193 * Sets the session ID to a random string.
209 * 194 *
210 * @private 195 * @private
211 */ 196 */
212 remoting.LogToServer.prototype.setSessionId = function() { 197 remoting.LogToServer.prototype.setSessionId = function() {
213 this.sessionId = remoting.LogToServer.generateSessionId(); 198 this.sessionId = remoting.LogToServer.generateSessionId();
214 this.sessionIdGenerationTime = new Date().getTime(); 199 this.sessionIdGenerationTime = new Date().getTime();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 remoting.LogToServer.generateSessionId = function() { 241 remoting.LogToServer.generateSessionId = function() {
257 var idArray = []; 242 var idArray = [];
258 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) { 243 for (var i = 0; i < remoting.LogToServer.SESSION_ID_LEN_; i++) {
259 var index = 244 var index =
260 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length; 245 Math.random() * remoting.LogToServer.SESSION_ID_ALPHABET_.length;
261 idArray.push( 246 idArray.push(
262 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1)); 247 remoting.LogToServer.SESSION_ID_ALPHABET_.slice(index, index + 1));
263 } 248 }
264 return idArray.join(''); 249 return idArray.join('');
265 }; 250 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698