Skip to content

Commit

Permalink
Bug 1620119 - Remove isActive from DocumentChannelCreationArgs. r=nika
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D65444

--HG--
extra : moz-landing-system : lando
  • Loading branch information
djg committed Mar 10, 2020
1 parent 27632ab commit 2fb206b
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 36 deletions.
45 changes: 28 additions & 17 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,22 @@ static bool IsTopLevelDoc(nsILoadInfo* aLoadInfo) {
return bc && bc->IsTopContent();
}

// True if loading for top level document loading in active tab.
static bool IsUrgentStart(nsILoadInfo* aLoadInfo, uint32_t aLoadType) {
if (!IsTopLevelDoc(aLoadInfo)) {
return false;
}

if (aLoadType &
(nsIDocShell::LOAD_CMD_NORMAL | nsIDocShell::LOAD_CMD_HISTORY)) {
return true;
}

RefPtr<BrowsingContext> bc;
MOZ_ALWAYS_SUCCEEDS(aLoadInfo->GetTargetBrowsingContext(getter_AddRefs(bc)));
return bc && bc->GetIsActive();
}

static bool HasNonEmptySandboxingFlags(nsILoadInfo* aLoadInfo) {
// NOTE: HasNonEmptySandboxingFlag used to come from
// nsDocShell::mBrowsingContext. nsDocShell::OpenInitializedChannel sets the
Expand Down Expand Up @@ -9394,7 +9410,7 @@ static bool SchemeUsesDocChannel(nsIURI* aURI) {
nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo,
nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell,
const OriginAttributes& aOriginAttributes, nsLoadFlags aLoadFlags,
uint32_t aCacheKey, bool aIsActive, nsresult& aRv, nsIChannel** aChannel) {
uint32_t aCacheKey, nsresult& aRv, nsIChannel** aChannel) {
MOZ_ASSERT(aLoadInfo);

nsString srcdoc = VoidString();
Expand Down Expand Up @@ -9423,8 +9439,6 @@ static bool SchemeUsesDocChannel(nsIURI* aURI) {

OriginAttributes attrs;

const bool isTopLevelDoc = IsTopLevelDoc(aLoadInfo);

// Inherit origin attributes from PrincipalToInherit if inheritAttrs is
// true. Otherwise we just use the origin attributes from docshell.
if (inheritAttrs) {
Expand All @@ -9437,7 +9451,7 @@ static bool SchemeUsesDocChannel(nsIURI* aURI) {
attrs == aOriginAttributes);
} else {
attrs = aOriginAttributes;
attrs.SetFirstPartyDomain(isTopLevelDoc, aLoadState->URI());
attrs.SetFirstPartyDomain(IsTopLevelDoc(aLoadInfo), aLoadState->URI());
}

aRv = aLoadInfo->SetOriginAttributes(attrs);
Expand Down Expand Up @@ -9527,14 +9541,14 @@ static bool SchemeUsesDocChannel(nsIURI* aURI) {
aRv = httpChannel->SetReferrerInfo(referrerInfo);
MOZ_ASSERT(NS_SUCCEEDED(aRv));
}
}

// Mark the http channel as UrgentStart for top level document loading
// in active tab.
if (aIsActive && httpChannel && isTopLevelDoc) {
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));
if (cos) {
cos->AddClassFlags(nsIClassOfService::UrgentStart);
// Mark the http channel as UrgentStart for top level document loading in
// active tab.
if (IsUrgentStart(aLoadInfo, aLoadState->LoadType())) {
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));
if (cos) {
cos->AddClassFlags(nsIClassOfService::UrgentStart);
}
}
}

Expand Down Expand Up @@ -9938,9 +9952,6 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
cacheKey = mOSHE->GetCacheKey();
}

bool isActive = mBrowsingContext->GetIsActive() ||
(mLoadType & (LOAD_CMD_NORMAL | LOAD_CMD_HISTORY));

