Skip to content

Commit

Permalink
Bug 1666751: Use simple and never failing LoadInfo() getter because a…
Browse files Browse the repository at this point in the history
…ll channels should have a loadinfo r=freddyb,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D91119
  • Loading branch information
Christoph Kerschbaumer committed Sep 23, 2020
1 parent 43c1b3c commit f8e1e72
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 28 deletions.
3 changes: 1 addition & 2 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10364,8 +10364,7 @@ nsresult nsDocShell::OpenRedirectedChannel(nsDocShellLoadState* aLoadState) {

MaybeCreateInitialClientSource();

nsCOMPtr<nsILoadInfo> loadInfo;
channel->GetLoadInfo(getter_AddRefs(loadInfo));
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();

LoadInfo* li = static_cast<LoadInfo*>(loadInfo.get());
if (loadInfo->GetExternalContentPolicyType() ==
Expand Down
7 changes: 1 addition & 6 deletions dom/file/uri/BlobURLInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,7 @@ void BlobURLInputStream::RetrieveBlobData(const MutexAutoLock& aProofOfLock) {
NotifyWaitTargets(aProofOfLock);
});

nsCOMPtr<nsILoadInfo> loadInfo;
if (NS_WARN_IF(NS_FAILED(mChannel->GetLoadInfo(getter_AddRefs(loadInfo))))) {
NS_WARNING("Failed to get owning channel's loadinfo");
return;
}

nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
nsCOMPtr<nsIPrincipal> loadingPrincipal;
if (NS_WARN_IF(NS_FAILED(loadInfo->GetTriggeringPrincipal(
Expand Down
5 changes: 1 addition & 4 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5744,10 +5744,7 @@ nsresult ContentParent::AboutToLoadHttpFtpDocumentForChild(
UpdateCookieStatus(aChannel);
}

RefPtr<nsILoadInfo> loadInfo;
rv = aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_SUCCESS(rv, rv);

RefPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
RefPtr<BrowsingContext> browsingContext;
rv = loadInfo->GetTargetBrowsingContext(getter_AddRefs(browsingContext));
NS_ENSURE_SUCCESS(rv, rv);
Expand Down
3 changes: 1 addition & 2 deletions dom/serviceworkers/ServiceWorkerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,8 +1533,7 @@ nsresult ServiceWorkerPrivate::SendFetchEvent(
if (isNonSubresourceRequest) {
registration = swm->GetRegistration(mInfo->Principal(), mInfo->Scope());
} else {
nsCOMPtr<nsILoadInfo> loadInfo;
channel->GetLoadInfo(getter_AddRefs(loadInfo));
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();

// We'll check for a null registration below rather than an error code here.
Unused << swm->GetClientRegistration(loadInfo->GetClientInfo().ref(),
Expand Down
5 changes: 1 addition & 4 deletions dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,7 @@ Result<IPCInternalRequest, nsresult> GetIPCInternalRequest(
uint32_t loadFlags;
MOZ_TRY(underlyingChannel->GetLoadFlags(&loadFlags));

nsCOMPtr<nsILoadInfo> loadInfo;
MOZ_TRY(underlyingChannel->GetLoadInfo(getter_AddRefs(loadInfo)));
MOZ_ASSERT(loadInfo);

nsCOMPtr<nsILoadInfo> loadInfo = underlyingChannel->LoadInfo();
nsContentPolicyType contentPolicyType = loadInfo->InternalContentPolicyType();

nsAutoString integrity;
Expand Down
6 changes: 1 addition & 5 deletions dom/workers/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,11 +1117,7 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
respectedCOEP = mWorkerPrivate->GetOwnerEmbedderPolicy();
}

nsCOMPtr<nsILoadInfo> channelLoadInfo;
rv = channel->GetLoadInfo(getter_AddRefs(channelLoadInfo));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsILoadInfo> channelLoadInfo = channel->LoadInfo();
channelLoadInfo->SetLoadingEmbedderPolicy(respectedCOEP);
}

Expand Down
4 changes: 1 addition & 3 deletions netwerk/ipc/DocumentLoadListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,7 @@ void DocumentLoadListener::SerializeRedirectData(
// clears the principal to inherit, which fails tests (probably because this
// 'redirect' is usually just an implementation detail). It's also http
// only, and mChannel can be anything that we redirected to.
nsCOMPtr<nsILoadInfo> channelLoadInfo;
mChannel->GetLoadInfo(getter_AddRefs(channelLoadInfo));

nsCOMPtr<nsILoadInfo> channelLoadInfo = mChannel->LoadInfo();
nsCOMPtr<nsIPrincipal> principalToInherit;
channelLoadInfo->GetPrincipalToInherit(getter_AddRefs(principalToInherit));

Expand Down
3 changes: 1 addition & 2 deletions netwerk/protocol/http/nsHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ void AccumulateCacheHitTelemetry(CacheDisposition hitOrMiss,
nsIChannel* aChannel) {
nsCString key("UNKNOWN");

nsCOMPtr<nsILoadInfo> loadInfo;
Unused << aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();

nsAutoCString contentType;
if (NS_SUCCEEDED(aChannel->GetContentType(contentType))) {
Expand Down

0 comments on commit f8e1e72

Please sign in to comment.