diff options
-rw-r--r-- | chrome/browser/download/download_item.cc | 15 | ||||
-rw-r--r-- | chrome/browser/download/download_item.h | 4 | ||||
-rw-r--r-- | chrome/browser/download/download_util.cc | 13 | ||||
-rw-r--r-- | chrome/browser/download/download_util.h | 16 |
4 files changed, 41 insertions, 7 deletions
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc index f2cc384..eeac2bb 100644 --- a/chrome/browser/download/download_item.cc +++ b/chrome/browser/download/download_item.cc @@ -141,7 +141,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager, state_ = CANCELLED; if (IsComplete()) all_data_saved_ = true; - Init(false /* don't start progress timer */); + Init(false /* not actively downloading */); } // Constructing for a regular download: @@ -178,7 +178,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager, all_data_saved_(false), opened_(false), open_enabled_(true) { - Init(true /* start progress timer */); + Init(true /* actively downloading */); } // Constructing for the "Save Page As..." feature: @@ -207,7 +207,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager, all_data_saved_(false), opened_(false), open_enabled_(true) { - Init(true /* start progress timer */); + Init(true /* actively downloading */); } DownloadItem::~DownloadItem() { @@ -360,7 +360,7 @@ void DownloadItem::Completed() { state_ = COMPLETE; UpdateObservers(); download_manager_->DownloadCompleted(id()); - download_util::RecordDownloadCount(download_util::COMPLETED_COUNT); + download_util::RecordDownloadCompleted(start_tick_); // Handle chrome extensions explicitly and skip the shell execute. if (is_extension_install()) { @@ -390,6 +390,7 @@ void DownloadItem::Interrupted(int64 size, int os_error) { last_os_error_ = os_error; UpdateSize(size); StopProgressTimer(); + download_util::RecordDownloadInterrupted(os_error); UpdateObservers(); } @@ -591,10 +592,12 @@ FilePath DownloadItem::GetUserVerifiedFilePath() const { GetTargetFilePath() : full_path_; } -void DownloadItem::Init(bool start_timer) { +void DownloadItem::Init(bool active) { UpdateTarget(); - if (start_timer) + if (active) { StartProgressTimer(); + download_util::RecordDownloadCount(download_util::START_COUNT); + } VLOG(20) << __FUNCTION__ << "() " << DebugString(true); } diff --git a/chrome/browser/download/download_item.h b/chrome/browser/download/download_item.h index 93acbf3..2e78f50 100644 --- a/chrome/browser/download/download_item.h +++ b/chrome/browser/download/download_item.h @@ -323,7 +323,9 @@ class DownloadItem { #endif private: - void Init(bool start_timer); + // Construction common to all constructors. |active| should be true for new + // downloads and false for downloads from the history. + void Init(bool active); // Internal helper for maintaining consistent received and total sizes. void UpdateSize(int64 size); diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index ee2fe3a..71815ef 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -374,6 +374,19 @@ void RecordDownloadCount(DownloadCountTypes type) { "Download.Counts", type, DOWNLOAD_COUNT_TYPES_LAST_ENTRY); } +void RecordDownloadCompleted(const base::TimeTicks& start) { + download_util::RecordDownloadCount(download_util::COMPLETED_COUNT); + UMA_HISTOGRAM_LONG_TIMES("Download.Time", (base::TimeTicks::Now() - start)); +} + +void RecordDownloadInterrupted(int os_error) { + download_util::RecordDownloadCount(download_util::INTERRUPTED_COUNT); + // |os_error| is probably < 256, so use that as the maximum value of the + // "enum". The histogram implementation uses a separate bucket for any + // unlikely value of os_error >= 256. + UMA_HISTOGRAM_ENUMERATION("Download.InterruptedError", os_error, 0x100); +} + // Download progress painting -------------------------------------------------- // Common bitmaps used for download progress animations. We load them once the diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index 3fedb5a..4634743 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -32,6 +32,10 @@ class SkBitmap; struct DownloadCreateInfo; struct DownloadSaveInfo; +namespace base { +class TimeTicks; +} + namespace content { class ResourceContext; } @@ -159,12 +163,24 @@ enum DownloadCountTypes { // Downloads that are cancelled before completion (user action or error). CANCELLED_COUNT, + // Downloads that are started. Should be equal to UNTHROTTLED_COUNT. + START_COUNT, + + // Downloads that were interrupted by the OS. + INTERRUPTED_COUNT, + DOWNLOAD_COUNT_TYPES_LAST_ENTRY }; // Increment one of the above counts. void RecordDownloadCount(DownloadCountTypes type); +// Record COMPLETED_COUNT and how long the download took. +void RecordDownloadCompleted(const base::TimeTicks& start); + +// Record INTERRUPTED_COUNT and os_error. +void RecordDownloadInterrupted(int os_error); + // Paint the common download animation progress foreground and background, // clipping the foreground to 'percent' full. If percent is -1, then we don't // know the total size, so we just draw a rotating segment until we're done. |