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

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

Issue 679103004: Add function to get network stack state from a URLRequestContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 6 years, 2 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 | « no previous file | chrome/browser/ui/webui/net_internals/net_internals_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/browser_bridge.js
diff --git a/chrome/browser/resources/net_internals/browser_bridge.js b/chrome/browser/resources/net_internals/browser_bridge.js
index e5a19bf4ce4a360ea181ff2f6c45f5c20d70f796..09ce829b4471723eec68b2f9d3a3d87a31759970 100644
--- a/chrome/browser/resources/net_internals/browser_bridge.js
+++ b/chrome/browser/resources/net_internals/browser_bridge.js
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Populated by constants from the browser. Used only by this file.
+var NetInfoSources = null;
+
/**
* This class provides a "bridge" for communicating between the javascript and
* the browser.
@@ -33,40 +36,32 @@ var BrowserBridge = (function() {
this.earlyReceivedData_ = [];
this.pollableDataHelpers_ = {};
- this.pollableDataHelpers_.proxySettings =
- new PollableDataHelper('onProxySettingsChanged',
- this.sendGetProxySettings.bind(this));
- this.pollableDataHelpers_.badProxies =
- new PollableDataHelper('onBadProxiesChanged',
- this.sendGetBadProxies.bind(this));
- this.pollableDataHelpers_.httpCacheInfo =
- new PollableDataHelper('onHttpCacheInfoChanged',
- this.sendGetHttpCacheInfo.bind(this));
- this.pollableDataHelpers_.hostResolverInfo =
- new PollableDataHelper('onHostResolverInfoChanged',
- this.sendGetHostResolverInfo.bind(this));
- this.pollableDataHelpers_.socketPoolInfo =
- new PollableDataHelper('onSocketPoolInfoChanged',
- this.sendGetSocketPoolInfo.bind(this));
+
+ // Add PollableDataHelpers for NetInfoSources, which retrieve information
+ // directly from the network stack.
+ this.addNetInfoPollableDataHelper('proxySettings',
+ 'onProxySettingsChanged');
+ this.addNetInfoPollableDataHelper('badProxies', 'onBadProxiesChanged');
+ this.addNetInfoPollableDataHelper('hostResolverInfo',
+ 'onHostResolverInfoChanged');
+ this.addNetInfoPollableDataHelper('socketPoolInfo',
+ 'onSocketPoolInfoChanged');
+ this.addNetInfoPollableDataHelper('spdySessionInfo',
+ 'onSpdySessionInfoChanged');
+ this.addNetInfoPollableDataHelper('spdyStatus', 'onSpdyStatusChanged');
+ this.addNetInfoPollableDataHelper('spdyAlternateProtocolMappings',
+ 'onSpdyAlternateProtocolMappingsChanged');
+ this.addNetInfoPollableDataHelper('quicInfo', 'onQuicInfoChanged');
+ this.addNetInfoPollableDataHelper('httpCacheInfo',
+ 'onHttpCacheInfoChanged');
+
+ // Add other PollableDataHelpers.
this.pollableDataHelpers_.sessionNetworkStats =
- new PollableDataHelper('onSessionNetworkStatsChanged',
- this.sendGetSessionNetworkStats.bind(this));
+ new PollableDataHelper('onSessionNetworkStatsChanged',
+ this.sendGetSessionNetworkStats.bind(this));
this.pollableDataHelpers_.historicNetworkStats =
- new PollableDataHelper('onHistoricNetworkStatsChanged',
- this.sendGetHistoricNetworkStats.bind(this));
- this.pollableDataHelpers_.quicInfo =
- new PollableDataHelper('onQuicInfoChanged',
- this.sendGetQuicInfo.bind(this));
- this.pollableDataHelpers_.spdySessionInfo =
- new PollableDataHelper('onSpdySessionInfoChanged',
- this.sendGetSpdySessionInfo.bind(this));
- this.pollableDataHelpers_.spdyStatus =
- new PollableDataHelper('onSpdyStatusChanged',
- this.sendGetSpdyStatus.bind(this));
- this.pollableDataHelpers_.spdyAlternateProtocolMappings =
- new PollableDataHelper('onSpdyAlternateProtocolMappingsChanged',
- this.sendGetSpdyAlternateProtocolMappings.bind(
- this));
+ new PollableDataHelper('onHistoricNetworkStatsChanged',
+ this.sendGetHistoricNetworkStats.bind(this));
if (cr.isWindows) {
this.pollableDataHelpers_.serviceProviders =
new PollableDataHelper('onServiceProvidersChanged',
@@ -140,25 +135,16 @@ var BrowserBridge = (function() {
}
},
- sendGetProxySettings: function() {
- // The browser will call receivedProxySettings on completion.
- this.send('getProxySettings');
+ sendGetNetInfo: function(netInfoSource) {
+ // If don't have constants yet, don't do anything yet.
+ if (NetInfoSources)
+ this.send('getNetInfo', [NetInfoSources[netInfoSource]]);
},
sendReloadProxySettings: function() {
this.send('reloadProxySettings');
},
- sendGetBadProxies: function() {
- // The browser will call receivedBadProxies on completion.
- this.send('getBadProxies');
- },
-
- sendGetHostResolverInfo: function() {
- // The browser will call receivedHostResolverInfo on completion.
- this.send('getHostResolverInfo');
- },
-
sendClearBadProxies: function() {
this.send('clearBadProxies');
},
@@ -194,14 +180,6 @@ var BrowserBridge = (function() {
this.send('hstsDelete', [domain]);
},
- sendGetHttpCacheInfo: function() {
- this.send('getHttpCacheInfo');
- },
-
- sendGetSocketPoolInfo: function() {
- this.send('getSocketPoolInfo');
- },
-
sendGetSessionNetworkStats: function() {
this.send('getSessionNetworkStats');
},
@@ -218,22 +196,6 @@ var BrowserBridge = (function() {
this.send('flushSocketPools');
},
- sendGetQuicInfo: function() {
- this.send('getQuicInfo');
- },
-
- sendGetSpdySessionInfo: function() {
- this.send('getSpdySessionInfo');
- },
-
- sendGetSpdyStatus: function() {
- this.send('getSpdyStatus');
- },
-
- sendGetSpdyAlternateProtocolMappings: function() {
- this.send('getSpdyAlternateProtocolMappings');
- },
-
sendGetServiceProviders: function() {
this.send('getServiceProviders');
},
@@ -304,28 +266,26 @@ var BrowserBridge = (function() {
},
receivedConstants: function(constants) {
+ NetInfoSources = constants.netInfoSources;
for (var i = 0; i < this.constantsObservers_.length; i++)
this.constantsObservers_[i].onReceivedConstants(constants);
+ // May have been waiting for the constants to be received before getting
+ // information for the currently displayed tab.
+ this.checkForUpdatedInfo();
},
receivedLogEntries: function(logEntries) {
EventsTracker.getInstance().addLogEntries(logEntries);
},
- receivedProxySettings: function(proxySettings) {
- this.pollableDataHelpers_.proxySettings.update(proxySettings);
- },
-
- receivedBadProxies: function(badProxies) {
- this.pollableDataHelpers_.badProxies.update(badProxies);
- },
-
- receivedHostResolverInfo: function(hostResolverInfo) {
- this.pollableDataHelpers_.hostResolverInfo.update(hostResolverInfo);
- },
-
- receivedSocketPoolInfo: function(socketPoolInfo) {
- this.pollableDataHelpers_.socketPoolInfo.update(socketPoolInfo);
+ receivedNetInfo: function(netInfo) {
+ // Dispatch |netInfo| to the various PollableDataHelpers listening to
+ // each field it contains.
+ //
+ // Currently information is only received from one source at a time, but
+ // the API does allow for data from more that one to be requested at once.
+ for (var source in netInfo)
+ this.pollableDataHelpers_[source].update(netInfo[source]);
},
receivedSessionNetworkStats: function(sessionNetworkStats) {
@@ -337,24 +297,6 @@ var BrowserBridge = (function() {
historicNetworkStats);
},
- receivedQuicInfo: function(quicInfo) {
- this.pollableDataHelpers_.quicInfo.update(quicInfo);
- },
-
- receivedSpdySessionInfo: function(spdySessionInfo) {
- this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo);
- },
-
- receivedSpdyStatus: function(spdyStatus) {
- this.pollableDataHelpers_.spdyStatus.update(spdyStatus);
- },
-
- receivedSpdyAlternateProtocolMappings:
- function(spdyAlternateProtocolMappings) {
- this.pollableDataHelpers_.spdyAlternateProtocolMappings.update(
- spdyAlternateProtocolMappings);
- },
-
receivedServiceProviders: function(serviceProviders) {
this.pollableDataHelpers_.serviceProviders.update(serviceProviders);
},
@@ -403,10 +345,6 @@ var BrowserBridge = (function() {
this.setNetworkDebugModeObservers_[i].onSetNetworkDebugMode(status);
},
- receivedHttpCacheInfo: function(info) {
- this.pollableDataHelpers_.httpCacheInfo.update(info);
- },
-
receivedPrerenderInfo: function(prerenderInfo) {
this.pollableDataHelpers_.prerenderInfo.update(prerenderInfo);
},
@@ -712,7 +650,15 @@ var BrowserBridge = (function() {
if (callback)
new UpdateAllObserver(callback, this.pollableDataHelpers_);
this.checkForUpdatedInfo(true);
- }
+ },
+
+ /**
+ * Adds a PollableDataHelper that listens to the specified NetInfoSource.
+ */
+ addNetInfoPollableDataHelper: function(sourceName, observerMethodName) {
+ this.pollableDataHelpers_[sourceName] = new PollableDataHelper(
+ observerMethodName, this.sendGetNetInfo.bind(this, sourceName));
+ },
};
/**
« no previous file with comments | « no previous file | chrome/browser/ui/webui/net_internals/net_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698