diff options
author | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-30 23:02:26 +0000 |
---|---|---|
committer | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-30 23:02:26 +0000 |
commit | 11325a2b36895210fb3c2922e80cdec5e53cb715 (patch) | |
tree | 2f1d159eb47b77d2df6cdc4ce7ea1bbae693443c /content/browser/download | |
parent | e8325ac9da150a03aef94f966da08eaf916378d1 (diff) | |
download | chromium_src-11325a2b36895210fb3c2922e80cdec5e53cb715.zip chromium_src-11325a2b36895210fb3c2922e80cdec5e53cb715.tar.gz chromium_src-11325a2b36895210fb3c2922e80cdec5e53cb715.tar.bz2 |
[Downloads] Some UMA for downloads resumption.
* Count number of requests initiated due to resumption.
* Count downloads that have a strong validator and supports range
requests, since those are candidates for partial resumption.
* Count downloads that are interrupted after the associated WebContents
is destroyed.
BUG=7648
Review URL: https://chromiumcodereview.appspot.com/20609004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214461 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download')
7 files changed, 34 insertions, 8 deletions
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc index b49a256..e54ab9e 100644 --- a/content/browser/download/download_item_impl.cc +++ b/content/browser/download/download_item_impl.cc @@ -1398,6 +1398,8 @@ void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) { TransitionTo(INTERRUPTED_INTERNAL, DONT_UPDATE_OBSERVERS); RecordDownloadInterrupted(reason, received_bytes_, total_bytes_); + if (!GetWebContents()) + RecordDownloadCount(INTERRUPTED_WITHOUT_WEBCONTENTS); AutoResumeIfValid(); UpdateObservers(); diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc index 7d34837..ff5d326 100644 --- a/content/browser/download/download_item_impl_unittest.cc +++ b/content/browser/download/download_item_impl_unittest.cc @@ -496,7 +496,7 @@ TEST_F(DownloadItemTest, LimitRestartsAfterInterrupted) { // to be callled, so we simply verify that GetWebContents() is called. if (i < (DownloadItemImpl::kMaxAutoResumeAttempts - 1)) { EXPECT_CALL(*mock_request_handle, GetWebContents()) - .WillOnce(Return(static_cast<WebContents*>(NULL))); + .WillRepeatedly(Return(static_cast<WebContents*>(NULL))); } // Copied key parts of DoIntermediateRename & AddDownloadFileToDownloadItem diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index 47e3aaa..58fe952 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -524,6 +524,7 @@ void DownloadManagerImpl::OnSavePackageSuccessfullyFinished( void DownloadManagerImpl::ResumeInterruptedDownload( scoped_ptr<content::DownloadUrlParameters> params, uint32 id) { + RecordDownloadSource(INITIATED_BY_RESUMPTION); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index 2a02cf9..3b4844e 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -171,11 +171,10 @@ bool DownloadResourceHandler::OnResponseStarted( const net::HttpResponseHeaders* headers = request_->response_headers(); if (headers) { std::string last_modified_hdr; - std::string etag; if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr)) info->last_modified = last_modified_hdr; - if (headers->EnumerateHeader(NULL, "ETag", &etag)) - info->etag = etag; + if (headers->EnumerateHeader(NULL, "ETag", &etag_)) + info->etag = etag_; int status = headers->response_code(); if (2 == status / 100 && status != net::HTTP_PARTIAL_CONTENT) { @@ -373,7 +372,7 @@ bool DownloadResourceHandler::OnResponseCompleted( } } - RecordAcceptsRanges(accept_ranges_, bytes_read_); + RecordAcceptsRanges(accept_ranges_, bytes_read_, etag_); RecordNetworkBlockage( base::TimeTicks::Now() - download_start_time_, total_pause_time_); diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h index 866bffb..d38068d 100644 --- a/content/browser/download/download_resource_handler.h +++ b/content/browser/download/download_resource_handler.h @@ -126,6 +126,7 @@ class CONTENT_EXPORT DownloadResourceHandler size_t last_buffer_size_; int64 bytes_read_; std::string accept_ranges_; + std::string etag_; int pause_count_; bool was_deferred_; diff --git a/content/browser/download/download_stats.cc b/content/browser/download/download_stats.cc index c1b251d..f8a1e09 100644 --- a/content/browser/download/download_stats.cc +++ b/content/browser/download/download_stats.cc @@ -179,7 +179,8 @@ void RecordDownloadWriteLoopCount(int count) { } void RecordAcceptsRanges(const std::string& accepts_ranges, - int64 download_len) { + int64 download_len, + const std::string& etag) { int64 max = 1024 * 1024 * 1024; // One Terabyte. download_len /= 1024; // In Kilobytes static const int kBuckets = 50; @@ -196,6 +197,10 @@ void RecordAcceptsRanges(const std::string& accepts_ranges, 1, max, kBuckets); + // ETags that start with "W/" are considered weak ETags which don't imply + // byte-wise equality. + if (!StartsWithASCII(etag, "w/", false)) + RecordDownloadCount(STRONG_ETAG_AND_ACCEPTS_RANGES); } else { UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesMissingOrInvalid.KBytes", download_len, diff --git a/content/browser/download/download_stats.h b/content/browser/download/download_stats.h index 287b34d..be2ae4b 100644 --- a/content/browser/download/download_stats.h +++ b/content/browser/download/download_stats.h @@ -68,6 +68,14 @@ enum DownloadCountTypes { // successful invocation of ScanAndSaveDownloadedFile(). FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT, + // Count of downloads that supplies a strong ETag and has a 'Accept-Ranges: + // bytes' header. These downloads are candidates for partial resumption. + STRONG_ETAG_AND_ACCEPTS_RANGES, + + // Count of downloads that didn't have a valid WebContents at the time it was + // interrupted. + INTERRUPTED_WITHOUT_WEBCONTENTS, + DOWNLOAD_COUNT_TYPES_LAST_ENTRY }; @@ -85,6 +93,13 @@ enum DownloadSource { // (e.g. by Alt-click) through the IPC ViewHostMsg_DownloadUrl. INITIATED_BY_RENDERER, + // Fomerly INITIATED_BY_PEPPER_SAVE. + DOWNLOAD_SOURCE_UNUSED_3, + + // A request that was initiated as a result of resuming an interrupted + // download. + INITIATED_BY_RESUMPTION, + DOWNLOAD_SOURCE_LAST_ENTRY }; @@ -141,8 +156,11 @@ void RecordBandwidth(double actual_bandwidth, double potential_bandwidth); // download completed. void RecordOpen(const base::Time& end, bool first); -// Record whether or not the server accepts ranges, and the download size. -void RecordAcceptsRanges(const std::string& accepts_ranges, int64 download_len); +// Record whether or not the server accepts ranges, and the download size. Also +// counts if a strong ETag is supplied. The combination of range request support +// and ETag indicates downloads that are candidates for partial resumption. +void RecordAcceptsRanges(const std::string& accepts_ranges, int64 download_len, + const std::string& etag); // Record the number of downloads removed by ClearAll. void RecordClearAllSize(int size); |