| 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..a1db25b40747226b48d568e1a5d88e0f0172f184 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,28 @@ 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));
|
| + 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');
|
| +
|
| this.pollableDataHelpers_.sessionNetworkStats =
|
| 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));
|
| if (cr.isWindows) {
|
| this.pollableDataHelpers_.serviceProviders =
|
| new PollableDataHelper('onServiceProvidersChanged',
|
| @@ -140,25 +131,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 +176,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 +192,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 +262,23 @@ 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) {
|
| + // Currently information is only received from one source at a time, but
|
| + // could allow more.
|
| + for (var source in netInfo)
|
| + this.pollableDataHelpers_[source].update(netInfo[source]);
|
| },
|
|
|
| receivedSessionNetworkStats: function(sessionNetworkStats) {
|
| @@ -337,24 +290,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 +338,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 +643,15 @@ var BrowserBridge = (function() {
|
| if (callback)
|
| new UpdateAllObserver(callback, this.pollableDataHelpers_);
|
| this.checkForUpdatedInfo(true);
|
| - }
|
| + },
|
| +
|
| + /**
|
| + * Adds a PollableDataHelper that listens to the secified netInfo source.
|
| + */
|
| + addNetInfoPollableDataHelper: function(sourceName, observerMethodName) {
|
| + this.pollableDataHelpers_[sourceName] = new PollableDataHelper(
|
| + observerMethodName, this.sendGetNetInfo.bind(this, sourceName));
|
| + },
|
| };
|
|
|
| /**
|
|
|