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

Unified Diff: remoting/webapp/crd/js/connection_stats.js

Issue 1089493002: [Webapp Refactor] Re-add remoting.ConnectionStats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/crd/html/window_frame.html ('k') | remoting/webapp/crd/js/desktop_connected_view.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/connection_stats.js
diff --git a/remoting/webapp/crd/js/connection_stats.js b/remoting/webapp/crd/js/connection_stats.js
index e707c9f3d7742d17fdbc71149750b7f8827b2cef..7ab1652f597d5b66cc8aee21bb4333dccc527d40 100644
--- a/remoting/webapp/crd/js/connection_stats.js
+++ b/remoting/webapp/crd/js/connection_stats.js
@@ -14,19 +14,38 @@ var remoting = remoting || {};
/**
* @constructor
- * @implements {remoting.WindowShape.ClientUI}
* @param {Element} statsElement The HTML div to which to update stats.
+ * @param {remoting.ClientPlugin} plugin
+ *
+ * @implements {remoting.WindowShape.ClientUI}
+ * @implements {base.Disposable}
*/
-remoting.ConnectionStats = function(statsElement) {
+remoting.ConnectionStats = function(statsElement, plugin) {
/** @private */
this.statsElement_ = statsElement;
/** @private {remoting.ClientSession.PerfStats} */
this.mostRecent_ = null
+ /** @private */
+ this.plugin_ = plugin;
+
+ var that = this;
+
+ /** @private */
+ this.timer_ = new base.RepeatingTimer(function(){
+ that.update(plugin.getPerfStats());
+ }, 1000, true);
+
remoting.windowShape.addCallback(this);
};
+remoting.ConnectionStats.prototype.dispose = function() {
+ base.dispose(this.timer_);
+ this.timer_ = null;
+ this.plugin_ = null;
+};
+
/**
* @return {remoting.ClientSession.PerfStats} The most recently-set PerfStats,
* or null if update() has not yet been called.
@@ -43,6 +62,13 @@ remoting.ConnectionStats.prototype.toggle = function() {
};
/**
+ * @return {boolean}
+ */
+remoting.ConnectionStats.prototype.isVisible = function() {
+ return !this.statsElement_.hidden;
+};
+
+/**
* Show or hide the connection stats div.
* @param {boolean} show
*/
@@ -109,22 +135,3 @@ remoting.ConnectionStats.prototype.update = function(stats) {
', Render: ' + formatStatNumber(stats.renderLatency, 'ms') +
', Latency: ' + formatStatNumber(stats.roundtripLatency, 'ms'));
};
-
-/**
- * Check for the debug toggle hot-key.
- *
- * @param {Event} event The keyboard event.
- * @return {void} Nothing.
- */
-remoting.ConnectionStats.onKeydown = function(event) {
- var element = /** @type {Element} */ (event.target);
- if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') {
- return;
- }
- if (String.fromCharCode(event.which) == 'D') {
- remoting.stats.toggle();
- }
-};
-
-/** @type {remoting.ConnectionStats} */
-remoting.stats = null;
« no previous file with comments | « remoting/webapp/crd/html/window_frame.html ('k') | remoting/webapp/crd/js/desktop_connected_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698