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

Unified Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2714383003: Reduce FetchContext::getCachePolicy() callers (Closed)
Patch Set: rebase Created 3 years, 10 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: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
index 1fc42794b8dc26b911c527e9d74d22d039a73e3c..e02e3d56ec6b5048d5842f0217ed8e96a01009fa 100644
--- a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
@@ -683,8 +683,10 @@ void ResourceFetcher::initializeRevalidation(
const AtomicString& eTag =
resource->response().httpHeaderField(HTTPNames::ETag);
if (!lastModified.isEmpty() || !eTag.isEmpty()) {
- DCHECK_NE(context().getCachePolicy(), CachePolicyReload);
- if (context().getCachePolicy() == CachePolicyRevalidate) {
+ DCHECK_NE(WebCachePolicy::BypassingCache,
+ revalidatingRequest.getCachePolicy());
+ if (revalidatingRequest.getCachePolicy() ==
+ WebCachePolicy::ValidatingCacheData) {
revalidatingRequest.setHTTPHeaderField(HTTPNames::Cache_Control,
"max-age=0");
}
@@ -863,8 +865,9 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
//
// TODO(japhet): Can we get rid of one of these settings?
if (existingResource->isImage() &&
- !context().allowImage(m_imagesEnabled, existingResource->url()))
+ !context().allowImage(m_imagesEnabled, existingResource->url())) {
return Reload;
+ }
// Never use cache entries for downloadToFile / useStreamOnResponse requests.
// The data will be delivered through other paths.
@@ -876,8 +879,9 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
if (existingResource->response().wasFetchedViaServiceWorker() &&
existingResource->response().serviceWorkerResponseType() ==
WebServiceWorkerResponseTypeOpaque &&
- request.fetchRequestMode() != WebURLRequest::FetchRequestModeNoCORS)
+ request.fetchRequestMode() != WebURLRequest::FetchRequestModeNoCORS) {
return Reload;
+ }
// If resource was populated from a SubstituteData load or data: url, use it.
if (isStaticData)
@@ -898,8 +902,9 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
// In this case, the Resource likely has insufficient context to provide a
// useful cache hit or revalidation. See http://crbug.com/643659
if (request.isConditional() ||
- existingResource->response().httpStatusCode() == 304)
+ existingResource->response().httpStatusCode() == 304) {
return Reload;
+ }
// Don't reload resources while pasting.
if (m_allowStaleResources)
@@ -912,9 +917,8 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
if (existingResource->isPreloaded())
return Use;
- // CachePolicyHistoryBuffer uses the cache no matter what.
- CachePolicy cachePolicy = context().getCachePolicy();
- if (cachePolicy == CachePolicyHistoryBuffer)
+ // WebCachePolicy::ReturnCacheDataElseLoad uses the cache no matter what.
+ if (request.getCachePolicy() == WebCachePolicy::ReturnCacheDataElseLoad)
return Use;
// Don't reuse resources with Cache-control: no-store.
@@ -951,21 +955,19 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
return Use;
}
- if (request.getCachePolicy() == WebCachePolicy::BypassingCache)
- return Reload;
-
- // CachePolicyReload always reloads
- if (cachePolicy == CachePolicyReload) {
+ // WebCachePolicy::BypassingCache always reloads
+ if (request.getCachePolicy() == WebCachePolicy::BypassingCache) {
RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy "
- "reloading due to CachePolicyReload.";
+ "reloading due to "
+ "WebCachePolicy::BypassingCache.";
return Reload;
}
// We'll try to reload the resource if it failed last time.
if (existingResource->errorOccurred()) {
- RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::"
- "determineRevalidationPolicye reloading due "
- "to resource being in the error state";
+ RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy "
+ "reloading due to resource being in the error "
+ "state";
return Reload;
}
@@ -973,8 +975,9 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
// validation. We restrict this only to images from memory cache which are the
// same as the version in the current document.
if (type == Resource::Image &&
- existingResource == cachedResource(request.url()))
+ existingResource == cachedResource(request.url())) {
return Use;
+ }
if (existingResource->mustReloadDueToVaryHeader(request))
return Reload;
@@ -989,7 +992,7 @@ ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
// Check if the cache headers requires us to revalidate (cache expiration for
// example).
- if (cachePolicy == CachePolicyRevalidate ||
+ if (request.getCachePolicy() == WebCachePolicy::ValidatingCacheData ||
existingResource->mustRevalidateDueToCacheHeaders() ||
request.cacheControlContainsNoCache()) {
// See if the resource has usable ETag or Last-modified headers. If the page

Powered by Google App Engine
This is Rietveld 408576698