OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var SourceTracker = (function() { | 5 var SourceTracker = (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * This class keeps track of all NetLog events, grouped into per-source | 9 * This class keeps track of all NetLog events, grouped into per-source |
10 * streams. It receives events from EventsTracker, and passes | 10 * streams. It receives events from EventsTracker, and passes |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // List source entries with new log entries. Sorted chronologically, by | 82 // List source entries with new log entries. Sorted chronologically, by |
83 // first new log entry. | 83 // first new log entry. |
84 var updatedSourceEntries = []; | 84 var updatedSourceEntries = []; |
85 | 85 |
86 var updatedSourceEntryIdMap = {}; | 86 var updatedSourceEntryIdMap = {}; |
87 | 87 |
88 for (var e = 0; e < logEntries.length; ++e) { | 88 for (var e = 0; e < logEntries.length; ++e) { |
89 var logEntry = logEntries[e]; | 89 var logEntry = logEntries[e]; |
90 | 90 |
91 // Assign unique ID, if needed. | 91 // Assign unique ID, if needed. |
| 92 // TODO(mmenke): Remove this, and all other code to handle 0 source |
| 93 // IDs when M19 hits stable. |
92 if (logEntry.source.id == 0) { | 94 if (logEntry.source.id == 0) { |
93 logEntry.source.id = this.nextSourcelessEventId_; | 95 logEntry.source.id = this.nextSourcelessEventId_; |
94 --this.nextSourcelessEventId_; | 96 --this.nextSourcelessEventId_; |
95 } else if (this.maxReceivedSourceId_ < logEntry.source.id) { | 97 } else if (this.maxReceivedSourceId_ < logEntry.source.id) { |
96 this.maxReceivedSourceId_ = logEntry.source.id; | 98 this.maxReceivedSourceId_ = logEntry.source.id; |
97 } | 99 } |
98 | 100 |
99 // Create/update SourceEntry object. | 101 // Create/update SourceEntry object. |
100 var sourceEntry = this.sourceEntries_[logEntry.source.id]; | 102 var sourceEntry = this.sourceEntries_[logEntry.source.id]; |
101 if (!sourceEntry) { | 103 if (!sourceEntry) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 * ovserver.onAllSourceEntriesDeleted() | 159 * ovserver.onAllSourceEntriesDeleted() |
158 * observer.onSecurityStrippingChanged() | 160 * observer.onSecurityStrippingChanged() |
159 */ | 161 */ |
160 addSourceEntryObserver: function(observer) { | 162 addSourceEntryObserver: function(observer) { |
161 this.sourceEntryObservers_.push(observer); | 163 this.sourceEntryObservers_.push(observer); |
162 } | 164 } |
163 }; | 165 }; |
164 | 166 |
165 return SourceTracker; | 167 return SourceTracker; |
166 })(); | 168 })(); |
OLD | NEW |