| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 /** | 5 /** |
| 6 * Each row in the filtered items list is backed by a SourceEntry. This | 6 * Each row in the filtered items list is backed by a SourceEntry. This |
| 7 * instance contains all of the data pertaining to that row, and notifies | 7 * instance contains all of the data pertaining to that row, and notifies |
| 8 * its parent view (the RequestsView) whenever its data changes. | 8 * its parent view (the RequestsView) whenever its data changes. |
| 9 * | 9 * |
| 10 * @constructor | 10 * @constructor |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 SourceEntry.prototype.setFilterStyles = function(isMatchedByFilter) { | 54 SourceEntry.prototype.setFilterStyles = function(isMatchedByFilter) { |
| 55 // Hide rows which have been filtered away. | 55 // Hide rows which have been filtered away. |
| 56 if (isMatchedByFilter) { | 56 if (isMatchedByFilter) { |
| 57 this.row_.style.display = ''; | 57 this.row_.style.display = ''; |
| 58 } else { | 58 } else { |
| 59 this.row_.style.display = 'none'; | 59 this.row_.style.display = 'none'; |
| 60 } | 60 } |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 SourceEntry.prototype.update = function(logEntry) { | 63 SourceEntry.prototype.update = function(logEntry) { |
| 64 var prevStartEntry = this.getStartEntry_(); |
| 64 this.entries_.push(logEntry); | 65 this.entries_.push(logEntry); |
| 66 var curStartEntry = this.getStartEntry_(); |
| 65 | 67 |
| 66 if (this.entries_.length == 1) { | 68 // If we just got the first entry for this source. |
| 69 if (!prevStartEntry && curStartEntry) { |
| 67 this.createRow_(); | 70 this.createRow_(); |
| 68 | 71 |
| 69 // Only apply the filter during the first update. | 72 // Only apply the filter during the first update. |
| 70 // TODO(eroman): once filters use other data, apply it on each update. | 73 // TODO(eroman): once filters use other data, apply it on each update. |
| 71 var matchesFilter = this.matchesFilter(this.parentView_.currentFilter_); | 74 var matchesFilter = this.matchesFilter(this.parentView_.currentFilter_); |
| 72 this.setIsMatchedByFilter(matchesFilter); | 75 this.setIsMatchedByFilter(matchesFilter); |
| 73 } | 76 } |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 SourceEntry.prototype.onCheckboxToggled_ = function() { | 79 SourceEntry.prototype.onCheckboxToggled_ = function() { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 var sourceTypeString = this.getSourceTypeString(); | 145 var sourceTypeString = this.getSourceTypeString(); |
| 143 addTextNode(typeCell, sourceTypeString); | 146 addTextNode(typeCell, sourceTypeString); |
| 144 addTextNode(descriptionCell, this.getDescription()); | 147 addTextNode(descriptionCell, this.getDescription()); |
| 145 | 148 |
| 146 // Add a CSS classname specific to this source type (so CSS can specify | 149 // Add a CSS classname specific to this source type (so CSS can specify |
| 147 // different stylings for different types). | 150 // different stylings for different types). |
| 148 changeClassName(this.row_, "source_" + sourceTypeString, true); | 151 changeClassName(this.row_, "source_" + sourceTypeString, true); |
| 149 }; | 152 }; |
| 150 | 153 |
| 151 SourceEntry.prototype.getDescription = function() { | 154 SourceEntry.prototype.getDescription = function() { |
| 152 var e = this.entries_[0]; | 155 var e = this.getStartEntry_(); |
| 153 if (e.type == LogEntryType.TYPE_EVENT && | 156 if (!e || e.extra_parameters == undefined) |
| 154 e.event.phase == LogEventPhase.PHASE_BEGIN && | 157 return ''; |
| 155 e.string != undefined) { | 158 return e.extra_parameters; // The URL / hostname / whatever. |
| 156 return e.string; // The URL / hostname / whatever. | 159 }; |
| 157 } | 160 |
| 158 return ''; | 161 /** |
| 162 * Returns the starting entry for this source. Conceptually this is the |
| 163 * first entry that was logged to this source. However, we skip over the |
| 164 * TYPE_REQUEST_ALIVE entries which wrap TYPE_URL_REQUEST_START / |
| 165 * TYPE_SOCKET_STREAM_CONNECT. |
| 166 * |
| 167 * TODO(eroman): Get rid of TYPE_REQUEST_ALIVE so this isn't necessary. |
| 168 */ |
| 169 SourceEntry.prototype.getStartEntry_ = function() { |
| 170 if (this.entries_.length < 1) |
| 171 return undefined; |
| 172 if (this.entries_[0].type != LogEventType.REQUEST_ALIVE) |
| 173 return this.entries_[0]; |
| 174 if (this.entries_.length < 2) |
| 175 return undefined; |
| 176 return this.entries_[1]; |
| 159 }; | 177 }; |
| 160 | 178 |
| 161 SourceEntry.prototype.getLogEntries = function() { | 179 SourceEntry.prototype.getLogEntries = function() { |
| 162 return this.entries_; | 180 return this.entries_; |
| 163 }; | 181 }; |
| 164 | 182 |
| 165 SourceEntry.prototype.getSourceTypeString = function() { | 183 SourceEntry.prototype.getSourceTypeString = function() { |
| 166 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); | 184 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); |
| 167 }; | 185 }; |
| 168 | 186 |
| 169 SourceEntry.prototype.getSelectionCheckbox = function() { | 187 SourceEntry.prototype.getSelectionCheckbox = function() { |
| 170 return this.row_.childNodes[0].firstChild; | 188 return this.row_.childNodes[0].firstChild; |
| 171 }; | 189 }; |
| 172 | 190 |
| 173 SourceEntry.prototype.getSourceId = function() { | 191 SourceEntry.prototype.getSourceId = function() { |
| 174 return this.entries_[0].source.id; | 192 return this.entries_[0].source.id; |
| 175 }; | 193 }; |
| 176 | 194 |
| 177 SourceEntry.prototype.remove = function() { | 195 SourceEntry.prototype.remove = function() { |
| 178 this.setSelected(false); | 196 this.setSelected(false); |
| 179 this.setIsMatchedByFilter(false); | 197 this.setIsMatchedByFilter(false); |
| 180 this.row_.parentNode.removeChild(this.row_); | 198 this.row_.parentNode.removeChild(this.row_); |
| 181 }; | 199 }; |
| 182 | 200 |
| OLD | NEW |