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

Unified Diff: components/precache/core/precache_fetcher.cc

Issue 2378173002: Precache per-resource cap should be applied on network bytes used (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « components/precache/core/precache_fetcher.h ('k') | components/search_provider_logos/logo_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/precache/core/precache_fetcher.cc
diff --git a/components/precache/core/precache_fetcher.cc b/components/precache/core/precache_fetcher.cc
index 191807a72841dd6ccf158269f7464c3ccb4e93ce..bceb2a20d3af62618fd010a148cca3547c300e96 100644
--- a/components/precache/core/precache_fetcher.cc
+++ b/components/precache/core/precache_fetcher.cc
@@ -286,23 +286,25 @@ void PrecacheFetcher::Fetcher::LoadFromNetwork() {
void PrecacheFetcher::Fetcher::OnURLFetchDownloadProgress(
const net::URLFetcher* source,
int64_t current,
- int64_t total) {
- // If going over the per-resource download cap.
+ int64_t total,
+ int64_t current_network_bytes) {
+ // If network bytes going over the per-resource download cap.
if (fetch_stage_ == FetchStage::NETWORK &&
- // |current| is guaranteed to be non-negative, so this cast is safe.
- static_cast<size_t>(std::max(current, total)) > max_bytes_) {
+ // |current_network_bytes| is guaranteed to be non-negative, so this cast
+ // is safe.
+ static_cast<size_t>(current_network_bytes) > max_bytes_) {
VLOG(1) << "Cancelling " << url_ << ": (" << current << "/" << total
<< ") is over " << max_bytes_;
// Call the completion callback, to attempt the next download, or to trigger
// cleanup in precache_delegate_->OnDone().
- response_bytes_ = network_response_bytes_ = current;
+ response_bytes_ = current;
+ network_response_bytes_ = current_network_bytes;
was_cached_ = source->WasCached();
UMA_HISTOGRAM_CUSTOM_COUNTS("Precache.Fetch.ResponseBytes.NetworkWasted",
network_response_bytes_, 1,
1024 * 1024 /* 1 MB */, 100);
-
// Cancel the download.
network_url_fetcher_.reset();
callback_.Run(*this);
« no previous file with comments | « components/precache/core/precache_fetcher.h ('k') | components/search_provider_logos/logo_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698