Bug 1701303 - Move counting of private browsing contexts to parent process. r=smaug,johannh
Move the counting of private browsing contexts to the parent process. Also change to only consider non-chrome browsing contexts when counting private contexts. The latter is possible due to bug 1528115, because we no longer need to support hidden private windows. With counting in the parent process we can make sure that when we're changing remoteness on a private browsing context the private browsing context count never drops to zero. This fixes an issue with Fission, where we remoteness changes could transiently have a zero private browsing context count, that would be mistaken for the last private browsing context going away. Changing to only count non-chrome browsing contexts makes us only fire 'last-pb-context-exited' once, and since we count them in the parent there is no missing information about contexts that makes us wait for a content process about telling us about insertion or removal of browsing contexts. Differential Revision: https://phabricator.services.mozilla.com/D118182
This commit is contained in:
@@ -273,9 +273,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
// Number of documents currently loading
|
||||
static int32_t gNumberOfDocumentsLoading = 0;
|
||||
|
||||
// Global count of docshells with the private attribute set
|
||||
static uint32_t gNumberOfPrivateDocShells = 0;
|
||||
|
||||
static mozilla::LazyLogModule gCharsetMenuLog("CharsetMenu");
|
||||
|
||||
#define LOGCHARSETMENU(args) \
|
||||
@@ -307,33 +304,6 @@ static void FavorPerformanceHint(bool aPerfOverStarvation) {
|
||||
}
|
||||
}
|
||||
|
||||
static void IncreasePrivateDocShellCount() {
|
||||
gNumberOfPrivateDocShells++;
|
||||
if (gNumberOfPrivateDocShells > 1 || !XRE_IsContentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
|
||||
cc->SendPrivateDocShellsExist(true);
|
||||
}
|
||||
|
||||
static void DecreasePrivateDocShellCount() {
|
||||
MOZ_ASSERT(gNumberOfPrivateDocShells > 0);
|
||||
gNumberOfPrivateDocShells--;
|
||||
if (!gNumberOfPrivateDocShells) {
|
||||
if (XRE_IsContentProcess()) {
|
||||
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
|
||||
cc->SendPrivateDocShellsExist(false);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService();
|
||||
if (obsvc) {
|
||||
obsvc->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsTopLevelDoc(BrowsingContext* aBrowsingContext,
|
||||
nsILoadInfo* aLoadInfo) {
|
||||
MOZ_ASSERT(aBrowsingContext);
|
||||
@@ -411,7 +381,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
||||
mIsBeingDestroyed(false),
|
||||
mIsExecutingOnLoadHandler(false),
|
||||
mSavingOldViewer(false),
|
||||
mAffectPrivateSessionLifetime(true),
|
||||
mInvisible(false),
|
||||
mHasLoadedNonBlankURI(false),
|
||||
mBlankTiming(false),
|
||||
@@ -1717,14 +1686,6 @@ nsDocShell::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing) {
|
||||
void nsDocShell::NotifyPrivateBrowsingChanged() {
|
||||
MOZ_ASSERT(!mIsBeingDestroyed);
|
||||
|
||||
if (mAffectPrivateSessionLifetime) {
|
||||
if (UsePrivateBrowsing()) {
|
||||
IncreasePrivateDocShellCount();
|
||||
} else {
|
||||
DecreasePrivateDocShellCount();
|
||||
}
|
||||
}
|
||||
|
||||
nsTObserverArray<nsWeakPtr>::ForwardIterator iter(mPrivacyObservers);
|
||||
while (iter.HasMore()) {
|
||||
nsWeakPtr ref = iter.GetNext();
|
||||
@@ -1777,35 +1738,6 @@ nsDocShell::SetRemoteSubframes(bool aUseRemoteSubframes) {
|
||||
return mBrowsingContext->SetRemoteSubframes(aUseRemoteSubframes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime) {
|
||||
MOZ_ASSERT(!mIsBeingDestroyed);
|
||||
|
||||
bool change = aAffectLifetime != mAffectPrivateSessionLifetime;
|
||||
if (change && UsePrivateBrowsing()) {
|
||||
if (aAffectLifetime) {
|
||||
IncreasePrivateDocShellCount();
|
||||
} else {
|
||||
DecreasePrivateDocShellCount();
|
||||
}
|
||||
}
|
||||
mAffectPrivateSessionLifetime = aAffectLifetime;
|
||||
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(child);
|
||||
if (shell) {
|
||||
shell->SetAffectPrivateSessionLifetime(aAffectLifetime);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetAffectPrivateSessionLifetime(bool* aAffectLifetime) {
|
||||
*aAffectLifetime = mAffectPrivateSessionLifetime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::AddWeakPrivacyTransitionObserver(
|
||||
nsIPrivacyTransitionObserver* aObserver) {
|
||||
@@ -2601,8 +2533,6 @@ nsresult nsDocShell::SetDocLoaderParent(nsDocLoader* aParent) {
|
||||
value = false;
|
||||
}
|
||||
SetAllowDNSPrefetch(mAllowDNSPrefetch && value);
|
||||
SetAffectPrivateSessionLifetime(
|
||||
parentAsDocShell->GetAffectPrivateSessionLifetime());
|
||||
|
||||
// We don't need to inherit metaViewportOverride, because the viewport
|
||||
// is only relevant for the outermost nsDocShell, not for any iframes
|
||||
@@ -4527,10 +4457,6 @@ nsDocShell::Destroy() {
|
||||
// to break the cycle between us and the timers.
|
||||
CancelRefreshURITimers();
|
||||
|
||||
if (UsePrivateBrowsing() && mAffectPrivateSessionLifetime) {
|
||||
DecreasePrivateDocShellCount();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user