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: third_party/WebKit/Source/platform/network/ResourceRequest.cpp

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: handle font-display: swap Created 4 years, 2 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/network/ResourceRequest.cpp
diff --git a/third_party/WebKit/Source/platform/network/ResourceRequest.cpp b/third_party/WebKit/Source/platform/network/ResourceRequest.cpp
index 4d264c050380bd298bae9b62e29b41ddb7e3be49..9ccbd1a7736e4ebdea6e94c885b02dad736fc152 100644
--- a/third_party/WebKit/Source/platform/network/ResourceRequest.cpp
+++ b/third_party/WebKit/Source/platform/network/ResourceRequest.cpp
@@ -88,6 +88,8 @@ ResourceRequest::ResourceRequest(CrossThreadResourceRequestData* data)
m_uiStartTime = data->m_uiStartTime;
m_isExternalRequest = data->m_isExternalRequest;
m_inputPerfMetricReportPolicy = data->m_inputPerfMetricReportPolicy;
+ m_isCacheAwareLoadingActivated = data->m_isCacheAwareLoadingActivated;
+ m_savedCachePolicy = data->m_savedCachePolicy;
m_redirectStatus = data->m_redirectStatus;
}
@@ -136,6 +138,8 @@ std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::copyData()
data->m_uiStartTime = m_uiStartTime;
data->m_isExternalRequest = m_isExternalRequest;
data->m_inputPerfMetricReportPolicy = m_inputPerfMetricReportPolicy;
+ data->m_isCacheAwareLoadingActivated = m_isCacheAwareLoadingActivated;
+ data->m_savedCachePolicy = m_savedCachePolicy;
data->m_redirectStatus = m_redirectStatus;
return data;
}
@@ -169,7 +173,17 @@ WebCachePolicy ResourceRequest::getCachePolicy() const {
}
void ResourceRequest::setCachePolicy(WebCachePolicy cachePolicy) {
- m_cachePolicy = cachePolicy;
+ // TODO(632580): Remove after all modifications to ResourceRequest is done
+ // before ResourceFetcher::createResourceForLoading().
+ if (m_isCacheAwareLoadingActivated &&
+ (cachePolicy == WebCachePolicy::ReturnCacheDataDontLoad ||
+ cachePolicy == WebCachePolicy::BypassingCache))
+ deactivateCacheAwareLoading();
+
+ if (m_isCacheAwareLoadingActivated)
+ m_savedCachePolicy = cachePolicy;
+ else
+ m_cachePolicy = cachePolicy;
}
double ResourceRequest::timeoutInterval() const {
@@ -392,6 +406,21 @@ bool ResourceRequest::hasCacheValidatorFields() const {
!m_httpHeaderFields.get(HTTPNames::ETag).isEmpty();
}
+void ResourceRequest::activateCacheAwareLoading() {
+ DCHECK(!m_isCacheAwareLoadingActivated);
+ m_savedCachePolicy = m_cachePolicy;
+ // TODO(652649): Stale data may be retrieved with this flag. Switch to new
+ // flag to load from disk cache with validation when available in net.
+ m_cachePolicy = WebCachePolicy::ReturnCacheDataDontLoad;
+ m_isCacheAwareLoadingActivated = true;
+}
+
+void ResourceRequest::deactivateCacheAwareLoading() {
+ DCHECK(m_isCacheAwareLoadingActivated);
+ m_cachePolicy = m_savedCachePolicy;
+ m_isCacheAwareLoadingActivated = false;
+}
+
void ResourceRequest::initialize(const KURL& url) {
m_url = url;
m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy;
@@ -424,6 +453,8 @@ void ResourceRequest::initialize(const KURL& url) {
m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport;
m_redirectStatus = RedirectStatus::NoRedirect;
m_requestorOrigin = SecurityOrigin::createUnique();
+ m_isCacheAwareLoadingActivated = false;
+ m_savedCachePolicy = WebCachePolicy::UseProtocolCachePolicy;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698