Chromium Code Reviews| Index: chrome/browser/resources/net_internals/source_entry.js |
| diff --git a/chrome/browser/resources/net_internals/source_entry.js b/chrome/browser/resources/net_internals/source_entry.js |
| index c24f27b8b04f2cace6fdefc1521334d6506f5306..7476f647bbd25885a89a0d498e0fea3321e59753 100644 |
| --- a/chrome/browser/resources/net_internals/source_entry.js |
| +++ b/chrome/browser/resources/net_internals/source_entry.js |
| @@ -132,6 +132,16 @@ var SourceEntry = (function() { |
| case LogSourceType.DNS_TRANSACTION: |
| this.description_ = e.params.hostname; |
| break; |
| + case LogSourceType.DOWNLOAD: |
| + switch (e.type) { |
| + case LogEventType.DOWNLOAD_FILE_RENAMED: |
| + this.description_ = e.params.new_filename; |
| + break; |
| + case LogEventType.DOWNLOAD_FILE_OPENED: |
| + this.description_ = e.params.file_name; |
| + break; |
| + } |
| + break; |
| case LogSourceType.FILESTREAM: |
| this.description_ = e.params.file_name; |
| break; |
| @@ -164,6 +174,16 @@ var SourceEntry = (function() { |
| if (e != undefined) |
| return e; |
| } |
| + if (this.entries_[0].source.type == LogSourceType.DOWNLOAD) { |
| + // If any rename occurred, use the last name |
| + e = this.findLastLogEntryByType_(LogEventType.DOWNLOAD_FILE_RENAMED); |
| + if (e != undefined) |
| + return e; |
| + // Otherwise, if the file was opened, use that name |
| + e = this.findLogEntryByType_(LogEventType.DOWNLOAD_FILE_OPENED); |
| + if (e != undefined) |
| + return e; |
| + } |
| if (this.entries_.length >= 2) { |
| if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || |
| this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || |
| @@ -187,6 +207,22 @@ var SourceEntry = (function() { |
| return undefined; |
| }, |
| + /** |
| + * Returns the last entry with the specified type, or undefined if not |
| + * found. |
| + */ |
| + findLastLogEntryByType_: function(type) { |
| + for (var i = this.entries_.length - 1; i >= 0; --i) { |
| + if (this.entries_[i].type == type) { |
| + if ((this.entries_[i].phase != LogEventPhase.PHASE_END) && |
| + (this.entries_[i].phase != LogEventPhase.PHASE_FINISH)) { |
|
mmenke1
2012/02/03 18:32:32
Think checking for PHASE_BEGIN makes the most sens
ahendrickson
2012/02/04 05:27:14
Done.
|
| + return this.entries_[i]; |
| + } |
| + } |
| + } |
| + return undefined; |
| + }, |
| + |
| getLogEntries: function() { |
| return this.entries_; |
| }, |