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

Unified Diff: chrome/browser/resources/net_internals/browser_bridge.js

Issue 7553009: Add some browser tests for net-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Just test result of first test Created 9 years, 5 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
Index: chrome/browser/resources/net_internals/browser_bridge.js
===================================================================
--- chrome/browser/resources/net_internals/browser_bridge.js (revision 94938)
+++ chrome/browser/resources/net_internals/browser_bridge.js (working copy)
@@ -66,6 +66,9 @@
// and no messages will be sent to the browser, either. Intended for use
// when viewing log files.
this.disabled_ = false;
+
+ // Interval id returned by window.setInterval for polling timer.
+ this.pollIntervalId_ = null;
}
cr.addSingletonGetter(BrowserBridge);
@@ -93,12 +96,27 @@
sendReady: function() {
this.send('notifyReady');
+ this.setPollInterval(POLL_INTERVAL_MS);
+ },
- // Some of the data we are interested is not currently exposed as a
- // stream, so we will poll the browser to find out when it changes and
- // then notify the observers.
- window.setInterval(this.checkForUpdatedInfo.bind(this, false),
- POLL_INTERVAL_MS);
+ /**
+ * Some of the data we are interested is not currently exposed as a
+ * stream. This starts polling those with active observers (visible
+ * views) every |intervalMs|. Subsequent calls override previous calls
+ * to this function. If |intervalMs| is 0, stops polling. Function only
+ * exposed for unit testing.
+ */
+ setPollInterval: function(intervalMs) {
+ if (this.pollIntervalId_ !== null) {
+ window.clearInterval(this.pollIntervalId_);
+ this.pollIntervalId_ = null;
+ }
+
+ if (intervalMs > 0) {
+ this.pollIntervalId_ =
+ window.setInterval(this.checkForUpdatedInfo.bind(this, false),
+ intervalMs);
+ }
},
sendGetProxySettings: function() {

Powered by Google App Engine
This is Rietveld 408576698