Bug 1900561 - Set nsIClassOfService::fetchPriority where callers use nsISupportsPriority.adjustPriority r=acreskey

Depends on D221957

Differential Revision: https://phabricator.services.mozilla.com/D221958
This commit is contained in:
Valentin Gosu
2024-09-24 12:29:08 +00:00
parent 7b36a93327
commit ebbb22fc8b
4 changed files with 22 additions and 3 deletions

View File

@@ -855,12 +855,16 @@ nsresult FetchDriver::HttpFetch(
nsIClassOfService::Tail);
}
const auto fetchPriority = ToFetchPriority(mRequest->GetPriorityMode());
if (cos) {
cos->SetFetchPriorityDOM(fetchPriority);
}
if (nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(chan)) {
if (mIsTrackingFetch &&
StaticPrefs::privacy_trackingprotection_lower_network_priority()) {
p->SetPriority(nsISupportsPriority::PRIORITY_LOWEST);
} else if (StaticPrefs::network_fetchpriority_enabled()) {
const auto fetchPriority = ToFetchPriority(mRequest->GetPriorityMode());
// According to step 15 of https://fetch.spec.whatwg.org/#concept-fetch
// requests priority, initiator, destination, and render-blocking are
// used in an implementation-defined manner to set the internal priority.

View File

@@ -733,11 +733,11 @@ static void AdjustPriorityAndClassOfServiceForLinkPreloadScripts(
return;
}
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
if (nsCOMPtr<nsISupportsPriority> supportsPriority =
do_QueryInterface(aChannel)) {
LOG(("Is <link rel=[module]preload"));
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
// The spec defines the priority to be set in an implementation defined
// manner (<https://fetch.spec.whatwg.org/#concept-fetch>, step 15 and
// <https://html.spec.whatwg.org/#concept-script-fetch-options-fetch-priority>).
@@ -752,6 +752,10 @@ static void AdjustPriorityAndClassOfServiceForLinkPreloadScripts(
adjustedPriority);
#endif
}
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(fetchPriority);
}
}
void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel,
@@ -762,10 +766,10 @@ void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel,
return;
}
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
if (nsCOMPtr<nsISupportsPriority> supportsPriority =
do_QueryInterface(aChannel)) {
LOG(("Is not <link rel=[module]preload"));
const auto fetchPriority = ToFetchPriority(aRequest->FetchPriority());
// The spec defines the priority to be set in an implementation defined
// manner (<https://fetch.spec.whatwg.org/#concept-fetch>, step 15 and
@@ -801,6 +805,9 @@ void AdjustPriorityForNonLinkPreloadScripts(nsIChannel* aChannel,
#endif
}
}
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(fetchPriority);
}
}
// static

View File

@@ -838,6 +838,10 @@ static void AdjustPriorityForImages(nsIChannel* aChannel,
supportsPriority->AdjustPriority(priority);
}
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(aFetchPriority);
}
}
static nsresult NewImageChannel(

View File

@@ -1489,6 +1489,10 @@ void Loader::AdjustPriority(const SheetLoadData& aLoadData,
sp->GetPriority(&adjustedPriority);
LogPriorityMapping(sCssLoaderLog, aLoadData.mFetchPriority, adjustedPriority);
#endif
if (nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(aChannel)) {
cos->SetFetchPriorityDOM(aLoadData.mFetchPriority);
}
}
nsresult Loader::LoadSheetAsyncInternal(SheetLoadData& aLoadData,