Chromium Code Reviews| 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..5354dc8e35630b99ea2944aee00429f701e5b671 100644 |
| --- a/third_party/WebKit/Source/platform/network/ResourceRequest.cpp |
| +++ b/third_party/WebKit/Source/platform/network/ResourceRequest.cpp |
| @@ -88,6 +88,9 @@ ResourceRequest::ResourceRequest(CrossThreadResourceRequestData* data) |
| m_uiStartTime = data->m_uiStartTime; |
| m_isExternalRequest = data->m_isExternalRequest; |
| m_inputPerfMetricReportPolicy = data->m_inputPerfMetricReportPolicy; |
| + m_isCacheAwareLoadingEnabled = data->m_isCacheAwareLoadingEnabled; |
| + m_isCacheAwareLoadingActivated = data->m_isCacheAwareLoadingActivated; |
| + m_savedCachePolicy = data->m_savedCachePolicy; |
| m_redirectStatus = data->m_redirectStatus; |
| } |
| @@ -136,6 +139,9 @@ std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::copyData() |
| data->m_uiStartTime = m_uiStartTime; |
| data->m_isExternalRequest = m_isExternalRequest; |
| data->m_inputPerfMetricReportPolicy = m_inputPerfMetricReportPolicy; |
| + data->m_isCacheAwareLoadingEnabled = m_isCacheAwareLoadingEnabled; |
| + data->m_isCacheAwareLoadingActivated = m_isCacheAwareLoadingActivated; |
| + data->m_savedCachePolicy = m_savedCachePolicy; |
| data->m_redirectStatus = m_redirectStatus; |
| return data; |
| } |
| @@ -392,6 +398,35 @@ bool ResourceRequest::hasCacheValidatorFields() const { |
| !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty(); |
| } |
| +void ResourceRequest::mayActivateCacheAwareLoading() { |
| + if (!m_isCacheAwareLoadingEnabled) |
| + return; |
|
yhirano
2016/10/06 11:57:06
DCHECK(!m_isCacheAwareLoadingActivated)?
Shao-Chuan Lee
2016/10/07 08:10:07
Done (now in activateCacheAwareLoading()).
|
| + |
| + switch (m_cachePolicy) { |
| + case WebCachePolicy::BypassingCache: |
| + case WebCachePolicy::ReturnCacheDataDontLoad: |
| + return; |
| + case WebCachePolicy::UseProtocolCachePolicy: |
| + case WebCachePolicy::ValidatingCacheData: |
| + case WebCachePolicy::ReturnCacheDataElseLoad: |
| + break; |
| + default: |
|
yhirano
2016/10/06 11:57:06
This section is not needed.
Shao-Chuan Lee
2016/10/07 08:10:07
I'm using this to ensure new flags are handled in
yhirano
2016/10/11 04:17:07
The compiler checks if each switch statement inclu
Shao-Chuan Lee
2016/10/11 07:27:28
I see. Didn't notice we have -Wswitch enabled, tha
|
| + NOTREACHED(); |
| + } |
| + |
| + 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 +459,9 @@ void ResourceRequest::initialize(const KURL& url) { |
| m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; |
| m_redirectStatus = RedirectStatus::NoRedirect; |
| m_requestorOrigin = SecurityOrigin::createUnique(); |
| + m_isCacheAwareLoadingEnabled = false; |
| + m_isCacheAwareLoadingActivated = false; |
| + m_savedCachePolicy = WebCachePolicy::UseProtocolCachePolicy; |
| } |
| } // namespace blink |