gecko-dev/uriloader/preload
Frédéric Wang b005b82248 Bug 1872657 - Add fetchpriority support for <link rel=preload as=image>. r=valentin,smaug,manuel
This patch adds fetchpriority support for `<link rel=preload as=image>`
and equivalent HTTP Link header. The fetchpriority value is passed from
where the link is parsed down to `NewImageChannel` where the priority
is initially set. Currently, the default equals PRIORITY_LOW, but is
decreased a bit if LOAD_BACKGROUND flag is set (this is always the case
for link preload images, see `imgLoader::LoadImage`). Later, the
priority can be increased again depending on the category (see
`imgRequest::BoostPriority`).

In order to minimize the changes, the new calculation is to keep the
initial setting to PRIORITY_LOW, adjust it using a new
`network.fetchpriority.adjustments.*` preference depending on the
fetchpriority attributes, and then preserve further adjustments for
LOAD_BACKGROUND and `BoostPriority`.

For the default value `fetchpriority=auto`, there is no adjustment
i.e. we continue to start with PRIORITY_LOW. `fetchpriority=low/high`
are respectively mapped to PRIORITY_LOW/PRIORITY_HIGH which is simple
and consistent with the "Image" cases from Google's web.dev article
https://web.dev/articles/fetch-priority. These values could of course
be revised in the future after more experiments.

This change is covered by the following tests below. The expectations
is modified to match what is described above (i.e. map to PRIORITY_LOW
or PRIORITY_HIGH with adjustment due to LOAD_BACKGROUND):
- `link-initial-preload-image.h2.html`
- `link-dynamic-preload-image.h2.html`
- `kPipeHeaderPreloadImageLinks`

Based on a patch by Mirko Brodesser (mbrodesser@igalia.com)

Differential Revision: https://phabricator.services.mozilla.com/D197493
2024-02-27 06:33:48 +00:00
..
gtest Bug 1869835 - Part 1: Add code to emit ETW markers on Windows when a trace logger is enabled. r=canaltinova,profiler-reviewers 2023-12-21 18:17:40 +00:00
FetchPreloader.cpp Bug 1872839 - Remove aMimeTypeGuess parameter from nsIContentPolicy. r=freddyb 2024-01-08 15:47:42 +00:00
FetchPreloader.h Bug 1865610: part 10) Add fetchpriority attribute support for rel=preload as=fetch and rel=preload as=font. r=emilio,valentin 2023-11-30 15:00:10 +00:00
moz.build
PreloaderBase.cpp
PreloaderBase.h Bug 1839315: part 3) Remove no-op method PreloaderBase::PrioritizeAsPreload. r=necko-reviewers,valentin 2023-10-11 10:21:56 +00:00
PreloadHashKey.cpp
PreloadHashKey.h
PreloadService.cpp Bug 1872657 - Add fetchpriority support for <link rel=preload as=image>. r=valentin,smaug,manuel 2024-02-27 06:33:48 +00:00
PreloadService.h Bug 1872657 - Add fetchpriority support for <link rel=preload as=image>. r=valentin,smaug,manuel 2024-02-27 06:33:48 +00:00