Commit 39efff8e authored by Sofiya Semenova's avatar Sofiya Semenova Committed by Commit Bot

Turn on UKM NavigationPredictor metrics collection.

Change-Id: I76b80b77cf72e91d83b89a002c598e8447f9f1e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1723307Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Sofiya Semenova <sofiyase@google.com>
Cr-Commit-Position: refs/heads/master@{#682369}
parent 6622f151
......@@ -219,11 +219,7 @@ NavigationPredictor::NavigationPredictor(
normalize_navigation_scores_(base::GetFieldTrialParamByFeatureAsBool(
blink::features::kNavigationPredictor,
"normalize_scores",
true)),
send_ukm_metrics_(base::GetFieldTrialParamByFeatureAsBool(
blink::features::kNavigationPredictor,
"send_ukm_metrics",
false)) {
true)) {
DCHECK(browser_context_);
DETACH_FROM_SEQUENCE(sequence_checker_);
DCHECK_LE(0, preconnect_origin_score_threshold_);
......@@ -440,7 +436,7 @@ void NavigationPredictor::MaybePreconnectNow(Action log_action) {
}
void NavigationPredictor::MaybeSendMetricsToUkm() const {
if (!send_ukm_metrics_ || !ukm_recorder_) {
if (!ukm_recorder_) {
return;
}
......@@ -513,7 +509,7 @@ int NavigationPredictor::GetLinearBucketForRatioArea(int value) const {
void NavigationPredictor::MaybeSendClickMetricsToUkm(
const std::string& clicked_url) const {
if (!send_ukm_metrics_ || !ukm_recorder_) {
if (!ukm_recorder_) {
return;
}
......
......@@ -196,14 +196,13 @@ class NavigationPredictor : public blink::mojom::AnchorElementMetricsHost,
// MaybePreconnectNow preconnects to an origin server if it's allowed.
void MaybePreconnectNow(Action log_action);
// Sends metrics to the UKM id at |ukm_source_id_| if |send_ukm_metrics_|
// is true.
// Sends metrics to the UKM id at |ukm_source_id_|.
void MaybeSendMetricsToUkm() const;
// After an in-page click, sends the index of the url that was clicked to the
// UKM id at |ukm_source_id_| if |send_ukm_metrics_| is true. The index sent
// corresponds to the index of that url in |top_urls_|, and is 1-indexed.
// If the url does not appear in top_urls_, a 0 is returned.
// UKM id at |ukm_source_id_|. The index sent corresponds to the index of that
// url in |top_urls_|, and is 1-indexed. If the url does not appear in
// |top_urls_|, a 0 is returned.
void MaybeSendClickMetricsToUkm(const std::string& clicked_url) const;
// Returns the minimum of the bucket that |value| belongs in, for page-wide
......@@ -299,10 +298,6 @@ class NavigationPredictor : public blink::mojom::AnchorElementMetricsHost,
// all navigation scores for a page.
const bool normalize_navigation_scores_;
// True if |this| should send metrics about aggregate link information
// to the UKM at id |ukm_source_id_|.
const bool send_ukm_metrics_;
// Timing of document loaded and last click.
base::TimeTicks document_loaded_timing_;
base::TimeTicks last_click_timing_;
......
......@@ -128,8 +128,7 @@ class NavigationPredictorTest : public ChromeRenderViewHostTestHarness {
void SetupFieldTrial(base::Optional<int> preconnect_origin_score_threshold,
base::Optional<int> prefetch_url_score_threshold,
base::Optional<bool> prefetch_after_preconnect,
base::Optional<bool> send_ukm_metrics) {
base::Optional<bool> prefetch_after_preconnect) {
if (field_trial_initiated_)
return;
......@@ -150,9 +149,6 @@ class NavigationPredictorTest : public ChromeRenderViewHostTestHarness {
params["prefetch_after_preconnect"] =
prefetch_after_preconnect.value() ? "true" : "false";
}
if (send_ukm_metrics.has_value()) {
params["send_ukm_metrics"] = send_ukm_metrics.value() ? "true" : "false";
}
scoped_feature_list.InitAndEnableFeatureWithParameters(
blink::features::kNavigationPredictor, params);
}
......@@ -504,7 +500,7 @@ class NavigationPredictorSendUkmMetricsEnabledTest
: public NavigationPredictorTest {
public:
NavigationPredictorSendUkmMetricsEnabledTest() {
SetupFieldTrial(base::nullopt, base::nullopt, base::nullopt, true);
SetupFieldTrial(base::nullopt, base::nullopt, base::nullopt);
}
void SetUp() override {
......@@ -721,7 +717,7 @@ class NavigationPredictorPrefetchAfterPreconnectEnabledTest
: public NavigationPredictorTest {
public:
NavigationPredictorPrefetchAfterPreconnectEnabledTest() {
SetupFieldTrial(base::nullopt, base::nullopt, true, base::nullopt);
SetupFieldTrial(base::nullopt, base::nullopt, true);
}
void SetUp() override {
......@@ -768,8 +764,7 @@ class NavigationPredictorPrefetchDisabledTest : public NavigationPredictorTest {
public:
NavigationPredictorPrefetchDisabledTest() {
SetupFieldTrial(0 /* preconnect_origin_score_threshold */,
101 /* prefetch_url_score_threshold */, base::nullopt,
base::nullopt);
101 /* prefetch_url_score_threshold */, base::nullopt);
}
void SetUp() override {
......@@ -867,8 +862,7 @@ class NavigationPredictorPreconnectPrefetchDisabledTest
public:
NavigationPredictorPreconnectPrefetchDisabledTest() {
SetupFieldTrial(101 /* preconnect_origin_score_threshold */,
101 /* prefetch_url_score_threshold */, base::nullopt,
base::nullopt);
101 /* prefetch_url_score_threshold */, base::nullopt);
}
void SetUp() override {
......
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