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

Unified Diff: remoting/webapp/me2mom/server_log_entry.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/server_log_entry.js
diff --git a/remoting/webapp/me2mom/server_log_entry.js b/remoting/webapp/me2mom/server_log_entry.js
index 892a91a871f8dd9935c035bd970170e3b09e8d4e..ba58050881ea6f5a10fd34fc06b31b7cfa94c1a3 100644
--- a/remoting/webapp/me2mom/server_log_entry.js
+++ b/remoting/webapp/me2mom/server_log_entry.js
@@ -94,6 +94,22 @@ remoting.ServerLogEntry.prototype.getValueForConnectionError =
}
/** @private */
+remoting.ServerLogEntry.prototype.VALUE_EVENT_NAME_CONNECTION_STATISTICS_ =
+ "connection-statistics";
+/** @private */
+remoting.ServerLogEntry.prototype.KEY_VIDEO_BANDWIDTH_ = "video-bandwidth";
+/** @private */
+remoting.ServerLogEntry.prototype.KEY_CAPTURE_LATENCY_ = "capture-latency";
+/** @private */
+remoting.ServerLogEntry.prototype.KEY_ENCODE_LATENCY_ = "encode-latency";
+/** @private */
+remoting.ServerLogEntry.prototype.KEY_DECODE_LATENCY_ = "decode-latency";
+/** @private */
+remoting.ServerLogEntry.prototype.KEY_RENDER_LATENCY_ = "render-latency";
+/** @private */
+remoting.ServerLogEntry.prototype.KEY_ROUNDTRIP_LATENCY_ = "roundtrip-latency";
+
+/** @private */
remoting.ServerLogEntry.prototype.KEY_OS_NAME_ = 'os-name';
/** @private */
remoting.ServerLogEntry.prototype.VALUE_OS_NAME_WINDOWS_ = 'Windows';
@@ -162,6 +178,58 @@ remoting.ServerLogEntry.prototype.makeClientSessionStateChange =
};
/**
+ * Makes a log entry for a set of connection statistics.
+ * Returns null if all the statistics were zero.
+ *
+ * @param {remoting.StatsAccumulator} statsAccumulator
+ * @return {?remoting.ServerLogEntry}
+ */
+remoting.ServerLogEntry.prototype.makeStats = function(statsAccumulator) {
+ var entry = new remoting.ServerLogEntry();
+ entry.set(this.KEY_ROLE_, this.VALUE_ROLE_CLIENT_);
+ entry.set(this.KEY_EVENT_NAME_, this.VALUE_EVENT_NAME_CONNECTION_STATISTICS_);
+ var nonZero = false;
Jamie 2011/12/09 06:58:34 Can't these just be entry.addStatsField, and remov
simonmorris 2011/12/09 18:40:36 Done.
+ nonZero |= this.addStatsField(
+ entry, this.KEY_VIDEO_BANDWIDTH_,
+ remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator);
+ nonZero |= this.addStatsField(
+ entry, this.KEY_CAPTURE_LATENCY_,
+ remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator);
+ nonZero |= this.addStatsField(
+ entry, this.KEY_ENCODE_LATENCY_,
+ remoting.ClientSession.STATS_KEY_ENCODE_LATENCY, statsAccumulator);
+ nonZero |= this.addStatsField(
+ entry, this.KEY_DECODE_LATENCY_,
+ remoting.ClientSession.STATS_KEY_DECODE_LATENCY, statsAccumulator);
+ nonZero |= this.addStatsField(
+ entry, this.KEY_RENDER_LATENCY_,
+ remoting.ClientSession.STATS_KEY_RENDER_LATENCY, statsAccumulator);
+ nonZero |= this.addStatsField(
+ entry, this.KEY_ROUNDTRIP_LATENCY_,
+ remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY, statsAccumulator);
+ if (nonZero) {
+ return entry;
+ }
+ return null;
+};
+
+/**
+ * Adds one connection statistic to a log entry.
+ *
+ * @param {remoting.ServerLogEntry} entry
+ * @param {string} entryKey
+ * @param {string} statsKey
+ * @param {remoting.StatsAccumulator} statsAccumulator
+ * @return {boolean} whether the statistic is non-zero
+ */
+remoting.ServerLogEntry.prototype.addStatsField = function(
+ entry, entryKey, statsKey, statsAccumulator) {
+ var val = statsAccumulator.calcMean(statsKey);
+ entry.set(entryKey, val.toString());
+ return (val != 0);
+};
+
+/**
* Adds an ID field to this log entry.
*
* @param {string} id

Powered by Google App Engine
This is Rietveld 408576698