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