summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortbansal <tbansal@chromium.org>2015-07-31 14:06:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-31 21:07:47 +0000
commit8b735f8c69629aa777e274da3f033c581b458065 (patch)
treef71a564980ea7715f40cec4351c1978621b970f4
parent7ae7fc06cd7e5f8fe95c672f79dead4ba46f46ed (diff)
downloadchromium_src-8b735f8c69629aa777e274da3f033c581b458065.zip
chromium_src-8b735f8c69629aa777e274da3f033c581b458065.tar.gz
chromium_src-8b735f8c69629aa777e274da3f033c581b458065.tar.bz2
Add one more state to LoFi flag.
On setting this flag, LoFi would be enabled on slow connections even if device is not part of LoFi field trial. Definition of slow connection is hard-coded. BUG=470596 Review URL: https://codereview.chromium.org/1269933002 Cr-Commit-Position: refs/heads/master@{#341408}
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/about_flags.cc6
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc28
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h2
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc56
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc78
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc8
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_params.h4
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc4
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h1
-rw-r--r--tools/metrics/actions/actions.xml10
11 files changed, 189 insertions, 11 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index e1e41d7..1b3efff 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6596,6 +6596,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DATA_REDUCTION_PROXY_LO_FI_DISABLED" desc="Option for IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_LO_FI_NAME to disable Lo-Fi">
Disable
</message>
+ <message name="IDS_FLAGS_DATA_REDUCTION_PROXY_LO_FI_SLOW_CONNECTIONS_ONLY" desc="Option for IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_LO_FI_NAME to enable Lo-Fi only on slow connections">
+ Slow connections only
+ </message>
<message name="IDS_FLAGS_DATA_REDUCTION_PROXY_RESET_SAVINGS_NAME" desc="Title in about::flags to clear data savings obtained with data reduction proxy when Chrome restarts">
Clear data savings on startup
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 1465091..ffd8822 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -232,7 +232,11 @@ const Experiment::Choice kDataReductionProxyLoFiChoices[] = {
kDataReductionProxyLoFiValueCellularOnly},
{ IDS_FLAGS_DATA_REDUCTION_PROXY_LO_FI_DISABLED,
data_reduction_proxy::switches::kDataReductionProxyLoFi,
- data_reduction_proxy::switches::kDataReductionProxyLoFiValueDisabled}
+ data_reduction_proxy::switches::kDataReductionProxyLoFiValueDisabled},
+ { IDS_FLAGS_DATA_REDUCTION_PROXY_LO_FI_SLOW_CONNECTIONS_ONLY,
+ data_reduction_proxy::switches::kDataReductionProxyLoFi,
+ data_reduction_proxy::switches::
+ kDataReductionProxyLoFiValueSlowConnectionsOnly}
};
const Experiment::Choice kShowSavedCopyChoices[] = {
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 36f09fb..70f379a 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
@@ -478,9 +478,17 @@ bool DataReductionProxyConfig::ShouldUseLoFiHeaderForRequests() const {
}
void DataReductionProxyConfig::PopulateAutoLoFiParams() {
+ if (params::IsLoFiSlowConnectionsOnlyViaFlags()) {
+ auto_lofi_minimum_rtt_ = base::TimeDelta::FromMilliseconds(2000);
+ auto_lofi_maximum_kbps_ = 0;
+ auto_lofi_hysteresis_ = base::TimeDelta::FromSeconds(60);
+ return;
+ }
+
if (!IsIncludedInLoFiControlFieldTrial() &&
- !IsIncludedInLoFiEnabledFieldTrial())
+ !IsIncludedInLoFiEnabledFieldTrial()) {
return;
+ }
uint64_t auto_lofi_minimum_rtt_msec;
std::string variation_value = variations::GetVariationParamValue(
@@ -787,20 +795,14 @@ void DataReductionProxyConfig::UpdateLoFiStatusOnMainFrameRequest(
return;
}
- if (IsIncludedInLoFiControlFieldTrial()) {
- lofi_status_ = IsNetworkQualityProhibitivelySlow(network_quality_estimator)
- ? LOFI_STATUS_ACTIVE_CONTROL
- : LOFI_STATUS_INACTIVE_CONTROL;
- return;
- }
-
// Store the previous state of Lo-Fi, so that change in Lo-Fi status can be
// recorded properly. This is not needed for the control group, because it
// is only used to report changes in request headers, and the request headers
// are never modified in the control group.
LoFiStatus previous_lofi_status = lofi_status_;
- if (IsIncludedInLoFiEnabledFieldTrial()) {
+ if (params::IsLoFiSlowConnectionsOnlyViaFlags() ||
+ IsIncludedInLoFiEnabledFieldTrial()) {
lofi_status_ = IsNetworkQualityProhibitivelySlow(network_quality_estimator)
? LOFI_STATUS_ACTIVE
: LOFI_STATUS_INACTIVE;
@@ -809,6 +811,14 @@ void DataReductionProxyConfig::UpdateLoFiStatusOnMainFrameRequest(
ShouldUseLoFiHeaderForRequests(lofi_status_));
return;
}
+
+ if (IsIncludedInLoFiControlFieldTrial()) {
+ lofi_status_ = IsNetworkQualityProhibitivelySlow(network_quality_estimator)
+ ? LOFI_STATUS_ACTIVE_CONTROL
+ : LOFI_STATUS_INACTIVE_CONTROL;
+ return;
+ }
+
// If Lo-Fi is not enabled through command line and the user is not in
// Lo-Fi field trials, we set Lo-Fi to permanent off.
lofi_status_ = LOFI_STATUS_OFF;
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h
index 2b95053..c85f6d1 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h
@@ -267,6 +267,8 @@ class DataReductionProxyConfig
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest,
TestMaybeDisableIfVPNTrialEnabled);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiParams);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest,
+ AutoLoFiParamsSlowConnectionsFlag);
// NetworkChangeNotifier::IPAddressObserver:
void OnIPAddressChanged() override;
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
index 05edc7b..1f03f74 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
@@ -1079,4 +1079,60 @@ TEST_F(DataReductionProxyConfigTest, AutoLoFiParams) {
&test_network_quality_estimator));
}
+TEST_F(DataReductionProxyConfigTest, AutoLoFiParamsSlowConnectionsFlag) {
+ DataReductionProxyConfig config(nullptr, nullptr, configurator(),
+ event_creator());
+ variations::testing::ClearAllVariationParams();
+
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kDataReductionProxyLoFi,
+ switches::kDataReductionProxyLoFiValueSlowConnectionsOnly);
+
+ config.PopulateAutoLoFiParams();
+
+ int rtt_msec = 2000;
+ int hysteresis_sec = 60;
+ EXPECT_EQ(base::TimeDelta::FromMilliseconds(rtt_msec),
+ config.auto_lofi_minimum_rtt_);
+ EXPECT_EQ(0, config.auto_lofi_maximum_kbps_);
+ EXPECT_EQ(base::TimeDelta::FromSeconds(hysteresis_sec),
+ config.auto_lofi_hysteresis_);
+
+ std::map<std::string, std::string> network_quality_estimator_params;
+ TestNetworkQualityEstimator test_network_quality_estimator(
+ network_quality_estimator_params);
+
+ // RTT is higher than threshold. Network is slow.
+ test_network_quality_estimator.SetRTT(
+ base::TimeDelta::FromMilliseconds(rtt_msec + 1));
+ EXPECT_TRUE(config.IsNetworkQualityProhibitivelySlow(
+ &test_network_quality_estimator));
+
+ // Network quality improved. RTT is lower than the threshold. However,
+ // network should still be marked as slow because of hysteresis.
+ test_network_quality_estimator.SetRTT(
+ base::TimeDelta::FromMilliseconds(rtt_msec - 1));
+ EXPECT_TRUE(config.IsNetworkQualityProhibitivelySlow(
+ &test_network_quality_estimator));
+
+ // Change the last update time to be older than the hysteresis duration.
+ // Checking network quality afterwards should show that network is no longer
+ // slow.
+ config.network_quality_last_updated_ =
+ base::TimeTicks::Now() - base::TimeDelta::FromSeconds(hysteresis_sec + 1);
+ EXPECT_FALSE(config.IsNetworkQualityProhibitivelySlow(
+ &test_network_quality_estimator));
+
+ // Changing the RTT has no effect because of hysteresis.
+ test_network_quality_estimator.SetRTT(
+ base::TimeDelta::FromMilliseconds(rtt_msec + 1));
+ EXPECT_FALSE(config.IsNetworkQualityProhibitivelySlow(
+ &test_network_quality_estimator));
+
+ // Change in connection type changes the network quality despite hysteresis.
+ config.connection_type_ = net::NetworkChangeNotifier::CONNECTION_WIFI;
+ EXPECT_TRUE(config.IsNetworkQualityProhibitivelySlow(
+ &test_network_quality_estimator));
+}
+
} // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
index 6d373be..511f8d9 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
@@ -363,6 +363,84 @@ TEST_F(DataReductionProxyRequestOptionsTest, AutoLoFi) {
}
}
+TEST_F(DataReductionProxyRequestOptionsTest, SlowConnectionsFlag) {
+ const struct {
+ bool slow_connections_flag_enabled;
+ bool network_prohibitively_slow;
+ bool auto_lofi_enabled_group;
+
+ } tests[] = {
+ {
+ false, false, false,
+ },
+ {
+ false, true, false,
+ },
+ {
+ true, false, false,
+ },
+ {
+ true, true, false,
+ },
+ {
+ false, false, true,
+ },
+ {
+ false, true, true,
+ },
+ {
+ true, false, true,
+ },
+ {
+ true, true, true,
+ },
+ };
+
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ test_context_->config()->ResetLoFiStatusForTest();
+ // For the purpose of this test, Lo-Fi header is expected only if LoFi Slow
+ // Connection Flag is enabled or session is part of Lo-Fi enabled field
+ // trial. For both cases, an additional condition is that network must be
+ // prohibitively slow.
+ bool expect_lofi_header = (tests[i].slow_connections_flag_enabled &&
+ tests[i].network_prohibitively_slow) ||
+ (!tests[i].slow_connections_flag_enabled &&
+ tests[i].auto_lofi_enabled_group &&
+ tests[i].network_prohibitively_slow);
+
+ std::string expected_header;
+ if (!expect_lofi_header) {
+ SetHeaderExpectations(kExpectedSession, kExpectedCredentials,
+ std::string(), kClientStr, std::string(),
+ std::string(), std::string(),
+ std::vector<std::string>(), &expected_header);
+ } else {
+ SetHeaderExpectations(kExpectedSession, kExpectedCredentials,
+ std::string(), kClientStr, std::string(),
+ std::string(), "low", std::vector<std::string>(),
+ &expected_header);
+ }
+
+ if (tests[i].slow_connections_flag_enabled) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kDataReductionProxyLoFi,
+ switches::kDataReductionProxyLoFiValueSlowConnectionsOnly);
+ }
+
+ test_context_->config()->SetIncludedInLoFiEnabledFieldTrial(
+ tests[i].auto_lofi_enabled_group);
+
+ test_context_->config()->SetNetworkProhibitivelySlow(
+ tests[i].network_prohibitively_slow);
+
+ // Force update Lo-Fi status.
+ test_context_->config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
+
+ CreateRequestOptions(kBogusVersion);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ }
+}
+
TEST_F(DataReductionProxyRequestOptionsTest, SecureSession) {
std::string expected_header;
SetHeaderExpectations(std::string(), std::string(), kSecureSession,
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
index 01e3fc3..9dccf53 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
@@ -90,6 +90,14 @@ bool IsLoFiCellularOnlyViaFlags() {
kDataReductionProxyLoFiValueCellularOnly;
}
+bool IsLoFiSlowConnectionsOnlyViaFlags() {
+ const std::string& lo_fi_value =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ data_reduction_proxy::switches::kDataReductionProxyLoFi);
+ return lo_fi_value == data_reduction_proxy::switches::
+ kDataReductionProxyLoFiValueSlowConnectionsOnly;
+}
+
bool IsLoFiDisabledViaFlags() {
const std::string& lo_fi_value =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h
index 02df360f..6851fab 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h
@@ -51,6 +51,10 @@ bool IsLoFiAlwaysOnViaFlags();
// mode only on cellular connections.
bool IsLoFiCellularOnlyViaFlags();
+// Returns true if this client has the command line switch to enable Lo-Fi
+// mode only on slow connections.
+bool IsLoFiSlowConnectionsOnlyViaFlags();
+
// Returns true if this client has the command line switch to disable Lo-Fi
// mode.
bool IsLoFiDisabledViaFlags();
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc
index d1c90ea..59bcff8 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc
@@ -43,11 +43,13 @@ const char kDataReductionProxyWarmupURL[] = "data-reduction-proxy-warmup-url";
const char kDataReductionSSLProxy[] = "data-reduction-ssl-proxy";
// The mode for Data Reduction Proxy Lo-Fi. The various modes are always-on,
-// cellular-only, and disabled.
+// cellular-only, slow connections only and disabled.
const char kDataReductionProxyLoFi[] = "data-reduction-proxy-lo-fi";
const char kDataReductionProxyLoFiValueAlwaysOn[] = "always-on";
const char kDataReductionProxyLoFiValueCellularOnly[] = "cellular-only";
const char kDataReductionProxyLoFiValueDisabled[] = "disabled";
+const char kDataReductionProxyLoFiValueSlowConnectionsOnly[] =
+ "slow-connections-only";
// Disables the origin of the data reduction proxy dev.
const char kDisableDataReductionProxyDev[] =
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h
index f3af94e..548a7a4 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h
@@ -24,6 +24,7 @@ extern const char kDataReductionProxyLoFi[];
extern const char kDataReductionProxyLoFiValueAlwaysOn[];
extern const char kDataReductionProxyLoFiValueCellularOnly[];
extern const char kDataReductionProxyLoFiValueDisabled[];
+extern const char kDataReductionProxyLoFiValueSlowConnectionsOnly[];
extern const char kDisableDataReductionProxyDev[];
extern const char kEnableDataReductionProxyDev[];
extern const char kEnableDataReductionProxyCarrierTest[];
diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml
index 3937041..6608cf1 100644
--- a/tools/metrics/actions/actions.xml
+++ b/tools/metrics/actions/actions.xml
@@ -96,6 +96,16 @@ should be able to be added at any place in this file.
</description>
</action>
+<action name="AboutFlags_data-reduction-proxy-lo-fi@4">
+ <owner>bengr@chromium.org</owner>
+ <owner>megjablon@chromium.org</owner>
+ <description>
+ User enabled flag that Forces Data Saver Lo-Fi mode to be enabled only on
+ slow connections via chrome://flags. The action is emitted once per startup
+ when the flag is active.
+ </description>
+</action>
+
<action name="AboutFlags_disable-chrome-to-mobile">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>