// We want to use DocumentChannel if we're using a supported scheme, or if
// we're a sandboxed srcdoc load. Non-sandboxed srcdoc loads need to share
// the same principal object as their outer document (and must load in the
Expand All @@ -9952,12 +9963,12 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,

if (StaticPrefs::browser_tabs_documentchannel() && XRE_IsContentProcess() &&
canUseDocumentChannel) {
channel = new DocumentChannelChild(aLoadState, loadInfo, loadFlags,
cacheKey, isActive);
channel =
new DocumentChannelChild(aLoadState, loadInfo, loadFlags, cacheKey);
channel->SetNotificationCallbacks(this);
} else if (!CreateAndConfigureRealChannelForLoadState(
aLoadState, loadInfo, this, this, GetOriginAttributes(),
loadFlags, cacheKey, isActive, rv, getter_AddRefs(channel))) {
loadFlags, cacheKey, rv, getter_AddRefs(channel))) {
return rv;
}

Expand Down
2 changes: 1 addition & 1 deletion docshell/base/nsDocShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class nsDocShell final : public nsDocLoader,
nsDocShellLoadState* aLoadState, mozilla::net::LoadInfo* aLoadInfo,
nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell,
const mozilla::OriginAttributes& aOriginAttributes,
nsLoadFlags aLoadFlags, uint32_t aCacheKey, bool aIsActive, nsresult& rv,
nsLoadFlags aLoadFlags, uint32_t aCacheKey, nsresult& rv,
nsIChannel** aChannel);

// Notify consumers of a search being loaded through the observer service:
Expand Down
4 changes: 1 addition & 3 deletions netwerk/ipc/DocumentChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ NS_INTERFACE_MAP_END

