Bug 804653 - Make destroying a private docshell update the global count of private docshells instead of waiting an indefinite amount of time for the destructor. r=bz
authorJosh Matthews <josh@joshmatthews.net>
Tue, 30 Oct 2012 09:21:52 -0400
changeset 111902 876a728f389a3ffb05b7046fdcea0bf23aaea04c
parent 111901 32c7a15c3b1c84c1bd6a2d99731c81f374cdfe82
child 111903 1545e91c658ec9cd25d9750a43bbe7afd8057cf9
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersbz
bugs804653
milestone19.0a1
Bug 804653 - Make destroying a private docshell update the global count of private docshells instead of waiting an indefinite amount of time for the destructor. r=bz
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -820,20 +820,16 @@ nsDocShell::~nsDocShell()
 #ifdef DEBUG
     // We're counting the number of |nsDocShells| to help find leaks
     --gNumberOfDocShells;
     if (!PR_GetEnv("MOZ_QUIET")) {
         printf("--DOCSHELL %p == %ld [id = %llu]\n", (void*) this,
                gNumberOfDocShells, mHistoryID);
     }
 #endif
-
-    if (mInPrivateBrowsing) {
-        DecreasePrivateDocShellCount();
-    }
 }
 
 nsresult
 nsDocShell::Init()
 {
     nsresult rv = nsDocLoader::Init();
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -4910,16 +4906,22 @@ nsDocShell::Destroy()
     SetTreeOwner(nullptr);
 
     // required to break ref cycle
     mSecurityUI = nullptr;
 
     // Cancel any timers that were set for this docshell; this is needed
     // to break the cycle between us and the timers.
     CancelRefreshURITimers();
+
+    if (mInPrivateBrowsing) {
+        mInPrivateBrowsing = false;
+        DecreasePrivateDocShellCount();
+    }
+
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
 {
     if (mParentWidget) {
         *aScale = mParentWidget->GetDefaultScale();