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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 if (logEntry.phase == EventPhase.PHASE_BEGIN) | 25 if (logEntry.phase == EventPhase.PHASE_BEGIN) |
26 this.isInactive_ = false; | 26 this.isInactive_ = false; |
27 | 27 |
28 this.update(logEntry); | 28 this.update(logEntry); |
29 } | 29 } |
30 | 30 |
31 SourceEntry.prototype = { | 31 SourceEntry.prototype = { |
32 update: function(logEntry) { | 32 update: function(logEntry) { |
33 // Only the last event should have the same type first event, | 33 // Only the last event should have the same type first event, |
34 if (!this.isInactive_ && | 34 if (!this.isInactive_ && logEntry.phase == EventPhase.PHASE_END && |
35 logEntry.phase == EventPhase.PHASE_END && | |
36 logEntry.type == this.entries_[0].type) { | 35 logEntry.type == this.entries_[0].type) { |
37 this.isInactive_ = true; | 36 this.isInactive_ = true; |
38 } | 37 } |
39 | 38 |
40 // If we have a net error code, update |this.isError_| if appropriate. | 39 // If we have a net error code, update |this.isError_| if appropriate. |
41 if (logEntry.params) { | 40 if (logEntry.params) { |
42 var netErrorCode = logEntry.params.net_error; | 41 var netErrorCode = logEntry.params.net_error; |
43 // Skip both cases where netErrorCode is undefined, and cases where it | 42 // Skip both cases where netErrorCode is undefined, and cases where it |
44 // is 0, indicating no actual error occurred. | 43 // is 0, indicating no actual error occurred. |
45 if (netErrorCode) { | 44 if (netErrorCode) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 getStartEntry_: function() { | 191 getStartEntry_: function() { |
193 if (this.entries_.length < 1) | 192 if (this.entries_.length < 1) |
194 return undefined; | 193 return undefined; |
195 if (this.entries_[0].source.type == EventSourceType.FILESTREAM) { | 194 if (this.entries_[0].source.type == EventSourceType.FILESTREAM) { |
196 var e = this.findLogEntryByType_(EventType.FILE_STREAM_OPEN); | 195 var e = this.findLogEntryByType_(EventType.FILE_STREAM_OPEN); |
197 if (e != undefined) | 196 if (e != undefined) |
198 return e; | 197 return e; |
199 } | 198 } |
200 if (this.entries_[0].source.type == EventSourceType.DOWNLOAD) { | 199 if (this.entries_[0].source.type == EventSourceType.DOWNLOAD) { |
201 // If any rename occurred, use the last name | 200 // If any rename occurred, use the last name |
202 e = this.findLastLogEntryStartByType_( | 201 e = this.findLastLogEntryStartByType_(EventType.DOWNLOAD_FILE_RENAMED); |
203 EventType.DOWNLOAD_FILE_RENAMED); | |
204 if (e != undefined) | 202 if (e != undefined) |
205 return e; | 203 return e; |
206 // Otherwise, if the file was opened, use that name | 204 // Otherwise, if the file was opened, use that name |
207 e = this.findLogEntryByType_(EventType.DOWNLOAD_FILE_OPENED); | 205 e = this.findLogEntryByType_(EventType.DOWNLOAD_FILE_OPENED); |
208 if (e != undefined) | 206 if (e != undefined) |
209 return e; | 207 return e; |
210 // History items are never opened, so use the activation info | 208 // History items are never opened, so use the activation info |
211 e = this.findLogEntryByType_(EventType.DOWNLOAD_ITEM_ACTIVE); | 209 e = this.findLogEntryByType_(EventType.DOWNLOAD_ITEM_ACTIVE); |
212 if (e != undefined) | 210 if (e != undefined) |
213 return e; | 211 return e; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 334 |
337 // Format the table for fixed-width text. | 335 // Format the table for fixed-width text. |
338 tablePrinter.toText(0, parent); | 336 tablePrinter.toText(0, parent); |
339 }, | 337 }, |
340 | 338 |
341 /** | 339 /** |
342 * Creates a table printer for the SourceEntry. | 340 * Creates a table printer for the SourceEntry. |
343 */ | 341 */ |
344 createTablePrinter: function() { | 342 createTablePrinter: function() { |
345 return createLogEntryTablePrinter( | 343 return createLogEntryTablePrinter( |
346 this.entries_, | 344 this.entries_, SourceTracker.getInstance().getPrivacyStripping(), |
347 SourceTracker.getInstance().getPrivacyStripping(), | |
348 SourceTracker.getInstance().getUseRelativeTimes() ? | 345 SourceTracker.getInstance().getUseRelativeTimes() ? |
349 timeutil.getBaseTime() : 0, | 346 timeutil.getBaseTime() : |
| 347 0, |
350 Constants.clientInfo.numericDate); | 348 Constants.clientInfo.numericDate); |
351 }, | 349 }, |
352 }; | 350 }; |
353 | 351 |
354 return SourceEntry; | 352 return SourceEntry; |
355 })(); | 353 })(); |
OLD | NEW |