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

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 1512783002: disable fetches for parser blocking scripts inserted via doc.write (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « third_party/WebKit/Source/core/frame/Settings.in ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « third_party/WebKit/Source/core/frame/Settings.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698