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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc

Issue 2642793005: Create a Lite Page bit for previews and fallback to Lo-Fi (Closed)
Patch Set: Created 3 years, 10 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: components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc
index be76a720fe88e18f1e5acf2b144efd4432e61075..9231ced2cc8dd5671eba7ec26fc31b06922b696c 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc
@@ -958,7 +958,7 @@ bool DataReductionProxyConfig::IsEffectiveConnectionTypeSlowerThanThreshold(
effective_connection_type <= lofi_effective_connection_type_threshold_;
}
-bool DataReductionProxyConfig::ShouldEnableLoFiMode(
+bool DataReductionProxyConfig::ShouldEnableLoFi(
const net::URLRequest& request) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK((request.load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0);
@@ -969,7 +969,7 @@ bool DataReductionProxyConfig::ShouldEnableLoFiMode(
request.context() ? request.context()->network_quality_estimator()
: nullptr;
- bool enable_lofi = ShouldEnableLoFiModeInternal(network_quality_estimator);
+ bool enable_lofi = ShouldEnableLoFiInternal(network_quality_estimator);
if (params::IsLoFiSlowConnectionsOnlyViaFlags() ||
params::IsIncludedInLoFiEnabledFieldTrial()) {
@@ -981,12 +981,26 @@ bool DataReductionProxyConfig::ShouldEnableLoFiMode(
return enable_lofi;
}
+bool DataReductionProxyConfig::ShouldEnableLitePages(
+ const net::URLRequest& request) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK((request.load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0);
+ DCHECK(!request.url().SchemeIsCryptographic());
+
+ net::NetworkQualityEstimator* network_quality_estimator;
+ network_quality_estimator =
+ request.context() ? request.context()->network_quality_estimator()
+ : nullptr;
+
+ return ShouldEnableLitePagesInternal(network_quality_estimator);
bengr 2017/02/15 00:03:47 You could get rid of the temporary: return ShouldE
megjablon 2017/02/16 04:29:09 Done.
+}
+
bool DataReductionProxyConfig::enabled_by_user_and_reachable() const {
DCHECK(thread_checker_.CalledOnValidThread());
return enabled_by_user_ && !unreachable_;
}
-bool DataReductionProxyConfig::ShouldEnableLoFiModeInternal(
+bool DataReductionProxyConfig::ShouldEnableLoFiInternal(
const net::NetworkQualityEstimator* network_quality_estimator) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -1017,6 +1031,36 @@ bool DataReductionProxyConfig::ShouldEnableLoFiModeInternal(
return false;
}
+bool DataReductionProxyConfig::ShouldEnableLitePagesInternal(
+ const net::NetworkQualityEstimator* network_quality_estimator) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ // If Lo-Fi has been turned off, its status can't change. This Lo-Fi bit will
+ // be removed when Lo-Fi and Lite Pages are moved over to using the Previews
+ // blacklist.
+ if (lofi_off_)
+ return false;
+
+ // TODO: Move the Lo-Fi flag to a flag supporting all Previews types.
bengr 2017/02/15 00:03:47 TODO(megjablon):
megjablon 2017/02/16 04:29:09 Removing since we should discuss how we want the h
+ if (params::IsLoFiAlwaysOnViaFlags() && params::AreLitePagesEnabledViaFlags())
+ return true;
+
+ if (params::IsLoFiCellularOnlyViaFlags() &&
+ params::AreLitePagesEnabledViaFlags()) {
+ return net::NetworkChangeNotifier::IsConnectionCellular(
+ net::NetworkChangeNotifier::GetConnectionType());
+ }
+
+ if ((params::IsLoFiSlowConnectionsOnlyViaFlags() &&
+ params::AreLitePagesEnabledViaFlags()) ||
+ params::IsIncludedInLitePageFieldTrial() ||
+ params::IsIncludedInLoFiControlFieldTrial()) {
+ return IsNetworkQualityProhibitivelySlow(network_quality_estimator);
+ }
+
+ return false;
+}
+
void DataReductionProxyConfig::GetNetworkList(
net::NetworkInterfaceList* interfaces,
int policy) {

Powered by Google App Engine
This is Rietveld 408576698