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

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

Issue 2864333003: Use the Previews Black List for server previews (Closed)
Patch Set: deps change Created 3 years, 7 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 4f81a26e3f2c931930ccc011580ce6bc7d9aaa7d..800bc923f4417c1b3e66f7da76ba7ada9757b72e 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
@@ -29,11 +29,13 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/data_use_measurement/core/data_use_user_data.h"
+#include "components/previews/core/previews_decider.h"
#include "components/variations/variations_associated_data.h"
#include "net/base/host_port_pair.h"
#include "net/base/load_flags.h"
#include "net/base/network_change_notifier.h"
#include "net/log/net_log_source_type.h"
+#include "net/nqe/effective_connection_type.h"
#include "net/proxy/proxy_server.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -955,17 +957,14 @@ bool DataReductionProxyConfig::IsEffectiveConnectionTypeSlowerThanThreshold(
}
bool DataReductionProxyConfig::ShouldEnableLoFi(
- const net::URLRequest& request) {
+ const net::URLRequest& request,
+ previews::PreviewsDecider* previews_decider) {
+ DCHECK(previews_decider);
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;
-
- bool enable_lofi = ShouldEnableLoFiInternal(network_quality_estimator);
+ bool enable_lofi = ShouldEnableLoFiInternal(request, previews_decider);
if (params::IsLoFiSlowConnectionsOnlyViaFlags() ||
params::IsIncludedInLoFiEnabledFieldTrial()) {
@@ -978,14 +977,14 @@ bool DataReductionProxyConfig::ShouldEnableLoFi(
}
bool DataReductionProxyConfig::ShouldEnableLitePages(
- const net::URLRequest& request) {
+ const net::URLRequest& request,
+ previews::PreviewsDecider* previews_decider) {
+ DCHECK(previews_decider);
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK((request.load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0);
DCHECK(!request.url().SchemeIsCryptographic());
- return ShouldEnableLitePagesInternal(
- request.context() ? request.context()->network_quality_estimator()
- : nullptr);
+ return ShouldEnableLitePagesInternal(request, previews_decider);
}
bool DataReductionProxyConfig::enabled_by_user_and_reachable() const {
@@ -994,15 +993,28 @@ bool DataReductionProxyConfig::enabled_by_user_and_reachable() const {
}
bool DataReductionProxyConfig::ShouldEnableLoFiInternal(
- const net::NetworkQualityEstimator* network_quality_estimator) {
+ const net::URLRequest& request,
+ previews::PreviewsDecider* previews_decider) {
DCHECK(thread_checker_.CalledOnValidThread());
last_query_ = GetTicksNow();
network_quality_at_last_query_ = NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN;
- // If Lo-Fi has been turned off, its status can't change.
- if (lofi_off_)
+ if (params::IsBlackListEnabledForServerPreviews()) {
+ // Pass in net::EFFECTIVE_CONNECTION_TYPE_4G as the thresold as network
+ // speed is checked in IsNetworkQualityProhibitivelySlow().
megjablon 2017/05/09 19:58:33 Can we have ShouldAllowPreviewAtECT check the NQE
RyanSturm 2017/05/09 22:35:19 Done. This is slightly complicated based on other
+ if (!previews_decider->ShouldAllowPreviewAtECT(
+ request, previews::PreviewsType::LOFI,
+ net::EFFECTIVE_CONNECTION_TYPE_4G)) {
+ return false;
+ }
+ } else if (lofi_off_) {
+ // 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.
megjablon 2017/05/09 19:58:33 Fix comment formatting
RyanSturm 2017/05/09 22:35:19 Done.
return false;
+ }
if (params::IsLoFiAlwaysOnViaFlags())
return true;
@@ -1011,6 +1023,11 @@ bool DataReductionProxyConfig::ShouldEnableLoFiInternal(
return net::NetworkChangeNotifier::IsConnectionCellular(connection_type_);
}
+ net::NetworkQualityEstimator* network_quality_estimator;
+ network_quality_estimator =
+ request.context() ? request.context()->network_quality_estimator()
+ : nullptr;
+
if (params::IsLoFiSlowConnectionsOnlyViaFlags() ||
params::IsIncludedInLoFiEnabledFieldTrial() ||
params::IsIncludedInLoFiControlFieldTrial()) {
@@ -1021,14 +1038,25 @@ bool DataReductionProxyConfig::ShouldEnableLoFiInternal(
}
bool DataReductionProxyConfig::ShouldEnableLitePagesInternal(
- const net::NetworkQualityEstimator* network_quality_estimator) {
+ const net::URLRequest& request,
+ previews::PreviewsDecider* previews_decider) {
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_)
+ if (params::IsBlackListEnabledForServerPreviews()) {
megjablon 2017/05/09 19:58:33 Same two comments as above
RyanSturm 2017/05/09 22:35:19 Done.
+ // Pass in net::EFFECTIVE_CONNECTION_TYPE_4G as the thresold as network
+ // speed is checked in IsNetworkQualityProhibitivelySlow().
+ if (!previews_decider->ShouldAllowPreviewAtECT(
+ request, previews::PreviewsType::LITE_PAGE,
+ net::EFFECTIVE_CONNECTION_TYPE_4G)) {
+ return false;
+ }
+ } else if (lofi_off_) {
+ // 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.
return false;
+ }
if (params::IsLoFiAlwaysOnViaFlags() && params::AreLitePagesEnabledViaFlags())
return true;
@@ -1038,6 +1066,10 @@ bool DataReductionProxyConfig::ShouldEnableLitePagesInternal(
return net::NetworkChangeNotifier::IsConnectionCellular(
net::NetworkChangeNotifier::GetConnectionType());
}
+ net::NetworkQualityEstimator* network_quality_estimator;
+ network_quality_estimator =
+ request.context() ? request.context()->network_quality_estimator()
+ : nullptr;
if ((params::IsLoFiSlowConnectionsOnlyViaFlags() &&
params::AreLitePagesEnabledViaFlags()) ||

Powered by Google App Engine
This is Rietveld 408576698