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

Side by Side Diff: chrome/browser/resources/net_internals/events_tracker.js

Issue 9581021: [refactor] Split up SourceTracker into SourceTracker + EventsTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var EventsTracker = (function() {
6 'use strict';
7
8 /**
9 * This class keeps track of all NetLog events.
10 * It receives events from the browser and when loading a log file, and passes
11 * them on to all its observers.
12 *
13 * @constructor
14 */
15 function EventsTracker() {
16 assertFirstConstructorCall(EventsTracker);
17
18 this.capturedEvents_ = [];
19 this.observers_ = [];
20 }
21
22 cr.addSingletonGetter(EventsTracker);
23
24 EventsTracker.prototype = {
25 /**
26 * Returns a list of all captured events.
27 */
28 getAllCapturedEvents: function() {
29 return this.capturedEvents_;
30 },
31
32 /**
33 * Returns the number of events that were captured.
34 */
35 getNumCapturedEvents: function() {
36 return this.capturedEvents_.length;
37 },
38
39 /**
40 * Called when all log events have been deleted.
mmenke 2012/03/02 22:12:36 Deletes all log events, and broadcasts that to all
eroman 2012/03/02 22:19:21 Good spot! Done.
41 */
42 deleteAllLogEntries: function() {
43 this.capturedEvents_ = [];
44 for (var i = 0; i < this.observers_.length; ++i)
45 this.observers_[i].onAllLogEntriesDeleted();
46 },
47
48 /**
49 * Adds captured events, and broadcasts them to any observers.
50 */
51 addLogEntries: function(logEntries) {
52 this.capturedEvents_ = this.capturedEvents_.concat(logEntries);
53 for (var i = 0; i < this.observers_.length; ++i) {
54 this.observers_[i].onReceivedLogEntries(logEntries);
55 }
56 },
57
58 /**
59 * Adds a listener of log entries. |observer| will be called back when new
60 * log data arrives or all entries are deleted:
61 *
62 * observer.onReceivedLogEntries(entries)
63 * observer.onAllLogEntriesDeleted()
64 */
65 addLogEntryObserver: function(observer) {
66 this.observers_.push(observer);
67 }
68 };
69
70 return EventsTracker;
71 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/capture_status_view.js ('k') | chrome/browser/resources/net_internals/events_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698