ServiceWorker: Add support for throttling installing service workers.
This feature is gated behind the "ThrottleInstallingServiceWorker"
feature flag and uses the "limit" field trial param to control how
many outstanding requests to permit.
This CL includes the following changes:
* Changes ResourceFetcher and associated classes to use
FrameOrWorkerScheduler instead of FrameScheduler.
* Moves FrameOrWorkerScheduler::GetWeakPtr() from private to public so
that ResourceFetcher and friends can use it.
* Factors the outstanding throttle limit into a virtual method on
ResourceFetcherProperties. This makes it easier to expose a different
limit for workers vs frames.
* Moves existing frame throttle limits from ResourceLoadScheduler to
FrameResourceFetcherProperties.
* Updates the features controlling frame throttle limits to use the new
base::Feature and base::FeatureParam<> syntax.
* Introduces a ResourceLoadScheduler::ThrottleOptionOverride enum that
be set on the ResourceFetcher to override default ThrottleOption
behavior.
* Makes ServiceWorkerGlobalScope set a ThrottleOptionOverride, expose
its new throttle limit, and update the scheduler to enable throttling
while in the installing state.
* Adds a significant new content browsertest that validates installing
service workers throttle requests based on the feature and field trial
param.
Bug: 1035448
Change-Id: Icdbe82ef8db1573cd5acb26e53946166ac3bdbe3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015880
Commit-Queue: Ben Kelly <[email protected]>
Reviewed-by: Takashi Toyoshima <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: Yutaka Hirano <[email protected]>
Cr-Commit-Position: refs/heads/master@{#760548}
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index 79455d0..07a592ac 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -511,5 +511,12 @@
const base::FeatureParam<int> kAlignFontDisplayAutoTimeoutWithLCPGoalParam{
&kAlignFontDisplayAutoTimeoutWithLCPGoal, "lcp-limit-in-ms", 2000};
+// Enable throttling of fetch() requests from service workers in the
+// installing state.
+const base::Feature kThrottleInstallingServiceWorker{
+ "ThrottleInstallingServiceWorker", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::FeatureParam<int> kInstallingServiceWorkerOutstandingThrottledLimit{
+ &kThrottleInstallingServiceWorker, "limit", 5};
+
} // namespace features
} // namespace blink