From 4615795e995dea0c7925288929fef3d945ec7b9f Mon Sep 17 00:00:00 2001 From: "ahendrickson@chromium.org" Date: Wed, 7 Sep 2011 19:45:21 +0000 Subject: Added more UMA statistics for downloads. Split from CL 7134019. BUG=None TEST=None Review URL: http://codereview.chromium.org/7778038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99991 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/download/download_item.cc | 2 +- content/browser/download/download_stats.cc | 20 +++++++++++++++++++- content/browser/download/download_stats.h | 14 +++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) (limited to 'content') diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc index 6d9dc303..0809872 100644 --- a/content/browser/download/download_item.cc +++ b/content/browser/download/download_item.cc @@ -409,7 +409,7 @@ void DownloadItem::Completed() { DCHECK(all_data_saved_); TransitionTo(COMPLETE); download_manager_->DownloadCompleted(id()); - download_stats::RecordDownloadCompleted(start_tick_); + download_stats::RecordDownloadCompleted(start_tick_, received_bytes_); if (auto_opened_) { // If it was already handled by the delegate, do nothing. diff --git a/content/browser/download/download_stats.cc b/content/browser/download/download_stats.cc index c51f68a..90d943a 100644 --- a/content/browser/download/download_stats.cc +++ b/content/browser/download/download_stats.cc @@ -22,9 +22,16 @@ void RecordDownloadCount(DownloadCountTypes type) { "Download.Counts", type, DOWNLOAD_COUNT_TYPES_LAST_ENTRY); } -void RecordDownloadCompleted(const base::TimeTicks& start) { +void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len) { RecordDownloadCount(COMPLETED_COUNT); UMA_HISTOGRAM_LONG_TIMES("Download.Time", (base::TimeTicks::Now() - start)); + int64 max = 1024 * 1024 * 1024; // One Terabyte. + download_len /= 1024; // In Kilobytes + UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", + download_len, + 1, + max, + 256); } void RecordDownloadInterrupted(int error, int64 received, int64 total) { @@ -72,6 +79,17 @@ void RecordDownloadInterrupted(int error, int64 received, int64 total) { UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size); } +void RecordDownloadWriteSize(size_t data_len) { + RecordDownloadCount(WRITE_SIZE_COUNT); + int max = 1024 * 1024; // One Megabyte. + UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); +} + +void RecordDownloadWriteLoopCount(int count) { + RecordDownloadCount(WRITE_LOOP_COUNT); + UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); +} + namespace { enum DownloadContent { diff --git a/content/browser/download/download_stats.h b/content/browser/download/download_stats.h index b1e7624..0007bcf 100644 --- a/content/browser/download/download_stats.h +++ b/content/browser/download/download_stats.h @@ -57,6 +57,12 @@ enum DownloadCountTypes { // Downloads that were interrupted by the OS. INTERRUPTED_COUNT, + // Write sizes for downloads. + WRITE_SIZE_COUNT, + + // Counts iterations of the BaseFile::AppendDataToFile() loop. + WRITE_LOOP_COUNT, + DOWNLOAD_COUNT_TYPES_LAST_ENTRY }; @@ -64,7 +70,7 @@ enum DownloadCountTypes { void RecordDownloadCount(DownloadCountTypes type); // Record COMPLETED_COUNT and how long the download took. -void RecordDownloadCompleted(const base::TimeTicks& start); +void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len); // Record INTERRUPTED_COUNT, |error|, |received| and |total| bytes. void RecordDownloadInterrupted(int error, int64 received, int64 total); @@ -72,6 +78,12 @@ void RecordDownloadInterrupted(int error, int64 received, int64 total); // Records the mime type of the download. void RecordDownloadMimeType(const std::string& mime_type); +// Record WRITE_SIZE_COUNT and data_len. +void RecordDownloadWriteSize(size_t data_len); + +// Record WRITE_LOOP_COUNT and number of loops. +void RecordDownloadWriteLoopCount(int count); + } // namespace download_stats #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ -- cgit v1.1