| OLD | NEW |
| 1 // Copyright (c) 2011 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 SourceEntry = (function() { | 5 var SourceEntry = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A SourceEntry gathers all log entries with the same source. | 9 * A SourceEntry gathers all log entries with the same source. |
| 10 * | 10 * |
| 11 * @constructor | 11 * @constructor |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 parent.getDescription().length > 0) { | 124 parent.getDescription().length > 0) { |
| 125 this.description_ += ' [' + parent.getDescription() + ']'; | 125 this.description_ += ' [' + parent.getDescription() + ']'; |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 break; | 129 break; |
| 130 case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST: | 130 case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST: |
| 131 case LogSourceType.DNS_TRANSACTION: | 131 case LogSourceType.DNS_TRANSACTION: |
| 132 this.description_ = e.params.hostname; | 132 this.description_ = e.params.hostname; |
| 133 break; | 133 break; |
| 134 case LogSourceType.FILESTREAM: |
| 135 this.description_ = e.params.file_name; |
| 136 break; |
| 134 } | 137 } |
| 135 | 138 |
| 136 if (this.description_ == undefined) | 139 if (this.description_ == undefined) |
| 137 this.description_ = ''; | 140 this.description_ = ''; |
| 138 }, | 141 }, |
| 139 | 142 |
| 140 /** | 143 /** |
| 141 * Returns a description for this source log stream, which will be displayed | 144 * Returns a description for this source log stream, which will be displayed |
| 142 * in the list view. Most often this is a URL that identifies the request, | 145 * in the list view. Most often this is a URL that identifies the request, |
| 143 * or a hostname for a connect job, etc... | 146 * or a hostname for a connect job, etc... |
| 144 */ | 147 */ |
| 145 getDescription: function() { | 148 getDescription: function() { |
| 146 return this.description_; | 149 return this.description_; |
| 147 }, | 150 }, |
| 148 | 151 |
| 149 /** | 152 /** |
| 150 * Returns the starting entry for this source. Conceptually this is the | 153 * Returns the starting entry for this source. Conceptually this is the |
| 151 * first entry that was logged to this source. However, we skip over the | 154 * first entry that was logged to this source. However, we skip over the |
| 152 * TYPE_REQUEST_ALIVE entries which wrap TYPE_URL_REQUEST_START_JOB / | 155 * TYPE_REQUEST_ALIVE entries which wrap TYPE_URL_REQUEST_START_JOB / |
| 153 * TYPE_SOCKET_STREAM_CONNECT. | 156 * TYPE_SOCKET_STREAM_CONNECT. |
| 154 */ | 157 */ |
| 155 getStartEntry_: function() { | 158 getStartEntry_: function() { |
| 156 if (this.entries_.length < 1) | 159 if (this.entries_.length < 1) |
| 157 return undefined; | 160 return undefined; |
| 161 if (this.entries_[0].source.type == LogSourceType.FILESTREAM) { |
| 162 var e = this.findLogEntryByType_(LogEventType.FILE_STREAM_OPEN); |
| 163 if (e != undefined) |
| 164 return e; |
| 165 } |
| 158 if (this.entries_.length >= 2) { | 166 if (this.entries_.length >= 2) { |
| 159 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || | 167 if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || |
| 160 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || | 168 this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || |
| 161 this.entries_[1].type == LogEventType.UDP_CONNECT) { | 169 this.entries_[1].type == LogEventType.UDP_CONNECT) { |
| 162 return this.entries_[1]; | 170 return this.entries_[1]; |
| 163 } | 171 } |
| 164 } | 172 } |
| 165 return this.entries_[0]; | 173 return this.entries_[0]; |
| 166 }, | 174 }, |
| 167 | 175 |
| 176 /** |
| 177 * Returns the first entry with the specified type, or undefined if not |
| 178 * found. |
| 179 */ |
| 180 findLogEntryByType_: function(type) { |
| 181 for (var i = 0; i < this.entries_.length; ++i) { |
| 182 if (this.entries_[i].type == type) { |
| 183 return this.entries_[i]; |
| 184 } |
| 185 } |
| 186 return undefined; |
| 187 }, |
| 188 |
| 168 getLogEntries: function() { | 189 getLogEntries: function() { |
| 169 return this.entries_; | 190 return this.entries_; |
| 170 }, | 191 }, |
| 171 | 192 |
| 172 getSourceTypeString: function() { | 193 getSourceTypeString: function() { |
| 173 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); | 194 return getKeyWithValue(LogSourceType, this.entries_[0].source.type); |
| 174 }, | 195 }, |
| 175 | 196 |
| 176 getSourceType: function() { | 197 getSourceType: function() { |
| 177 return this.entries_[0].source.type; | 198 return this.entries_[0].source.type; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 * Prints descriptive text about |entries_| to a new node added to the end | 246 * Prints descriptive text about |entries_| to a new node added to the end |
| 226 * of |parent|. | 247 * of |parent|. |
| 227 */ | 248 */ |
| 228 printAsText: function(parent) { | 249 printAsText: function(parent) { |
| 229 printLogEntriesAsText(this.entries_, parent); | 250 printLogEntriesAsText(this.entries_, parent); |
| 230 } | 251 } |
| 231 }; | 252 }; |
| 232 | 253 |
| 233 return SourceEntry; | 254 return SourceEntry; |
| 234 })(); | 255 })(); |
| OLD | NEW |