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

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

Issue 1703018: Add the ability to export the captured NetLog data to a formatted text file, ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address mbelshe's comments Created 10 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 | « chrome/browser/resources/net_internals/index.html ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/main.js
===================================================================
--- chrome/browser/resources/net_internals/main.js (revision 45858)
+++ chrome/browser/resources/net_internals/main.js (working copy)
@@ -57,6 +57,10 @@
"hostResolverCacheTTLSuccess",
"hostResolverCacheTTLFailure");
+ // Create a view which will display import/export options to control the
+ // captured data.
+ var dataView = new DataView("dataTabContent", "exportToJson", "exportToText");
+
// Create a view which lets you tab between the different sub-views.
var categoryTabSwitcher =
new TabSwitcherView(new DivView('categoryTabHandles'));
@@ -69,6 +73,7 @@
false);
categoryTabSwitcher.addTab('httpCacheTab',
new DivView('httpCacheTabContent'), false);
+ categoryTabSwitcher.addTab('dataTab', dataView, false);
// Build a map from the anchor name of each tab handle to its "tab ID".
// We will consider navigations to the #hash as a switch tab request.
@@ -109,14 +114,15 @@
function BrowserBridge() {
// List of observers for various bits of browser state.
this.logObservers_ = [];
- this.proxySettingsObservers_ = [];
- this.badProxiesObservers_ = [];
- this.hostResolverCacheObservers_ = [];
+ this.proxySettings_ = new PollableDataHelper('onProxySettingsChanged');
+ this.badProxies_ = new PollableDataHelper('onBadProxiesChanged');
+ this.hostResolverCache_ = new PollableDataHelper('onHostResolverCacheChanged');
- // Map from observer method name (i.e. 'onProxySettingsChanged',
- // 'onBadProxiesChanged') to the previously received data for that type. Used
- // to tell if the data has actually changed since we last polled it.
- this.prevPollData_ = {};
+ // Cache of the data received.
+ // TODO(eroman): the controls to clear data in the "Requests" tab should be
+ // affecting this as well.
+ this.passivelyCapturedEvents_ = [];
+ this.activelyCapturedEvents_ = [];
}
/**
@@ -169,7 +175,11 @@
// Messages received from the browser
//------------------------------------------------------------------------------
-BrowserBridge.prototype.receivedLogEntry = function(logEntry) {
+BrowserBridge.prototype.receivedLogEntry = function(logEntry,
+ wasCapturedPassively) {
+ if (!wasCapturedPassively) {
+ this.activelyCapturedEvents_.push(logEntry);
+ }
for (var i = 0; i < this.logObservers_.length; ++i)
this.logObservers_[i].onLogEntryAdded(logEntry);
};
@@ -193,25 +203,23 @@
};
BrowserBridge.prototype.receivedProxySettings = function(proxySettings) {
- this.dispatchToObserversFromPoll_(
- this.proxySettingsObservers_, 'onProxySettingsChanged', proxySettings);
+ this.proxySettings_.update(proxySettings);
};
BrowserBridge.prototype.receivedBadProxies = function(badProxies) {
- this.dispatchToObserversFromPoll_(
- this.badProxiesObservers_, 'onBadProxiesChanged', badProxies);
+ this.badProxies_.update(badProxies);
};
BrowserBridge.prototype.receivedHostResolverCache =
function(hostResolverCache) {
- this.dispatchToObserversFromPoll_(
- this.hostResolverCacheObservers_, 'onHostResolverCacheChanged',
- hostResolverCache);
+ this.hostResolverCache_.update(hostResolverCache);
};
BrowserBridge.prototype.receivedPassiveLogEntries = function(entries) {
+ this.passivelyCapturedEvents_ =
+ this.passivelyCapturedEvents_.concat(entries);
for (var i = 0; i < entries.length; ++i)
- this.receivedLogEntry(entries[i]);
+ this.receivedLogEntry(entries[i], true);
};
//------------------------------------------------------------------------------
@@ -236,7 +244,7 @@
* TODO(eroman): send a dictionary instead.
*/
BrowserBridge.prototype.addProxySettingsObserver = function(observer) {
- this.proxySettingsObservers_.push(observer);
+ this.proxySettings_.addObserver(observer);
};
/**
@@ -251,7 +259,7 @@
* bad. Note the time is in time ticks.
*/
BrowserBridge.prototype.addBadProxiesObsever = function(observer) {
- this.badProxiesObservers_.push(observer);
+ this.badProxies_.addObserver(observer);
};
/**
@@ -261,7 +269,7 @@
* observer.onHostResolverCacheChanged(hostResolverCache)
*/
BrowserBridge.prototype.addHostResolverCacheObserver = function(observer) {
- this.hostResolverCacheObservers_.push(observer);
+ this.hostResolverCache_.addObserver(observer);
};
/**
@@ -280,6 +288,22 @@
return d;
};
+/**
+ * Returns a list of all the events that were captured while we were
+ * listening for events.
+ */
+BrowserBridge.prototype.getAllActivelyCapturedEvents = function() {
+ return this.activelyCapturedEvents_;
+};
+
+/**
+ * Returns a list of all the events that were captured passively by the
+ * browser prior to when the net-internals page was started.
+ */
+BrowserBridge.prototype.getAllPassivelyCapturedEvents = function() {
+ return this.passivelyCapturedEvents_;
+};
+
BrowserBridge.prototype.doPolling_ = function() {
// TODO(eroman): Optimize this by using a separate polling frequency for the
// data consumed by the currently active view. Everything else can be on a low
@@ -290,21 +314,37 @@
};
/**
+ * This is a helper class used by BrowserBridge, to keep track of:
+ * - the list of observers interested in some piece of data.
+ * - the last known value of that piece of data.
+ * - the name of the callback method to invoke on observers.
+ * @constructor
+ */
+function PollableDataHelper(observerMethodName) {
+ this.observerMethodName_ = observerMethodName;
+ this.observers_ = [];
+}
+
+PollableDataHelper.prototype.addObserver = function(observer) {
+ this.observers_.push(observer);
+};
+
+/**
* Helper function to handle calling all the observers, but ONLY if the data has
* actually changed since last time. This is used for data we received from
* browser on a poll loop.
*/
-BrowserBridge.prototype.dispatchToObserversFromPoll_ = function(
- observerList, method, data) {
- var prevData = this.prevPollData_[method];
+PollableDataHelper.prototype.update = function(data) {
+ var prevData = this.currentData_;
// If the data hasn't changed since last time, no need to notify observers.
if (prevData && JSON.stringify(prevData) == JSON.stringify(data))
return;
- this.prevPollData_[method] = data;
+ this.currentData_ = data;
// Ok, notify the observers of the change.
- for (var i = 0; i < observerList.length; ++i)
- observerList[i][method](data);
+ for (var i = 0; i < this.observers_.length; ++i)
+ var observer = this.observers_[i];
+ observer[this.observerMethodName_](data);
};
« no previous file with comments | « chrome/browser/resources/net_internals/index.html ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698