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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp

Issue 2517983002: [DevTools] Properly handle cache-only requests when cache is disabled (Closed)
Patch Set: Created 4 years, 1 month 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 | « net/http/http_cache_unittest.cc ('k') | third_party/WebKit/public/platform/WebCachePolicy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp
index e648e34b6a7b53fb7aee9b34c829445579d42b10..b0e7fc4027266efe273dcbdb5ba7160efd74219a 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorNetworkAgent.cpp
@@ -116,6 +116,21 @@ bool matches(const String& url, const String& pattern) {
return true;
}
+bool LoadsFromCacheOnly(const ResourceRequest& request) {
+ switch (request.getCachePolicy()) {
+ case WebCachePolicy::UseProtocolCachePolicy:
+ case WebCachePolicy::ValidatingCacheData:
+ case WebCachePolicy::BypassingCache:
+ case WebCachePolicy::ReturnCacheDataElseLoad:
+ return false;
+ case WebCachePolicy::ReturnCacheDataDontLoad:
+ case WebCachePolicy::BypassCacheLoadOnlyFromCache:
+ return true;
+ }
+ NOTREACHED();
+ return false;
+}
+
static std::unique_ptr<protocol::Network::Headers> buildObjectForHeaders(
const HTTPHeaderMap& headers) {
std::unique_ptr<protocol::DictionaryValue> headersObject =
@@ -511,12 +526,6 @@ DEFINE_TRACE(InspectorNetworkAgent) {
}
bool InspectorNetworkAgent::shouldBlockRequest(const ResourceRequest& request) {
- if (m_state->booleanProperty(NetworkAgentState::cacheDisabled, false) &&
- request.requestContext() != WebURLRequest::RequestContextInternal &&
- request.getCachePolicy() == WebCachePolicy::ReturnCacheDataDontLoad) {
- return true;
- }
-
protocol::DictionaryValue* blockedURLs =
m_state->getObject(NetworkAgentState::blockedURLs);
if (!blockedURLs)
@@ -636,12 +645,12 @@ void InspectorNetworkAgent::willSendRequest(
request.setReportRawHeaders(true);
if (m_state->booleanProperty(NetworkAgentState::cacheDisabled, false)) {
- // It shouldn't be a ReturnCacheDataDontLoad request as those are blocked
- // in shouldBlockRequest unless it's from an internal source.
- DCHECK(WebCachePolicy::ReturnCacheDataDontLoad !=
- request.getCachePolicy() ||
- request.requestContext() == WebURLRequest::RequestContextInternal);
- request.setCachePolicy(WebCachePolicy::BypassingCache);
+ if (LoadsFromCacheOnly(request) &&
+ request.requestContext() != WebURLRequest::RequestContextInternal) {
+ request.setCachePolicy(WebCachePolicy::BypassCacheLoadOnlyFromCache);
+ } else {
+ request.setCachePolicy(WebCachePolicy::BypassingCache);
+ }
request.setShouldResetAppCache(true);
}
if (m_state->booleanProperty(NetworkAgentState::bypassServiceWorker, false))
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | third_party/WebKit/public/platform/WebCachePolicy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698