зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1623565 - P3: Remove mLoadFlags from DocumentChannelCreationArgs. r=mattwoodrow,jya
Differential Revision: https://phabricator.services.mozilla.com/D67799
This commit is contained in:
Родитель
0d4af00c6b
Коммит
6ffa81c157
|
@ -9726,7 +9726,8 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
|||
nsCOMPtr<nsIChannel> channel;
|
||||
if (DocumentChannel::CanUseDocumentChannel(aLoadState)) {
|
||||
channel = DocumentChannel::CreateDocumentChannel(aLoadState, loadInfo,
|
||||
loadFlags, this, cacheKey);
|
||||
loadFlags, this, cacheKey,
|
||||
uriModified, isXFOError);
|
||||
MOZ_ASSERT(channel);
|
||||
} else if (!CreateAndConfigureRealChannelForLoadState(
|
||||
mBrowsingContext, aLoadState, loadInfo, this, this,
|
||||
|
|
|
@ -60,13 +60,16 @@ NS_INTERFACE_MAP_END
|
|||
|
||||
DocumentChannel::DocumentChannel(nsDocShellLoadState* aLoadState,
|
||||
net::LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey)
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey,
|
||||
bool aUriModified, bool aIsXFOError)
|
||||
: mAsyncOpenTime(TimeStamp::Now()),
|
||||
mLoadState(aLoadState),
|
||||
mCacheKey(aCacheKey),
|
||||
mLoadFlags(aLoadFlags),
|
||||
mURI(aLoadState->URI()),
|
||||
mLoadInfo(aLoadInfo) {
|
||||
mLoadInfo(aLoadInfo),
|
||||
mUriModified(aUriModified),
|
||||
mIsXFOError(aIsXFOError) {
|
||||
LOG(("DocumentChannel ctor [this=%p, uri=%s]", this,
|
||||
aLoadState->URI()->GetSpecOrDefault().get()));
|
||||
RefPtr<nsHttpHandler> handler = nsHttpHandler::GetInstance();
|
||||
|
@ -173,14 +176,15 @@ bool DocumentChannel::CanUseDocumentChannel(nsDocShellLoadState* aLoadState) {
|
|||
already_AddRefed<DocumentChannel> DocumentChannel::CreateDocumentChannel(
|
||||
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags, nsIInterfaceRequestor* aNotificationCallbacks,
|
||||
uint32_t aCacheKey) {
|
||||
uint32_t aCacheKey, bool aUriModified, bool aIsXFOError) {
|
||||
RefPtr<DocumentChannel> channel;
|
||||
if (XRE_IsContentProcess()) {
|
||||
channel =
|
||||
new DocumentChannelChild(aLoadState, aLoadInfo, aLoadFlags, aCacheKey);
|
||||
channel = new DocumentChannelChild(aLoadState, aLoadInfo, aLoadFlags,
|
||||
aCacheKey, aUriModified, aIsXFOError);
|
||||
} else {
|
||||
channel = new ParentProcessDocumentChannel(aLoadState, aLoadInfo,
|
||||
aLoadFlags, aCacheKey);
|
||||
channel =
|
||||
new ParentProcessDocumentChannel(aLoadState, aLoadInfo, aLoadFlags,
|
||||
aCacheKey, aUriModified, aIsXFOError);
|
||||
}
|
||||
channel->SetNotificationCallbacks(aNotificationCallbacks);
|
||||
return channel.forget();
|
||||
|
@ -288,7 +292,7 @@ DocumentChannel::SetTRRMode(nsIRequest::TRRMode aTRRMode) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP DocumentChannel::SetLoadFlags(nsLoadFlags aLoadFlags) {
|
||||
mLoadFlags = aLoadFlags;
|
||||
MOZ_CRASH("Don't set flags after creation");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,13 +71,14 @@ class DocumentChannel : public nsIIdentChannel, public nsITraceableChannel {
|
|||
static already_AddRefed<DocumentChannel> CreateDocumentChannel(
|
||||
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags, nsIInterfaceRequestor* aNotificationCallbacks,
|
||||
uint32_t aCacheKey);
|
||||
uint32_t aCacheKey, bool aUriModified, bool aIsXFOError);
|
||||
|
||||
static bool CanUseDocumentChannel(nsDocShellLoadState* aLoadState);
|
||||
|
||||
protected:
|
||||
DocumentChannel(nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey);
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey, bool aUriModified,
|
||||
bool aIsXFOError);
|
||||
|
||||
void ShutdownListeners(nsresult aStatusCode);
|
||||
void DisconnectChildListeners(const nsresult& aStatus,
|
||||
|
@ -109,6 +110,12 @@ class DocumentChannel : public nsIIdentChannel, public nsITraceableChannel {
|
|||
nsCOMPtr<nsISupports> mOwner;
|
||||
RefPtr<nsDOMNavigationTiming> mTiming;
|
||||
Maybe<dom::ClientInfo> mInitialClientInfo;
|
||||
// mUriModified is true if we're doing a history load and the URI of the
|
||||
// session history had been modified by pushState/replaceState.
|
||||
bool mUriModified = false;
|
||||
// mIsXFOError is true if we're handling a load error and the status of the
|
||||
// failed channel is NS_ERROR_XFO_VIOLATION.
|
||||
bool mIsXFOError = false;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(DocumentChannel, DOCUMENT_CHANNEL_IID)
|
||||
|
|
|
@ -29,8 +29,10 @@ NS_IMPL_RELEASE_INHERITED(DocumentChannelChild, DocumentChannel)
|
|||
DocumentChannelChild::DocumentChannelChild(nsDocShellLoadState* aLoadState,
|
||||
net::LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags,
|
||||
uint32_t aCacheKey)
|
||||
: DocumentChannel(aLoadState, aLoadInfo, aLoadFlags, aCacheKey) {
|
||||
uint32_t aCacheKey,
|
||||
bool aUriModified, bool aIsXFOError)
|
||||
: DocumentChannel(aLoadState, aLoadInfo, aLoadFlags, aCacheKey,
|
||||
aUriModified, aIsXFOError) {
|
||||
LOG(("DocumentChannelChild ctor [this=%p, uri=%s]", this,
|
||||
aLoadState->URI()->GetSpecOrDefault().get()));
|
||||
}
|
||||
|
@ -81,11 +83,12 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
|
|||
DocumentChannelCreationArgs args;
|
||||
|
||||
args.loadState() = mLoadState->Serialize();
|
||||
args.loadFlags() = mLoadFlags;
|
||||
args.cacheKey() = mCacheKey;
|
||||
args.channelId() = mChannelId;
|
||||
args.asyncOpenTime() = mAsyncOpenTime;
|
||||
args.outerWindowId() = GetDocShell()->GetOuterWindowID();
|
||||
args.uriModified() = mUriModified;
|
||||
args.isXFOError() = mIsXFOError;
|
||||
|
||||
Maybe<IPCClientInfo> ipcClientInfo;
|
||||
if (mInitialClientInfo.isSome()) {
|
||||
|
|
|
@ -27,7 +27,7 @@ class DocumentChannelChild final : public DocumentChannel,
|
|||
public:
|
||||
DocumentChannelChild(nsDocShellLoadState* aLoadState,
|
||||
class LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags,
|
||||
uint32_t aCacheKey);
|
||||
uint32_t aCacheKey, bool aUriModified, bool aIsXFOError);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
|
||||
|
|
|
@ -48,10 +48,11 @@ bool DocumentChannelParent::Init(dom::CanonicalBrowsingContext* aContext,
|
|||
}
|
||||
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
if (!mParent->Open(loadState, aArgs.loadFlags(), aArgs.cacheKey(),
|
||||
Some(aArgs.channelId()), aArgs.asyncOpenTime(),
|
||||
aArgs.timing().refOr(nullptr), std::move(clientInfo),
|
||||
aArgs.outerWindowId(), aArgs.hasValidTransientUserAction(),
|
||||
if (!mParent->Open(loadState, aArgs.cacheKey(), Some(aArgs.channelId()),
|
||||
aArgs.asyncOpenTime(), aArgs.timing().refOr(nullptr),
|
||||
std::move(clientInfo), aArgs.outerWindowId(),
|
||||
aArgs.hasValidTransientUserAction(),
|
||||
Some(aArgs.uriModified()), Some(aArgs.isXFOError()),
|
||||
&rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
|
|
|
@ -360,10 +360,11 @@ CanonicalBrowsingContext* DocumentLoadListener::GetBrowsingContext() {
|
|||
}
|
||||
|
||||
bool DocumentLoadListener::Open(
|
||||
nsDocShellLoadState* aLoadState, nsLoadFlags aLoadFlags, uint32_t aCacheKey,
|
||||
nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
|
||||
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
|
||||
nsDOMNavigationTiming* aTiming, Maybe<ClientInfo>&& aInfo,
|
||||
uint64_t aOuterWindowId, bool aHasGesture, nsresult* aRv) {
|
||||
uint64_t aOuterWindowId, bool aHasGesture, Maybe<bool> aUriModified,
|
||||
Maybe<bool> aIsXFOError, nsresult* aRv) {
|
||||
LOG(("DocumentLoadListener Open [this=%p, uri=%s]", this,
|
||||
aLoadState->URI()->GetSpecOrDefault().get()));
|
||||
RefPtr<CanonicalBrowsingContext> browsingContext =
|
||||
|
@ -388,9 +389,12 @@ bool DocumentLoadListener::Open(
|
|||
RefPtr<LoadInfo> loadInfo =
|
||||
CreateLoadInfo(browsingContext, aLoadState, aOuterWindowId);
|
||||
|
||||
nsLoadFlags loadFlags = aLoadState->CalculateChannelLoadFlags(
|
||||
browsingContext, std::move(aUriModified), std::move(aIsXFOError));
|
||||
|
||||
if (!nsDocShell::CreateAndConfigureRealChannelForLoadState(
|
||||
browsingContext, aLoadState, loadInfo, mParentChannelListener,
|
||||
nullptr, attrs, aLoadFlags, aCacheKey, *aRv,
|
||||
nullptr, attrs, loadFlags, aCacheKey, *aRv,
|
||||
getter_AddRefs(mChannel))) {
|
||||
mParentChannelListener = nullptr;
|
||||
return false;
|
||||
|
@ -578,18 +582,6 @@ bool DocumentLoadListener::OpenFromParent(
|
|||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(*aLoadState);
|
||||
loadState->CalculateLoadURIFlags();
|
||||
|
||||
nsLoadFlags loadFlags = loadState->LoadFlags() |
|
||||
nsIChannel::LOAD_DOCUMENT_URI |
|
||||
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS;
|
||||
uint32_t sandboxFlags = aBrowsingContext->GetSandboxFlags();
|
||||
if ((sandboxFlags & (SANDBOXED_ORIGIN | SANDBOXED_SCRIPTS)) == 0) {
|
||||
loadFlags |= nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE;
|
||||
}
|
||||
if (loadState->FirstParty()) {
|
||||
// tag first party URL loads
|
||||
loadFlags |= nsIChannel::LOAD_INITIAL_DOCUMENT_URI;
|
||||
}
|
||||
|
||||
RefPtr<nsDOMNavigationTiming> timing = new nsDOMNavigationTiming(nullptr);
|
||||
timing->NotifyNavigationStart(
|
||||
aBrowsingContext->GetIsActive()
|
||||
|
@ -612,9 +604,10 @@ bool DocumentLoadListener::OpenFromParent(
|
|||
aBrowsingContext, aBrowsingContext->GetContentParent()->OtherPid());
|
||||
|
||||
nsresult rv;
|
||||
bool result = listener->Open(
|
||||
loadState, loadFlags, cacheKey, channelId, TimeStamp::Now(), timing,
|
||||
std::move(initialClientInfo), aOuterWindowId, false, &rv);
|
||||
bool result =
|
||||
listener->Open(loadState, cacheKey, channelId, TimeStamp::Now(), timing,
|
||||
std::move(initialClientInfo), aOuterWindowId, false,
|
||||
Nothing(), Nothing(), &rv);
|
||||
if (result) {
|
||||
// Create an entry in the redirect channel registrar to
|
||||
// allocate an identifier for this load.
|
||||
|
|
|
@ -94,11 +94,11 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
|
|||
ADocumentChannelBridge* aBridge);
|
||||
|
||||
// Creates the channel, and then calls AsyncOpen on it.
|
||||
bool Open(nsDocShellLoadState* aLoadState, nsLoadFlags aLoadFlags,
|
||||
uint32_t aCacheKey, const Maybe<uint64_t>& aChannelId,
|
||||
const TimeStamp& aAsyncOpenTime, nsDOMNavigationTiming* aTiming,
|
||||
Maybe<dom::ClientInfo>&& aInfo, uint64_t aOuterWindowId,
|
||||
bool aHasGesture, nsresult* aRv);
|
||||
bool Open(nsDocShellLoadState* aLoadState, uint32_t aCacheKey,
|
||||
const Maybe<uint64_t>& aChannelId, const TimeStamp& aAsyncOpenTime,
|
||||
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
|
||||
uint64_t aOuterWindowId, bool aHasGesture, Maybe<bool> aUriModified,
|
||||
Maybe<bool> aIsXFOError, nsresult* aRv);
|
||||
|
||||
// Creates a DocumentLoadListener directly in the parent process without
|
||||
// an associated DocumentChannelBridge.
|
||||
|
|
|
@ -434,13 +434,14 @@ struct DocumentChannelCreationArgs {
|
|||
DocShellLoadStateInit loadState;
|
||||
TimeStamp asyncOpenTime;
|
||||
uint64_t channelId;
|
||||
uint32_t loadFlags;
|
||||
uint32_t cacheKey;
|
||||
bool pluginsAllowed;
|
||||
nsDOMNavigationTiming? timing;
|
||||
IPCClientInfo? initialClientInfo;
|
||||
uint64_t outerWindowId;
|
||||
bool hasValidTransientUserAction;
|
||||
bool uriModified;
|
||||
bool isXFOError;
|
||||
};
|
||||
|
||||
struct DocumentChannelRedirect {
|
||||
|
|
|
@ -20,8 +20,10 @@ NS_IMPL_ISUPPORTS_INHERITED(ParentProcessDocumentChannel, DocumentChannel,
|
|||
|
||||
ParentProcessDocumentChannel::ParentProcessDocumentChannel(
|
||||
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey)
|
||||
: DocumentChannel(aLoadState, aLoadInfo, aLoadFlags, aCacheKey) {
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey, bool aUriModified,
|
||||
bool aIsXFOError)
|
||||
: DocumentChannel(aLoadState, aLoadInfo, aLoadFlags, aCacheKey,
|
||||
aUriModified, aIsXFOError) {
|
||||
LOG(("ParentProcessDocumentChannel ctor [this=%p]", this));
|
||||
}
|
||||
|
||||
|
@ -125,13 +127,12 @@ NS_IMETHODIMP ParentProcessDocumentChannel::AsyncOpen(
|
|||
nsresult rv = NS_OK;
|
||||
Maybe<dom::ClientInfo> initialClientInfo = mInitialClientInfo;
|
||||
if (!mDocumentLoadListener->Open(
|
||||
mLoadState, mLoadFlags, mCacheKey, Some(mChannelId), mAsyncOpenTime,
|
||||
mTiming, std::move(initialClientInfo),
|
||||
GetDocShell()->GetOuterWindowID(),
|
||||
mLoadState, mCacheKey, Some(mChannelId), mAsyncOpenTime, mTiming,
|
||||
std::move(initialClientInfo), GetDocShell()->GetOuterWindowID(),
|
||||
GetDocShell()
|
||||
->GetBrowsingContext()
|
||||
->HasValidTransientUserGestureActivation(),
|
||||
&rv)) {
|
||||
Some(mUriModified), Some(mIsXFOError), &rv)) {
|
||||
MOZ_ASSERT(NS_FAILED(rv));
|
||||
DisconnectDocumentLoadListener();
|
||||
return rv;
|
||||
|
|
|
@ -23,7 +23,8 @@ class ParentProcessDocumentChannel : public DocumentChannel,
|
|||
public:
|
||||
ParentProcessDocumentChannel(nsDocShellLoadState* aLoadState,
|
||||
class LoadInfo* aLoadInfo,
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey);
|
||||
nsLoadFlags aLoadFlags, uint32_t aCacheKey,
|
||||
bool aUriModified, bool aIsXFOError);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
|
||||
|
|
Загрузка…
Ссылка в новой задаче