Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
index 81df6c484816d12a0d8424bbaeb03268f83ce3ad..daba5e362fdd19c660cd3e79aefa9f4e4a60adea 100644 |
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
@@ -171,6 +171,7 @@ static ResourceRequestCachePolicy memoryCachePolicyToResourceRequestCachePolicy( |
ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const ResourceRequest& request, Resource::Type type) const |
{ |
+ ASSERT(frame()); |
if (type == Resource::MainResource) { |
FrameLoadType frameLoadType = frame()->loader().loadType(); |
if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBackForward) |
@@ -194,6 +195,21 @@ ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const R |
return UseProtocolCachePolicy; |
} |
+ // For users on slow connections, we want to avoid blocking the parser in |
+ // the main frame on script loads inserted via document.write, since it can |
+ // add significant delays before page content is displayed on the screen. |
+ // For now, as a prototype, we block fetches for main frame scripts |
+ // inserted via document.write as long as the |
+ // disallowFetchForDocWrittenScriptsInMainFrame setting is enabled. In the |
+ // future, we'll extend this logic to only block if estimated network RTT |
+ // is above some threshold. |
+ if (type == Resource::Script && isMainFrame()) { |
+ const bool isInDocumentWrite = m_document && m_document->isInDocumentWrite(); |
+ const bool disallowFetchForDocWriteScripts = frame()->settings() && frame()->settings()->disallowFetchForDocWrittenScriptsInMainFrame(); |
+ if (isInDocumentWrite && disallowFetchForDocWriteScripts) |
+ return ReturnCacheDataDontLoad; |
+ } |
+ |
if (request.isConditional()) |
return ReloadIgnoringCacheData; |