Bug 1556489 - P18. Add DocumentChannel and hook it up. r=nika,mayhemer

DocumentChannel acts as a replacement for HttpChannel where redirects are now entirely handled in the DocumentChannelParent. The ContentChild will receive the final nsIChannel once all redirects have been handled.

Differential Revision: https://phabricator.services.mozilla.com/D37490
This commit is contained in:
Matt Woodrow
2019-08-07 15:54:53 +10:00
committed by Jean-Yves Avenard
parent ac0bfbad70
commit f5f911a2ba
19 changed files with 1929 additions and 15 deletions

View File

@@ -70,6 +70,7 @@
#include "mozilla/dom/nsCSPContext.h"
#include "mozilla/dom/LoadURIOptionsBinding.h"
#include "mozilla/net/DocumentChannelChild.h"
#include "mozilla/net/UrlClassifierFeatureFactory.h"
#include "ReferrerInfo.h"
@@ -9760,12 +9761,27 @@ static bool IsConsideredSameOriginForUIR(nsIPrincipal* aTriggeringPrincipal,
return aTriggeringPrincipal->Equals(tmpResultPrincipal);
}
static bool HasHttpScheme(nsIURI* aURI) {
return aURI && (aURI->SchemeIs("http") || aURI->SchemeIs("https"));
}
/* static */ bool nsDocShell::CreateChannelForLoadState(
nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo,
nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell,
const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc, nsresult& aRv,
nsIChannel** aChannel) {
if (StaticPrefs::browser_tabs_documentchannel() && XRE_IsContentProcess() &&
HasHttpScheme(aLoadState->URI())) {
RefPtr<DocumentChannelChild> child = new DocumentChannelChild(
aLoadState, aLoadInfo, aInitiatorType, aLoadFlags, aLoadType, aCacheKey,
aIsActive, aIsTopLevelDoc);
child->SetNotificationCallbacks(aCallbacks);
child.forget(aChannel);
aRv = NS_OK;
return true;
}
nsCOMPtr<nsIChannel> channel;
nsAutoString srcdoc;
bool isSrcdoc = aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_IS_SRCDOC);