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

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

Issue 9581021: [refactor] Split up SourceTracker into SourceTracker + EventsTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update based on mmenke comments Created 8 years, 10 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/source_tracker.js
diff --git a/chrome/browser/resources/net_internals/source_tracker.js b/chrome/browser/resources/net_internals/source_tracker.js
index 92d576d3d27a4f1ea509f57c46f2347b17d2b4db..7220a3f5d85d6efbe76ea0b0e249d1f6861a6d9c 100644
--- a/chrome/browser/resources/net_internals/source_tracker.js
+++ b/chrome/browser/resources/net_internals/source_tracker.js
@@ -6,16 +6,14 @@ var SourceTracker = (function() {
'use strict';
/**
- * This class keeps track of all NetLog events.
- * It receives events from the browser and when loading a log file, and passes
+ * This class keeps track of all NetLog events, grouped into per-source
+ * streams. It receives events from EventsTracker, and passes
* them on to all its observers.
*
* @constructor
*/
function SourceTracker() {
- // Observers that are sent all events as they happen. This allows for easy
- // watching for particular events.
- this.logEntryObservers_ = [];
+ assertFirstConstructorCall(SourceTracker);
// Observers that only want to receive lists of updated SourceEntries.
this.sourceEntryObservers_ = [];
@@ -26,8 +24,12 @@ var SourceTracker = (function() {
this.enableSecurityStripping_ = true;
this.clearEntries_();
+
+ EventsTracker.getInstance().addLogEntryObserver(this);
}
+ cr.addSingletonGetter(SourceTracker);
+
SourceTracker.prototype = {
/**
* Clears all log entries and SourceEntries and related state.
@@ -48,13 +50,6 @@ var SourceTracker = (function() {
},
/**
- * Returns a list of all captured events.
- */
- getAllCapturedEvents: function() {
- return this.capturedEvents_;
- },
-
- /**
* Returns a list of all SourceEntries.
*/
getAllSourceEntries: function() {
@@ -62,14 +57,6 @@ var SourceTracker = (function() {
},
/**
- * Returns the number of events that were captured while we were
- * listening for events.
- */
- getNumCapturedEvents: function() {
- return this.capturedEvents_.length;
- },
-
- /**
* Returns the description of the specified SourceEntry, or an empty string
* if it doesn't exist.
*/
@@ -130,19 +117,15 @@ var SourceTracker = (function() {
this.sourceEntryObservers_[i].onSourceEntriesUpdated(
updatedSourceEntries);
}
- for (var i = 0; i < this.logEntryObservers_.length; ++i)
- this.logEntryObservers_[i].onReceivedLogEntries(logEntries);
},
/**
- * Deletes all captured events.
+ * Called when all log events have been deleted.
*/
- deleteAllSourceEntries: function() {
+ onAllLogEntriesDeleted: function() {
this.clearEntries_();
for (var i = 0; i < this.sourceEntryObservers_.length; ++i)
this.sourceEntryObservers_[i].onAllSourceEntriesDeleted();
- for (var i = 0; i < this.logEntryObservers_.length; ++i)
- this.logEntryObservers_[i].onAllLogEntriesDeleted();
},
/**
@@ -176,17 +159,6 @@ var SourceTracker = (function() {
*/
addSourceEntryObserver: function(observer) {
this.sourceEntryObservers_.push(observer);
- },
-
- /**
- * Adds a listener of log entries. |observer| will be called back when new
- * log data arrives or all entries are deleted:
- *
- * observer.onReceivedLogEntries(entries)
- * ovserver.onAllLogEntriesDeleted()
- */
- addLogEntryObserver: function(observer) {
- this.logEntryObservers_.push(observer);
}
};
« no previous file with comments | « chrome/browser/resources/net_internals/source_entry.js ('k') | chrome/browser/resources/net_internals/timeline_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698