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

Side by Side 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: remove unused frame_messages.h code Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 962
963 accuracy_histogram->Add(accuracy); 963 accuracy_histogram->Add(accuracy);
964 } 964 }
965 965
966 bool DataReductionProxyConfig::IsEffectiveConnectionTypeSlowerThanThreshold( 966 bool DataReductionProxyConfig::IsEffectiveConnectionTypeSlowerThanThreshold(
967 net::EffectiveConnectionType effective_connection_type) const { 967 net::EffectiveConnectionType effective_connection_type) const {
968 return effective_connection_type >= net::EFFECTIVE_CONNECTION_TYPE_OFFLINE && 968 return effective_connection_type >= net::EFFECTIVE_CONNECTION_TYPE_OFFLINE &&
969 effective_connection_type <= lofi_effective_connection_type_threshold_; 969 effective_connection_type <= lofi_effective_connection_type_threshold_;
970 } 970 }
971 971
972 bool DataReductionProxyConfig::ShouldEnableLoFiMode( 972 bool DataReductionProxyConfig::ShouldEnableLoFi(
973 const net::URLRequest& request) { 973 const net::URLRequest& request) {
974 DCHECK(thread_checker_.CalledOnValidThread()); 974 DCHECK(thread_checker_.CalledOnValidThread());
975 DCHECK((request.load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0); 975 DCHECK((request.load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0);
976 DCHECK(!request.url().SchemeIsCryptographic()); 976 DCHECK(!request.url().SchemeIsCryptographic());
977 977
978 net::NetworkQualityEstimator* network_quality_estimator; 978 net::NetworkQualityEstimator* network_quality_estimator;
979 network_quality_estimator = 979 network_quality_estimator =
980 request.context() ? request.context()->network_quality_estimator() 980 request.context() ? request.context()->network_quality_estimator()
981 : nullptr; 981 : nullptr;
982 982
983 bool enable_lofi = ShouldEnableLoFiModeInternal(network_quality_estimator); 983 bool enable_lofi = ShouldEnableLoFiInternal(network_quality_estimator);
984 984
985 if (params::IsLoFiSlowConnectionsOnlyViaFlags() || 985 if (params::IsLoFiSlowConnectionsOnlyViaFlags() ||
986 params::IsIncludedInLoFiEnabledFieldTrial()) { 986 params::IsIncludedInLoFiEnabledFieldTrial()) {
987 RecordAutoLoFiRequestHeaderStateChange( 987 RecordAutoLoFiRequestHeaderStateChange(
988 connection_type_, previous_state_lofi_on_, enable_lofi); 988 connection_type_, previous_state_lofi_on_, enable_lofi);
989 previous_state_lofi_on_ = enable_lofi; 989 previous_state_lofi_on_ = enable_lofi;
990 } 990 }
991 991
992 return enable_lofi; 992 return enable_lofi;
993 } 993 }
994 994
995 bool DataReductionProxyConfig::ShouldEnableLitePages(
996 const net::URLRequest& request) {
997 DCHECK(thread_checker_.CalledOnValidThread());
998 DCHECK((request.load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0);
999 DCHECK(!request.url().SchemeIsCryptographic());
1000
1001 return ShouldEnableLitePagesInternal(
1002 request.context() ? request.context()->network_quality_estimator()
1003 : nullptr);
1004 }
1005
995 bool DataReductionProxyConfig::enabled_by_user_and_reachable() const { 1006 bool DataReductionProxyConfig::enabled_by_user_and_reachable() const {
996 DCHECK(thread_checker_.CalledOnValidThread()); 1007 DCHECK(thread_checker_.CalledOnValidThread());
997 return enabled_by_user_ && !unreachable_; 1008 return enabled_by_user_ && !unreachable_;
998 } 1009 }
999 1010
1000 bool DataReductionProxyConfig::ShouldEnableLoFiModeInternal( 1011 bool DataReductionProxyConfig::ShouldEnableLoFiInternal(
1001 const net::NetworkQualityEstimator* network_quality_estimator) { 1012 const net::NetworkQualityEstimator* network_quality_estimator) {
1002 DCHECK(thread_checker_.CalledOnValidThread()); 1013 DCHECK(thread_checker_.CalledOnValidThread());
1003 1014
1004 last_query_ = GetTicksNow(); 1015 last_query_ = GetTicksNow();
1005 network_quality_at_last_query_ = NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN; 1016 network_quality_at_last_query_ = NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN;
1006 1017
1007 // If Lo-Fi has been turned off, its status can't change. 1018 // If Lo-Fi has been turned off, its status can't change.
1008 if (lofi_off_) 1019 if (lofi_off_)
1009 return false; 1020 return false;
1010 1021
1011 if (params::IsLoFiAlwaysOnViaFlags()) 1022 if (params::IsLoFiAlwaysOnViaFlags())
1012 return true; 1023 return true;
1013 1024
1014 if (params::IsLoFiCellularOnlyViaFlags()) { 1025 if (params::IsLoFiCellularOnlyViaFlags()) {
1015 return net::NetworkChangeNotifier::IsConnectionCellular(connection_type_); 1026 return net::NetworkChangeNotifier::IsConnectionCellular(connection_type_);
1016 } 1027 }
1017 1028
1018 if (params::IsLoFiSlowConnectionsOnlyViaFlags() || 1029 if (params::IsLoFiSlowConnectionsOnlyViaFlags() ||
1019 params::IsIncludedInLoFiEnabledFieldTrial() || 1030 params::IsIncludedInLoFiEnabledFieldTrial() ||
1020 params::IsIncludedInLoFiControlFieldTrial()) { 1031 params::IsIncludedInLoFiControlFieldTrial()) {
1021 return IsNetworkQualityProhibitivelySlow(network_quality_estimator); 1032 return IsNetworkQualityProhibitivelySlow(network_quality_estimator);
1022 } 1033 }
1023 1034
1024 // If Lo-Fi is not enabled through command line and the user is not in 1035 // If Lo-Fi is not enabled through command line and the user is not in
1025 // Lo-Fi field trials, set Lo-Fi to off. 1036 // Lo-Fi field trials, set Lo-Fi to off.
1026 lofi_off_ = true; 1037 lofi_off_ = true;
1027 return false; 1038 return false;
1028 } 1039 }
1029 1040
1041 bool DataReductionProxyConfig::ShouldEnableLitePagesInternal(
1042 const net::NetworkQualityEstimator* network_quality_estimator) {
1043 DCHECK(thread_checker_.CalledOnValidThread());
1044
1045 // If Lo-Fi has been turned off, its status can't change. This Lo-Fi bit will
1046 // be removed when Lo-Fi and Lite Pages are moved over to using the Previews
1047 // blacklist.
1048 if (lofi_off_)
1049 return false;
1050
1051 if (params::IsLoFiAlwaysOnViaFlags() && params::AreLitePagesEnabledViaFlags())
1052 return true;
1053
1054 if (params::IsLoFiCellularOnlyViaFlags() &&
1055 params::AreLitePagesEnabledViaFlags()) {
1056 return net::NetworkChangeNotifier::IsConnectionCellular(
1057 net::NetworkChangeNotifier::GetConnectionType());
1058 }
1059
1060 if ((params::IsLoFiSlowConnectionsOnlyViaFlags() &&
1061 params::AreLitePagesEnabledViaFlags()) ||
1062 params::IsIncludedInLitePageFieldTrial() ||
1063 params::IsIncludedInLoFiControlFieldTrial()) {
1064 return IsNetworkQualityProhibitivelySlow(network_quality_estimator);
1065 }
1066
1067 return false;
1068 }
1069
1030 void DataReductionProxyConfig::GetNetworkList( 1070 void DataReductionProxyConfig::GetNetworkList(
1031 net::NetworkInterfaceList* interfaces, 1071 net::NetworkInterfaceList* interfaces,
1032 int policy) { 1072 int policy) {
1033 net::GetNetworkList(interfaces, policy); 1073 net::GetNetworkList(interfaces, policy);
1034 } 1074 }
1035 1075
1036 const std::vector<base::TimeDelta>& 1076 const std::vector<base::TimeDelta>&
1037 DataReductionProxyConfig::GetLofiAccuracyRecordingIntervals() const { 1077 DataReductionProxyConfig::GetLofiAccuracyRecordingIntervals() const {
1038 DCHECK(thread_checker_.CalledOnValidThread()); 1078 DCHECK(thread_checker_.CalledOnValidThread());
1039 return lofi_accuracy_recording_intervals_; 1079 return lofi_accuracy_recording_intervals_;
(...skipping 20 matching lines...) Expand all
1060 DataReductionProxyConfig::GetProxiesForHttp() const { 1100 DataReductionProxyConfig::GetProxiesForHttp() const {
1061 DCHECK(thread_checker_.CalledOnValidThread()); 1101 DCHECK(thread_checker_.CalledOnValidThread());
1062 1102
1063 if (!enabled_by_user_) 1103 if (!enabled_by_user_)
1064 return std::vector<DataReductionProxyServer>(); 1104 return std::vector<DataReductionProxyServer>();
1065 1105
1066 return config_values_->proxies_for_http(); 1106 return config_values_->proxies_for_http();
1067 } 1107 }
1068 1108
1069 } // namespace data_reduction_proxy 1109 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698