Chromium Code Reviews| 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..c60f4e90b811ff08da6d07899cb4ef06ecf58e16 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"; |
|
Jamie
2011/12/09 19:47:56
Why not reuse the keys from ClientSession?
simonmorris
2011/12/09 21:12:12
Because I want to be able to look down the list of
|
| + |
| +/** @private */ |
| remoting.ServerLogEntry.prototype.KEY_OS_NAME_ = 'os-name'; |
| /** @private */ |
| remoting.ServerLogEntry.prototype.VALUE_OS_NAME_WINDOWS_ = 'Windows'; |
| @@ -142,6 +158,17 @@ remoting.ServerLogEntry.prototype.toStanza = function() { |
| }; |
| /** |
| + * Prints this object on the debug log. |
| + * |
| + * @param {number} indentLevel the indentation level of each field |
| + */ |
| +remoting.ServerLogEntry.prototype.toDebugLog = function(indentLevel) { |
| + for (var key in this.dict) { |
| + remoting.debug.logIndent(indentLevel, key + ': ' + this.dict[key]); |
| + } |
|
Jamie
2011/12/09 19:47:56
It might be better to log these on a single line,
simonmorris
2011/12/09 21:12:12
Done.
|
| +}; |
| + |
| +/** |
| * Makes a log entry for a change of client session state. |
| * |
| * @param {remoting.ClientSession.State} state |
| @@ -162,6 +189,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) { |
|
Jamie
2011/12/09 19:47:56
I don't think this (or the previous method) belong
simonmorris
2011/12/09 21:12:12
Done.
|
| + 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; |
| + nonZero |= entry.addStatsField( |
| + this.KEY_VIDEO_BANDWIDTH_, |
| + remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator); |
| + nonZero |= entry.addStatsField( |
| + this.KEY_CAPTURE_LATENCY_, |
| + remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator); |
| + nonZero |= entry.addStatsField( |
| + this.KEY_ENCODE_LATENCY_, |
| + remoting.ClientSession.STATS_KEY_ENCODE_LATENCY, statsAccumulator); |
| + nonZero |= entry.addStatsField( |
| + this.KEY_DECODE_LATENCY_, |
| + remoting.ClientSession.STATS_KEY_DECODE_LATENCY, statsAccumulator); |
| + nonZero |= entry.addStatsField( |
| + this.KEY_RENDER_LATENCY_, |
| + remoting.ClientSession.STATS_KEY_RENDER_LATENCY, statsAccumulator); |
| + nonZero |= entry.addStatsField( |
| + 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. |
| + * |
| + * @private |
| + * @param {string} entryKey |
| + * @param {string} statsKey |
| + * @param {remoting.StatsAccumulator} statsAccumulator |
| + * @return {boolean} whether the statistic is non-zero |
| + */ |
| +remoting.ServerLogEntry.prototype.addStatsField = function( |
| + entryKey, statsKey, statsAccumulator) { |
| + var val = statsAccumulator.calcMean(statsKey); |
| + this.set(entryKey, val.toString()); |
| + return (val != 0); |
| +}; |
| + |
| +/** |
| * Adds an ID field to this log entry. |
| * |
| * @param {string} id |