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

Unified Diff: net/http/http_cache_transaction.cc

Issue 2089783002: [net/cache] Avoid the cache for responses exceeding 2GB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index a782d52c3e5dbc74ac84643b6291599f9ea1b0c3..7886f5b3fc604760edd82c0447bf1ee711d01e57 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -1173,11 +1173,31 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) {
return OnCacheReadError(result, true);
}
+ const int current_size =
+ entry_->disk_entry->GetDataSize(kResponseContentIndex);
+ const int64_t full_response_length = response_.headers->GetContentLength();
mmenke 2016/06/22 15:50:26 nit: const is generally not used for runtime cons
asanka 2016/06/22 16:31:21 Done.
+
// Some resources may have slipped in as truncated when they're not.
- int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex);
- if (response_.headers->GetContentLength() == current_size)
+ if (full_response_length == current_size)
truncated_ = false;
+ // The SM's handling of StopCaching unfortunately doesn't deal well with
mmenke 2016/06/22 15:50:26 Please don't use uncommon abbreviations in comment
asanka 2016/06/22 16:31:21 I was trying to be cool and use abbreviations foun
+ // resources that are larger than 2GB when there is a truncated or sparse
+ // cache entry. While the SM is reworked to resolve this, the following logic
+ // is put in place to defer such requests to the network. The cache should not
+ // be storing multi gigabyte resources. See http://crbug.com/89567.
+ if ((truncated_ || response_.headers->response_code() == 206) &&
+ !range_requested_ &&
+ full_response_length > std::numeric_limits<int32_t>::max()) {
+ // Does not yield the cache lock. If another transaction starts for this
mmenke 2016/06/22 15:50:25 "Does not yield the cache lock" -> "Does not yield
asanka 2016/06/22 16:31:21 Reworded to say 'Does not release the cache entry'
+ // cache entry while this transaction is active, the second transaction will
+ // fallback to the network after the timeout.
mmenke 2016/06/22 15:50:26 fallback -> fall back ("fallback" is a noun)
asanka 2016/06/22 16:31:21 Done.
+ DCHECK(!partial_.get());
mmenke 2016/06/22 15:50:26 nit: .get() not needed.
asanka 2016/06/22 16:31:21 Done.
+ mode_ = NONE;
+ next_state_ = STATE_SEND_REQUEST;
+ return OK;
+ }
+
if ((response_.unused_since_prefetch &&
!(request_->load_flags & LOAD_PREFETCH)) ||
(!response_.unused_since_prefetch &&
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698