Commit d507116d authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Separate out triggering ECT for LitePageRedirect

Separate out triggering effective connection type
for LitePageRedirect feature. For LPR, we first
determine the ECT using LitePageRedirect feature.
If there is none present, we fallback to using
kClientSidePreviewsFieldTrial. If ECT is missing there as well,
a hardcoced value of 2G is used.

Change-Id: Ie8eb8119edaa80baaea528991dbfc59be0d57764
Bug: 1012023
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1858296
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707102}
parent 4f967db1
...@@ -335,11 +335,37 @@ net::EffectiveConnectionType GetECTThresholdForPreview( ...@@ -335,11 +335,37 @@ net::EffectiveConnectionType GetECTThresholdForPreview(
previews::PreviewsType type) { previews::PreviewsType type) {
switch (type) { switch (type) {
case PreviewsType::OFFLINE: case PreviewsType::OFFLINE:
return GetParamValueAsECTByFeature(features::kOfflinePreviews,
kEffectiveConnectionTypeThreshold,
net::EFFECTIVE_CONNECTION_TYPE_2G);
case PreviewsType::NOSCRIPT: case PreviewsType::NOSCRIPT:
case PreviewsType::LITE_PAGE_REDIRECT: return GetParamValueAsECTByFeature(features::kNoScriptPreviews,
return GetParamValueAsECT(kClientSidePreviewsFieldTrial, kEffectiveConnectionTypeThreshold,
kEffectiveConnectionTypeThreshold, net::EFFECTIVE_CONNECTION_TYPE_2G);
net::EFFECTIVE_CONNECTION_TYPE_2G); case PreviewsType::LITE_PAGE_REDIRECT: {
// First check ECT threshold in kLitePageServerPreviews and return that
// (if it's available).
net::EffectiveConnectionType lite_page_ect = GetParamValueAsECTByFeature(
features::kLitePageServerPreviews, kEffectiveConnectionTypeThreshold,
net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN);
if (lite_page_ect != net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN)
return lite_page_ect;
// Next check ECT threshold in kClientSidePreviewsFieldTrial and return
// that (if it's available). In M-78, the ECT threshold for
// LITE_PAGE_REDIRECT is determined from kClientSidePreviewsFieldTrial.
// So, checking kClientSidePreviewsFieldTrial makes the code backwards
// compatible.
net::EffectiveConnectionType client_side_ect = GetParamValueAsECT(
kClientSidePreviewsFieldTrial, kEffectiveConnectionTypeThreshold,
net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN);
if (client_side_ect != net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN)
return client_side_ect;
// Return the default value.
return net::EFFECTIVE_CONNECTION_TYPE_2G;
}
case PreviewsType::LITE_PAGE: case PreviewsType::LITE_PAGE:
NOTREACHED(); NOTREACHED();
break; break;
......
...@@ -46,6 +46,11 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { ...@@ -46,6 +46,11 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) {
params::OfflinePreviewFreshnessDuration()); params::OfflinePreviewFreshnessDuration());
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G, EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::OFFLINE)); params::GetECTThresholdForPreview(PreviewsType::OFFLINE));
EXPECT_EQ(
net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::LITE_PAGE_REDIRECT));
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::NOSCRIPT));
EXPECT_EQ(0, params::OfflinePreviewsVersion()); EXPECT_EQ(0, params::OfflinePreviewsVersion());
base::FieldTrialList field_trial_list(nullptr); base::FieldTrialList field_trial_list(nullptr);
...@@ -80,13 +85,62 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { ...@@ -80,13 +85,62 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) {
EXPECT_EQ(base::TimeDelta::FromSeconds(28), params::SingleOptOutDuration()); EXPECT_EQ(base::TimeDelta::FromSeconds(28), params::SingleOptOutDuration());
EXPECT_EQ(base::TimeDelta::FromDays(12), EXPECT_EQ(base::TimeDelta::FromDays(12),
params::OfflinePreviewFreshnessDuration()); params::OfflinePreviewFreshnessDuration());
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_4G, EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::OFFLINE)); params::GetECTThresholdForPreview(PreviewsType::OFFLINE));
EXPECT_EQ(
net::EFFECTIVE_CONNECTION_TYPE_4G,
params::GetECTThresholdForPreview(PreviewsType::LITE_PAGE_REDIRECT));
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::NOSCRIPT));
EXPECT_EQ(10, params::OfflinePreviewsVersion()); EXPECT_EQ(10, params::OfflinePreviewsVersion());
variations::testing::ClearAllVariationParams(); variations::testing::ClearAllVariationParams();
} }
// Verifies that the default params are correct, and that custom params can be
// set, for both the previews blacklist and offline previews.
TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline_LPR) {
// Verify that the default params are correct.
EXPECT_EQ(4u, params::MaxStoredHistoryLengthForPerHostBlackList());
EXPECT_EQ(10u, params::MaxStoredHistoryLengthForHostIndifferentBlackList());
EXPECT_EQ(100u, params::MaxInMemoryHostsInBlackList());
EXPECT_EQ(2, params::PerHostBlackListOptOutThreshold());
EXPECT_EQ(6, params::HostIndifferentBlackListOptOutThreshold());
EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlackListDuration());
EXPECT_EQ(base::TimeDelta::FromDays(30),
params::HostIndifferentBlackListPerHostDuration());
EXPECT_EQ(base::TimeDelta::FromSeconds(60 * 5),
params::SingleOptOutDuration());
EXPECT_EQ(base::TimeDelta::FromDays(7),
params::OfflinePreviewFreshnessDuration());
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::OFFLINE));
EXPECT_EQ(
net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::LITE_PAGE_REDIRECT));
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::NOSCRIPT));
EXPECT_EQ(0, params::OfflinePreviewsVersion());
// Set some custom params. Somewhat random yet valid values.
std::map<std::string, std::string> custom_params = {
{"max_allowed_effective_connection_type", "3G"},
{"version", "10"},
};
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(
features::kLitePageServerPreviews, custom_params);
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::OFFLINE));
EXPECT_EQ(
net::EFFECTIVE_CONNECTION_TYPE_3G,
params::GetECTThresholdForPreview(PreviewsType::LITE_PAGE_REDIRECT));
EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G,
params::GetECTThresholdForPreview(PreviewsType::NOSCRIPT));
}
TEST(PreviewsExperimentsTest, TestDefaultShouldExcludeMediaSuffix) { TEST(PreviewsExperimentsTest, TestDefaultShouldExcludeMediaSuffix) {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kExcludedMediaSuffixes); scoped_feature_list.InitAndEnableFeature(features::kExcludedMediaSuffixes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment