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

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

Issue 2279543004: [DocWriteBlocking] Add feature to block doc.written scripts if 2g-like network (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename Created 4 years, 4 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/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 1d8a489187bf24ba71847999558509e59898b068..f9e4e249a1deea948600756df3064258c112f77a 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -146,10 +146,11 @@ bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch
// the flag will be conveyed to the browser process only once.
document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoadingBehaviorDocumentWriteBlock);
- const bool isSlowConnection = networkStateNotifier().connectionType() == WebConnectionTypeCellular2G;
- const bool disallowFetch = document.settings()->disallowFetchForDocWrittenScriptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections() && isSlowConnection);
+ const bool is2G = networkStateNotifier().connectionType() == WebConnectionTypeCellular2G;
+ WebEffectiveConnectionType effectiveConnection = document.frame()->loader().client()->getEffectiveConnectionType();
+ const bool is2GOrLike2G = is2G || effectiveConnection == WebEffectiveConnectionType::Type2G || effectiveConnection == WebEffectiveConnectionType::TypeSlow2G;
Yoav Weiss 2016/09/04 05:11:43 Would it have been better to change the WebEffecti
jkarlin 2016/09/06 11:58:45 I don't think a strict ordering on the enum makes
- return disallowFetch;
+ return document.settings()->disallowFetchForDocWrittenScriptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections() && is2G) || (RuntimeEnabledFeatures::blockDocWriteIfEffectively2GEnabled() && is2GOrLike2G);
}
} // namespace
« no previous file with comments | « content/public/common/content_features.cc ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698