diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-18 16:35:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-18 15:45:54 +0000 |
commit | 32f5a1c56531e4210bc4cf8d8c7825d66e081888 (patch) | |
tree | eeeec6822f4d738d8454525233fd0e2e3a659e6d /chromium/net/http/http_cache_transaction.cc | |
parent | 99677208ff3b216fdfec551fbe548da5520cd6fb (diff) | |
download | qtwebengine-chromium-32f5a1c56531e4210bc4cf8d8c7825d66e081888.tar.gz |
BASELINE: Update Chromium to 87.0.4280.67
Change-Id: Ib157360be8c2ffb2c73125751a89f60e049c1d54
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/http/http_cache_transaction.cc')
-rw-r--r-- | chromium/net/http/http_cache_transaction.cc | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/chromium/net/http/http_cache_transaction.cc b/chromium/net/http/http_cache_transaction.cc index 9d5bc7f30c3..663677c5865 100644 --- a/chromium/net/http/http_cache_transaction.cc +++ b/chromium/net/http/http_cache_transaction.cc @@ -2632,28 +2632,39 @@ int HttpCache::Transaction::ValidateEntryHeadersAndContinue() { return OK; } -int HttpCache::Transaction::BeginExternallyConditionalizedRequest() { - DCHECK_EQ(UPDATE, mode_); +bool HttpCache::Transaction:: + ExternallyConditionalizedValidationHeadersMatchEntry() const { DCHECK(external_validation_.initialized); for (size_t i = 0; i < base::size(kValidationHeaders); i++) { if (external_validation_.values[i].empty()) continue; + // Retrieve either the cached response's "etag" or "last-modified" header. std::string validator; response_.headers->EnumerateHeader( nullptr, kValidationHeaders[i].related_response_header_name, &validator); - if (response_.headers->response_code() != 200 || truncated_ || - validator.empty() || validator != external_validation_.values[i]) { - // The externally conditionalized request is not a validation request - // for our existing cache entry. Proceed with caching disabled. - UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); - DoneWithEntry(true); + if (validator != external_validation_.values[i]) { + return false; } } + return true; +} + +int HttpCache::Transaction::BeginExternallyConditionalizedRequest() { + DCHECK_EQ(UPDATE, mode_); + + if (response_.headers->response_code() != 200 || truncated_ || + !ExternallyConditionalizedValidationHeadersMatchEntry()) { + // The externally conditionalized request is not a validation request + // for our existing cache entry. Proceed with caching disabled. + UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_OTHER); + DoneWithEntry(true); + } + TransitionToState(STATE_SEND_REQUEST); return OK; } @@ -3601,13 +3612,17 @@ void HttpCache::Transaction::TransitionToState(State state) { bool HttpCache::Transaction::ShouldDisableCaching( const HttpResponseHeaders* headers) const { bool disable_caching = false; - if (base::FeatureList::IsEnabled(features::kTurnOffStreamingMediaCaching) && - IsOnBatteryPower()) { - // If we're running on battery, and the acquired content is 'large' and - // not already cached, and we have a MIME type of audio or video, then - // disable the cache for this response. We based our initial definition of - // 'large' on the disk cache maximum block size of 16K, which we observed - // captures the majority of responses from various MSE implementations. + if (base::FeatureList::IsEnabled( + features::kTurnOffStreamingMediaCachingAlways) || + (base::FeatureList::IsEnabled( + features::kTurnOffStreamingMediaCachingOnBattery) && + IsOnBatteryPower())) { + // If the feature is always enabled or enabled while we're running on + // battery, and the acquired content is 'large' and not already cached, and + // we have a MIME type of audio or video, then disable the cache for this + // response. We based our initial definition of 'large' on the disk cache + // maximum block size of 16K, which we observed captures the majority of + // responses from various MSE implementations. static constexpr int kMaxContentSize = 4096 * 4; std::string mime_type; base::CompareCase insensitive_ascii = base::CompareCase::INSENSITIVE_ASCII; |