Commit 0fcb5aa4 authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Treat WiFi connection same as 4G

Treat WiFi connection same as 4G when computing the ECT.

Change-Id: I5d1ed46227b1d19b50a30996b2e3e8a551b82b9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1706871Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678557}
parent c335fda5
...@@ -929,32 +929,32 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const { ...@@ -929,32 +929,32 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const {
if (current_network_id_.signal_strength == INT32_MIN) if (current_network_id_.signal_strength == INT32_MIN)
return effective_connection_type_; return effective_connection_type_;
// Capping ECT on WiFi is currently not enabled. if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN ||
effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_OFFLINE) {
return effective_connection_type_;
}
if (current_network_id_.type == NetworkChangeNotifier::CONNECTION_WIFI) { if (current_network_id_.type == NetworkChangeNotifier::CONNECTION_WIFI) {
// The maximum signal strength level is 4. // The maximum signal strength level is 4.
UMA_HISTOGRAM_EXACT_LINEAR("NQE.WifiSignalStrength.AtECTComputation", UMA_HISTOGRAM_EXACT_LINEAR("NQE.WifiSignalStrength.AtECTComputation",
current_network_id_.signal_strength, 4); current_network_id_.signal_strength, 4);
} else if (current_network_id_.type == NetworkChangeNotifier::CONNECTION_2G ||
current_network_id_.type == NetworkChangeNotifier::CONNECTION_3G ||
current_network_id_.type == NetworkChangeNotifier::CONNECTION_4G) {
// The maximum signal strength level is 4.
UMA_HISTOGRAM_EXACT_LINEAR("NQE.CellularSignalStrength.AtECTComputation",
current_network_id_.signal_strength, 4);
} else {
NOTREACHED();
return effective_connection_type_; return effective_connection_type_;
} }
if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN ||
effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_OFFLINE) {
return effective_connection_type_;
}
// The maximum signal strength level is 4.
UMA_HISTOGRAM_EXACT_LINEAR("NQE.CellularSignalStrength.AtECTComputation",
current_network_id_.signal_strength, 4);
// Do not cap ECT if the signal strength is high. // Do not cap ECT if the signal strength is high.
if (current_network_id_.signal_strength > 2) if (current_network_id_.signal_strength > 2)
return effective_connection_type_; return effective_connection_type_;
DCHECK_LE(0, current_network_id_.signal_strength); DCHECK_LE(0, current_network_id_.signal_strength);
DCHECK_LE(NetworkChangeNotifier::CONNECTION_2G, current_network_id_.type);
DCHECK_GE(NetworkChangeNotifier::CONNECTION_4G, current_network_id_.type);
// When signal strength is 0, the device is almost offline. // When signal strength is 0, the device is almost offline.
if (current_network_id_.signal_strength == 0) { if (current_network_id_.signal_strength == 0) {
switch (current_network_id_.type) { switch (current_network_id_.type) {
...@@ -963,6 +963,7 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const { ...@@ -963,6 +963,7 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const {
return std::min(effective_connection_type_, return std::min(effective_connection_type_,
EFFECTIVE_CONNECTION_TYPE_SLOW_2G); EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
case NetworkChangeNotifier::CONNECTION_4G: case NetworkChangeNotifier::CONNECTION_4G:
case NetworkChangeNotifier::CONNECTION_WIFI:
return std::min(effective_connection_type_, return std::min(effective_connection_type_,
EFFECTIVE_CONNECTION_TYPE_2G); EFFECTIVE_CONNECTION_TYPE_2G);
default: default:
...@@ -980,6 +981,7 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const { ...@@ -980,6 +981,7 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const {
return std::min(effective_connection_type_, return std::min(effective_connection_type_,
EFFECTIVE_CONNECTION_TYPE_2G); EFFECTIVE_CONNECTION_TYPE_2G);
case NetworkChangeNotifier::CONNECTION_4G: case NetworkChangeNotifier::CONNECTION_4G:
case NetworkChangeNotifier::CONNECTION_WIFI:
return std::min(effective_connection_type_, return std::min(effective_connection_type_,
EFFECTIVE_CONNECTION_TYPE_3G); EFFECTIVE_CONNECTION_TYPE_3G);
default: default:
...@@ -997,6 +999,7 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const { ...@@ -997,6 +999,7 @@ NetworkQualityEstimator::GetCappedECTBasedOnSignalStrength() const {
return std::min(effective_connection_type_, return std::min(effective_connection_type_,
EFFECTIVE_CONNECTION_TYPE_3G); EFFECTIVE_CONNECTION_TYPE_3G);
case NetworkChangeNotifier::CONNECTION_4G: case NetworkChangeNotifier::CONNECTION_4G:
case NetworkChangeNotifier::CONNECTION_WIFI:
return std::min(effective_connection_type_, return std::min(effective_connection_type_,
EFFECTIVE_CONNECTION_TYPE_4G); EFFECTIVE_CONNECTION_TYPE_4G);
default: default:
......
...@@ -1197,22 +1197,33 @@ TEST_F(NetworkQualityEstimatorTest, DefaultHttpRTTBasedThresholds) { ...@@ -1197,22 +1197,33 @@ TEST_F(NetworkQualityEstimatorTest, DefaultHttpRTTBasedThresholds) {
TEST_F(NetworkQualityEstimatorTest, SignalStrengthBasedCapping) { TEST_F(NetworkQualityEstimatorTest, SignalStrengthBasedCapping) {
const struct { const struct {
bool enable_signal_strength_capping_experiment; bool enable_signal_strength_capping_experiment;
NetworkChangeNotifier::ConnectionType device_connection_type;
int32_t signal_strength_level; int32_t signal_strength_level;
int32_t http_rtt_msec; int32_t http_rtt_msec;
EffectiveConnectionType expected_ect; EffectiveConnectionType expected_ect;
bool expected_http_rtt_overridden; bool expected_http_rtt_overridden;
} tests[] = { } tests[] = {
// Signal strength is unavailable. // Signal strength is unavailable.
{true, INT32_MIN, 20, EFFECTIVE_CONNECTION_TYPE_4G, false}, {true, NetworkChangeNotifier::CONNECTION_4G, INT32_MIN, 20,
EFFECTIVE_CONNECTION_TYPE_4G, false},
// Signal strength is too low. Even though RTT is reported as low, // 4G device connection type: Signal strength is too low. Even though RTT
// is reported as low,
// ECT is expected to be capped to 2G. // ECT is expected to be capped to 2G.
{true, 0, 20, EFFECTIVE_CONNECTION_TYPE_2G, true}, {true, NetworkChangeNotifier::CONNECTION_4G, 0, 20,
EFFECTIVE_CONNECTION_TYPE_2G, true},
// WiFi device connection type: Signal strength is too low. Even though
// RTT is reported as low, ECT is expected to be capped to 2G.
{true, NetworkChangeNotifier::CONNECTION_WIFI, 0, 20,
EFFECTIVE_CONNECTION_TYPE_2G, true},
// When the signal strength based capping experiment is not enabled, // When the signal strength based capping experiment is not enabled,
// ECT should be computed only on the based of |http_rtt_msec|. // ECT should be computed only on the based of |http_rtt_msec|.
{false, INT32_MIN, 20, EFFECTIVE_CONNECTION_TYPE_4G, false}, {false, NetworkChangeNotifier::CONNECTION_4G, INT32_MIN, 20,
{false, 0, 20, EFFECTIVE_CONNECTION_TYPE_4G, false}, EFFECTIVE_CONNECTION_TYPE_4G, false},
{false, NetworkChangeNotifier::CONNECTION_4G, 0, 20,
EFFECTIVE_CONNECTION_TYPE_4G, false},
}; };
for (const auto& test : tests) { for (const auto& test : tests) {
...@@ -1227,8 +1238,7 @@ TEST_F(NetworkQualityEstimatorTest, SignalStrengthBasedCapping) { ...@@ -1227,8 +1238,7 @@ TEST_F(NetworkQualityEstimatorTest, SignalStrengthBasedCapping) {
// does not return Offline if the device is offline. // does not return Offline if the device is offline.
estimator.SetCurrentSignalStrength(test.signal_strength_level); estimator.SetCurrentSignalStrength(test.signal_strength_level);
estimator.SimulateNetworkChange(NetworkChangeNotifier::CONNECTION_4G, estimator.SimulateNetworkChange(test.device_connection_type, "test");
"test");
estimator.SetStartTimeNullHttpRtt( estimator.SetStartTimeNullHttpRtt(
base::TimeDelta::FromMilliseconds(test.http_rtt_msec)); base::TimeDelta::FromMilliseconds(test.http_rtt_msec));
......
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