DocumentChannel::DocumentChannel(nsDocShellLoadState* aLoadState,
net::LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey,
bool aIsActive)
nsLoadFlags aLoadFlags, uint32_t aCacheKey)
: mAsyncOpenTime(TimeStamp::Now()),
mLoadState(aLoadState),
mCacheKey(aCacheKey),
mIsActive(aIsActive),
mLoadFlags(aLoadFlags),
mURI(aLoadState->URI()),
mLoadInfo(aLoadInfo) {
Expand Down
3 changes: 1 addition & 2 deletions netwerk/ipc/DocumentChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DocumentChannel : public nsIIdentChannel, public nsITraceableChannel {
NS_DECLARE_STATIC_IID_ACCESSOR(DOCUMENT_CHANNEL_IID)

DocumentChannel(nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey, bool aIsActive);
nsLoadFlags aLoadFlags, uint32_t aCacheKey);

const nsTArray<DocumentChannelRedirect>& GetRedirectChain() const {
return mRedirects;
Expand Down Expand Up @@ -81,7 +81,6 @@ class DocumentChannel : public nsIIdentChannel, public nsITraceableChannel {
const TimeStamp mAsyncOpenTime;
const RefPtr<nsDocShellLoadState> mLoadState;
const uint32_t mCacheKey;
const bool mIsActive;

nsresult mStatus = NS_OK;
bool mCanceled = false;
Expand Down
5 changes: 2 additions & 3 deletions netwerk/ipc/DocumentChannelChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ NS_IMPL_RELEASE_INHERITED(DocumentChannelChild, DocumentChannel)
DocumentChannelChild::DocumentChannelChild(nsDocShellLoadState* aLoadState,
net::LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags,
uint32_t aCacheKey, bool aIsActive)
: DocumentChannel(aLoadState, aLoadInfo, aLoadFlags, aCacheKey, aIsActive) {
uint32_t aCacheKey)
: DocumentChannel(aLoadState, aLoadInfo, aLoadFlags, aCacheKey) {
LOG(("DocumentChannelChild ctor [this=%p, uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
}
Expand Down Expand Up @@ -84,7 +84,6 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
args.loadInfo() = *maybeArgs;
args.loadFlags() = mLoadFlags;
args.cacheKey() = mCacheKey;
args.isActive() = mIsActive;
args.channelId() = mChannelId;
args.asyncOpenTime() = mAsyncOpenTime;
args.documentOpenFlags() = mDocumentOpenFlags;
Expand Down
2 changes: 1 addition & 1 deletion netwerk/ipc/DocumentChannelChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DocumentChannelChild final : public DocumentChannel,
public:
DocumentChannelChild(nsDocShellLoadState* aLoadState,
class LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags,
uint32_t aCacheKey, bool aIsActive);
uint32_t aCacheKey);

NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
Expand Down
2 changes: 1 addition & 1 deletion netwerk/ipc/DocumentChannelParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) {

rv = NS_ERROR_UNEXPECTED;
if (!mParent->Open(loadState, loadInfo, aArgs.loadFlags(), aArgs.cacheKey(),
aArgs.isActive(), aArgs.channelId(), aArgs.asyncOpenTime(),
aArgs.channelId(), aArgs.asyncOpenTime(),
aArgs.documentOpenFlags(), aArgs.pluginsAllowed(),
aArgs.timing().refOr(nullptr), std::move(clientInfo),
aArgs.outerWindowId(), &rv)) {
Expand Down
11 changes: 5 additions & 6 deletions netwerk/ipc/DocumentLoadListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,10 @@ CanonicalBrowsingContext* DocumentLoadListener::GetBrowsingContext() {

bool DocumentLoadListener::Open(
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey, bool aIsActive,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
const Maybe<uint32_t>& aDocumentOpenFlags, bool aPluginsAllowed,
nsDOMNavigationTiming* aTiming, Maybe<ClientInfo>&& aInfo,
uint64_t aOuterWindowId, nsresult* aRv) {
nsLoadFlags aLoadFlags, uint32_t aCacheKey, const uint64_t& aChannelId,
const TimeStamp& aAsyncOpenTime, const Maybe<uint32_t>& aDocumentOpenFlags,
bool aPluginsAllowed, nsDOMNavigationTiming* aTiming,
Maybe<ClientInfo>&& aInfo, uint64_t aOuterWindowId, nsresult* aRv) {
LOG(("DocumentLoadListener Open [this=%p, uri=%s]", this,
aLoadState->URI()->GetSpecOrDefault().get()));
RefPtr<CanonicalBrowsingContext> browsingContext =
Expand All @@ -374,7 +373,7 @@ bool DocumentLoadListener::Open(

if (!nsDocShell::CreateAndConfigureRealChannelForLoadState(
aLoadState, loadInfo, mParentChannelListener, nullptr, attrs,
aLoadFlags, aCacheKey, aIsActive, *aRv, getter_AddRefs(mChannel))) {
aLoadFlags, aCacheKey, *aRv, getter_AddRefs(mChannel))) {
mParentChannelListener = nullptr;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion netwerk/ipc/DocumentLoadListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DocumentLoadListener : public nsIInterfaceRequestor,

// Creates the channel, and then calls AsyncOpen on it.
bool Open(nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aCacheKey, bool aIsActive,
nsLoadFlags aLoadFlags, uint32_t aCacheKey,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
const Maybe<uint32_t>& aDocumentOpenFlags, bool aPluginsAllowed,
nsDOMNavigationTiming* aTiming, Maybe<dom::ClientInfo>&& aInfo,
Expand Down
1 change: 0 additions & 1 deletion netwerk/ipc/NeckoChannelParams.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ struct DocumentChannelCreationArgs {
uint32_t loadFlags;
uint32_t cacheKey;
uint32_t? documentOpenFlags;
bool isActive;
bool pluginsAllowed;
nsDOMNavigationTiming? timing;
IPCClientInfo? initialClientInfo;
Expand Down

0 comments on commit 2fb206b

Please sign in to comment.