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

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

Issue 2303653002: Precache per-resource cap should be applied on network bytes used (Closed)
Patch Set: Addressed mmenke comments 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
Index: components/precache/core/precache_fetcher.cc
diff --git a/components/precache/core/precache_fetcher.cc b/components/precache/core/precache_fetcher.cc
index 90d05bb776b6eb6b841c69369f29a3acc5846c87..f1c53c6d450f4df2e85ec59c6c2bc94b3c924a4f 100644
--- a/components/precache/core/precache_fetcher.cc
+++ b/components/precache/core/precache_fetcher.cc
@@ -267,17 +267,20 @@ 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();
// Cancel the download.

Powered by Google App Engine
This is Rietveld 408576698