Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: chrome/browser/resources/net_internals/source_entry.js

Issue 9223019: Added net logging to BaseFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..535f5fa6b11fa359bb4041a57c0c6170a9b85cf7 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,17 @@ 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.findLastLogEntryStartByType_(
+ 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 +208,20 @@ var SourceEntry = (function() {
return undefined;
},
+ /**
+ * Returns the last entry with the specified type, or undefined if not
+ * found.
+ */
+ findLastLogEntryStartByType_: 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_BEGIN)
+ return this.entries_[i];
+ }
+ }
+ return undefined;
+ },
+
getLogEntries: function() {
return this.entries_;
},

Powered by Google App Engine
This is Rietveld 408576698