Commit 34ecc4a3 authored by Ryan Sturm's avatar Ryan Sturm Committed by Commit Bot

Adding a finch param for preconnect experiment

This param does not change the default behavior, but allows adjusting
behavior via finch. This will allow us to modify pre-connect retry
behavior to be slightly less aggressive.

Bug: 964089
Change-Id: I989c075c733e1d5edb5d0b070abcda86acd57545
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1614706Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Ryan Sturm <ryansturm@chromium.org>
Auto-Submit: Ryan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661024}
parent 9e89d7af
...@@ -136,8 +136,7 @@ NavigationPredictor::NavigationPredictor( ...@@ -136,8 +136,7 @@ NavigationPredictor::NavigationPredictor(
base::GetFieldTrialParamByFeatureAsBool( base::GetFieldTrialParamByFeatureAsBool(
blink::features::kNavigationPredictor, blink::features::kNavigationPredictor,
"same_origin_preconnecting_allowed", "same_origin_preconnecting_allowed",
false)) false)) {
{
DCHECK(browser_context_); DCHECK(browser_context_);
DETACH_FROM_SEQUENCE(sequence_checker_); DETACH_FROM_SEQUENCE(sequence_checker_);
DCHECK_LE(0, preconnect_origin_score_threshold_); DCHECK_LE(0, preconnect_origin_score_threshold_);
...@@ -317,14 +316,24 @@ void NavigationPredictor::MaybePreconnectNow(Action log_action) { ...@@ -317,14 +316,24 @@ void NavigationPredictor::MaybePreconnectNow(Action log_action) {
if (current_visibility_ != content::Visibility::VISIBLE) if (current_visibility_ != content::Visibility::VISIBLE)
return; return;
// Set/Reset the timer to fire after the pre-connect times out. Add an extra // The delay beyond the idle socket timeout that net uses when
// 50ms to make sure the preconnect has expired if it wasn't used. // re-preconnecting. If negative, no retries occur.
int retry_delay_ms = base::GetFieldTrialParamByFeatureAsInt(
blink::features::kNavigationPredictor, "retry_preconnect_wait_time_ms",
50);
if (retry_delay_ms < 0) {
return;
}
// Set/Reset the timer to fire after the preconnect times out. Add an extra
// delay to make sure the preconnect has expired if it wasn't used.
timer_.Start( timer_.Start(
FROM_HERE, FROM_HERE,
base::TimeDelta::FromSeconds(base::GetFieldTrialParamByFeatureAsInt( base::TimeDelta::FromSeconds(base::GetFieldTrialParamByFeatureAsInt(
net::features::kNetUnusedIdleSocketTimeout, net::features::kNetUnusedIdleSocketTimeout,
"unused_idle_socket_timeout_seconds", 10)) + "unused_idle_socket_timeout_seconds", 10)) +
base::TimeDelta::FromMilliseconds(50), base::TimeDelta::FromMilliseconds(retry_delay_ms),
base::BindOnce(&NavigationPredictor::MaybePreconnectNow, base::BindOnce(&NavigationPredictor::MaybePreconnectNow,
base::Unretained(this), Action::kPreconnectAfterTimeout)); base::Unretained(this), Action::kPreconnectAfterTimeout));
} }
......
...@@ -396,6 +396,33 @@ IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest, ...@@ -396,6 +396,33 @@ IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest,
NavigationPredictor::Action::kPreconnectAfterTimeout))); NavigationPredictor::Action::kPreconnectAfterTimeout)));
} }
// Test that we don't preconnect after the last preconnect timed out when
// retry_preconnect_wait_time_ms is negative.
IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest,
DISABLE_ON_CHROMEOS(ActionAccuracy_timeout_no_retry)) {
base::HistogramTester histogram_tester;
base::test::ScopedFeatureList scoped_feature_list_net;
// -1 would force synchronous retries if retries were not disabled.
scoped_feature_list_net.InitAndEnableFeatureWithParameters(
net::features::kNetUnusedIdleSocketTimeout,
{{"unused_idle_socket_timeout_seconds", "-1"}});
base::test::ScopedFeatureList scoped_feature_list_predictor;
scoped_feature_list_predictor.InitAndEnableFeatureWithParameters(
blink::features::kNavigationPredictor,
{{"retry_preconnect_wait_time_ms", "-1"}});
const GURL& url = GetTestURL("/page_with_same_host_anchor_element.html");
ui_test_utils::NavigateToURL(browser(), url);
WaitForLayout(&histogram_tester);
EXPECT_EQ(0, histogram_tester.GetBucketCount(
"NavigationPredictor.OnNonDSE.ActionTaken",
static_cast<base::HistogramBase::Sample>(
NavigationPredictor::Action::kPreconnectAfterTimeout)));
}
// Test that the action accuracy is properly recorded and when same origin // Test that the action accuracy is properly recorded and when same origin
// preconnections are enabled, then navigation predictor initiates the // preconnections are enabled, then navigation predictor initiates the
// preconnection. // preconnection.
......
...@@ -3101,6 +3101,7 @@ ...@@ -3101,6 +3101,7 @@
"is_url_incremented_scale": "100", "is_url_incremented_scale": "100",
"preconnect_skip_link_scores": "true", "preconnect_skip_link_scores": "true",
"ratio_area_scale": "100", "ratio_area_scale": "100",
"retry_preconnect_wait_time_ms": "50",
"same_origin_preconnecting_allowed": "true", "same_origin_preconnecting_allowed": "true",
"source_engagement_score_scale": "100", "source_engagement_score_scale": "100",
"target_engagement_score_scale": "100", "target_engagement_score_scale": "100",
......
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