Bug 1819570 - P2 Save worker's associated BrowsingContextID in channel's LoadInfo for the netmonitor. r=necko-reviewers,valentin

After PFetch is enabled, fetch() call in workers will not create a channel in the content process anymore.
Although netmonitor also watches the channels in the parent process, the created channel still loses the BrowsingContext information for netmonitor to connect the network event and the channel.

In P1, https://phabricator.services.mozilla.com/D174249, we propagate the BrowsingContext ID through PFetch.
In this patch, we need to save it in channel's LoadInfo for netmonitor.

In order not to confuse with nsILoadInfo's BrowsingContextID, we create a new attribute WorkerAssociatedBrowsingContextID in nsILoadInfo.

Depends on D174249

Differential Revision: https://phabricator.services.mozilla.com/D174441
This commit is contained in:
Eden Chuang
2023-05-04 02:46:31 +00:00
parent 36e87d7240
commit d4acff34b0
5 changed files with 55 additions and 0 deletions

View File

@@ -648,6 +648,12 @@ nsresult FetchDriver::HttpFetch(
NS_ENSURE_SUCCESS(rv, rv);
}
if (mAssociatedBrowsingContextID) {
nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
rv = loadInfo->SetWorkerAssociatedBrowsingContextID(
mAssociatedBrowsingContextID);
}
// If the fetch is created by FetchEvent.request or NavigationPreload request,
// corresponding InterceptedHttpChannel information need to propagte to the
// channel of the fetch.