blob: 373572c77b7f13a2105e19e6d7e46d9715de88b9 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2022 The Chromium Authors
Max Curran6c2835ea2022-03-07 19:52:382// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Sreeja Kamishettyf66553a2022-07-14 17:41:275#ifndef CONTENT_BROWSER_PRELOADING_PREFETCH_PREFETCH_FEATURES_H_
6#define CONTENT_BROWSER_PRELOADING_PREFETCH_PREFETCH_FEATURES_H_
Max Curran6c2835ea2022-03-07 19:52:387
8#include "base/feature_list.h"
Hiroshige Hayashizakic0b6aea2023-10-17 21:56:439#include "base/metrics/field_trial_params.h"
Max Curran6c2835ea2022-03-07 19:52:3810#include "content/common/content_export.h"
11
Hiroki Nakagawafc2a24d2025-05-23 08:06:2312namespace content {
13class BrowserContext;
14} // namespace content
15
Jeremy Romane77bc6c2023-12-08 07:07:3416namespace features {
Max Curran6c2835ea2022-03-07 19:52:3817
kenoss557dafa2025-07-01 10:38:3518// Controls params for tests of prefetch.
19CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchTesting);
20
21// The size limit of body size in bytes that can be reused in
22// `PrefetchDataPipeTee`.
23CONTENT_EXPORT extern const base::FeatureParam<int>
24 kPrefetchReusableBodySizeLimit;
25
Lingqi Chifb4bd462024-08-21 01:29:5626// This feature was used to launch the prefetch migration from embedder layer to
27// content/, and this work has finished and the old implemnetation was deleted.
28// Now this flag is just for injecting parameters through field trials as an
29// umberella feature.
Daniel Cheng0abd9f32022-09-22 04:20:1130CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchUseContentRefactor);
Max Curran6c2835ea2022-03-07 19:52:3831
Kouhei Ueno5ad21962023-11-16 04:38:5432// If enabled, navigational prefetch is scoped to the referring document's
33// network isolation key instead of the old behavior of the referring document
34// itself. See crbug.com/1502326
Kouhei Uenod47c0bbc2023-11-15 23:16:1735BASE_DECLARE_FEATURE(kPrefetchNIKScope);
36
Jeremy Roman586b5ec2024-02-13 15:14:4037// If enabled, prefetches may include client hints request headers.
38CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchClientHints);
39
40// This allows controlling the behavior of client hints with prefetches in case
41// an unexpected issue arises with the planned behavior, or one is suspected and
42// we want to debug more easily.
43// TODO(crbug.com/41497015): Remove this control once a behavior is shipped and
44// stabilized.
45enum class PrefetchClientHintsCrossSiteBehavior {
46 // Send no client hints cross-site.
47 kNone,
48 // Send only the "low-entropy" hints which are included by default.
49 kLowEntropy,
50 // Send all client hints that would normally be sent.
51 kAll,
52};
53CONTENT_EXPORT extern const base::FeatureParam<
54 PrefetchClientHintsCrossSiteBehavior>
55 kPrefetchClientHintsCrossSiteBehavior;
56
Jeremy Romane561b412024-02-15 18:31:3457// If enabled, then prefetch serving will apply mitigations if it may have been
58// contaminated by cross-partition state.
59CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchStateContaminationMitigation);
60
Jeremy Roman3146e872024-03-12 18:57:2461// If true, contaminated prefetches will also force a browsing context group
62// swap.
63CONTENT_EXPORT extern const base::FeatureParam<bool>
64 kPrefetchStateContaminationSwapsBrowsingContextGroup;
65
Hiroshige Hayashizaki13aac4c2024-11-22 21:03:1966// Fix for prefetching a URL controlled by a ServiceWorker without fetch
67// handler. Currently this stops prefetching for such cases
68// (https://crbug.com/379076354).
Hiroshige Hayashizaki0cc97822025-03-14 00:58:4469// Even when `kPrefetchServiceWorker` is enabled, this is still effective for
70// SW-ineligible prefetches.
Hiroshige Hayashizaki13aac4c2024-11-22 21:03:1971CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchServiceWorkerNoFetchHandlerFix);
72
Taiyo Mizuhashi2bef6682025-03-07 08:58:4573// Enabling this will apply net::RequestPriority::MEDIUM for prefetch
74// requests triggered by embedders. See crbug.com/353628437 to track this issue.
75CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchNetworkPriorityForEmbedders);
76
Taiyo Mizuhashi06c0436a2025-03-28 15:07:0277// Enabling this will bupm net::RequestPriority once after the running prefetch
78// starts to be served.
79CONTENT_EXPORT BASE_DECLARE_FEATURE(
80 kPrefetchBumpNetworkPriorityAfterBeingServed);
81
Hiroshige Hayashizaki0cc97822025-03-14 00:58:4482// Allow prefetching ServiceWorker-controlled URLs.
83CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchServiceWorker);
Hiroki Nakagawafc2a24d2025-05-23 08:06:2384bool IsPrefetchServiceWorkerEnabled(content::BrowserContext* browser_context);
Hiroshige Hayashizaki0cc97822025-03-14 00:58:4485
Taiyo Mizuhashib9780f22025-03-28 18:29:0386// If enabled, prefetch caches are cleared when browsing data removal. Please
87// see crbug.com/40262310 for more details.
88CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchBrowsingDataRemoval);
89
kenoss1b8ebc22025-04-04 00:11:3590// Replace current prefetch queue with a new queue and scheduler, which allows
91// prioritization, concurrent prefetches, bursting.
92//
93// For more details, see
94// https://docs.google.com/document/d/1W0Nk3Nq6NaUXkBppOUC5zyNmhVqMjYShm1bydGYd9qc
95CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchScheduler);
96
kenoss0a567362025-05-16 11:18:5597// Call `PrefetchScheduler::Progress()` synchronously as much as possible.
98CONTENT_EXPORT extern const base::FeatureParam<bool>
99 kPrefetchSchedulerProgressSyncBestEffort;
100
kenoss1b8ebc22025-04-04 00:11:35101// Controls params for tests of `PrefetchScheduler`.
102CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchSchedulerTesting);
103CONTENT_EXPORT extern const base::FeatureParam<size_t>
104 kPrefetchSchedulerTestingActiveSetSizeLimitForBase;
105CONTENT_EXPORT extern const base::FeatureParam<size_t>
106 kPrefetchSchedulerTestingActiveSetSizeLimitForBurst;
107
Taiyo Mizuhashi4e624a22025-05-15 11:28:54108// Provide a partial fix for prefetch queueing problem (crbug.com/400233773),
109// without `PrefetchScheduler` feature.
110CONTENT_EXPORT BASE_DECLARE_FEATURE(
111 kPrefetchQueueingPartialFixWithoutScheduler);
112
Taiyo Mizuhashi576a62972025-06-23 11:09:25113// Controls field trials parameters for prefetch canary checker.
114CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchCanaryCheckerParams);
115
Taiyo Mizuhashi98e3dea2025-06-23 18:32:58116// Allows multiple base limit on `PrefetchScheduler`.
117CONTENT_EXPORT BASE_DECLARE_FEATURE(kPrefetchMultipleActiveSetSizeLimitForBase);
118CONTENT_EXPORT extern const base::FeatureParam<size_t>
119 kPrefetchMultipleActiveSetSizeLimitForBaseValue;
Jeremy Romane77bc6c2023-12-08 07:07:34120} // namespace features
Max Curran6c2835ea2022-03-07 19:52:38121
Sreeja Kamishettyf66553a2022-07-14 17:41:27122#endif // CONTENT_BROWSER_PRELOADING_PREFETCH_PREFETCH_FEATURES_H_