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

Unified Diff: remoting/webapp/me2mom/log_to_server.js

Issue 8865005: The chromoting client logs connection statistics to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/me2mom/log_to_server.js
diff --git a/remoting/webapp/me2mom/log_to_server.js b/remoting/webapp/me2mom/log_to_server.js
index 017bc1afe21c0ce4816f1a8d4fcb05803e871f53..2dfc4326344a4031e1c23077764e553692368d87 100644
--- a/remoting/webapp/me2mom/log_to_server.js
+++ b/remoting/webapp/me2mom/log_to_server.js
@@ -16,7 +16,10 @@ var remoting = remoting || {};
* @constructor
*/
remoting.LogToServer = function() {
- /** @type Array.<string> */ this.pendingEntries = [];
+ /** @type Array.<string> */
+ this.pendingEntries = [];
+ /** @type {remoting.StatsAccumulator} */
+ this.statsAccumulator = new remoting.StatsAccumulator();
};
// Local storage keys.
@@ -56,6 +59,44 @@ remoting.LogToServer.prototype.logClientSessionStateChange =
entry.addWebappVersionField();
entry.addIdField(this.getId());
this.log(entry);
+ // Don't accumulate connection statistics across state changes.
+ this.logAccumulatedStatistics();
+ this.statsAccumulator.empty();
+};
+
+/**
+ * Logs connection statistics.
+ * @param {Object.<string, number>} stats the connection statistics
+ */
+remoting.LogToServer.prototype.logStatistics = function(stats) {
+ // Store the statistics.
+ this.statsAccumulator.add(stats);
+ // Send statistics to the server if they've been accumulating for at least
+ // 60 seconds.
+ if (this.statsAccumulator.getTimeSinceFirstValue() >= 60 * 1000) {
Jamie 2011/12/09 06:58:34 Optional: How would you feel about replacing this
simonmorris 2011/12/09 18:40:36 One problem is that LogToServer would then have to
+ this.logAccumulatedStatistics();
+ }
+};
+
+/**
+ * Moves connection statistics from the accumulator to the log server.
+ *
+ * If all the statistics are zero, then the accumulator is still emptied,
+ * but the statistics are not sent to the log server.
+ *
+ * @private
+ */
+remoting.LogToServer.prototype.logAccumulatedStatistics = function() {
+ var entry = remoting.ServerLogEntry.prototype.makeStats(
+ this.statsAccumulator);
+ if (entry) {
+ entry.addHostFields();
+ entry.addChromeVersionField();
+ entry.addWebappVersionField();
+ entry.addIdField(this.getId());
+ this.log(entry);
+ }
+ this.statsAccumulator.empty();
};
/**

Powered by Google App Engine
This is Rietveld 408576698