Bug 881723 - Keep all session storage IPC connections alive until there's no chance of forking/cloning them. r=mayhemer, a=leo+
authorJosh Matthews <josh@joshmatthews.net>
Fri, 19 Jul 2013 15:36:50 -0400
changeset 119782 9c6987190007a2503969dd7d216afa7583c10f3a
parent 119781 d2fd06e900b39b29cf3acd46f7a4ac8e5113fa80
child 119783 21265aae3e6022119f6ad45cb00bdd3d784600c3
push id989
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 19:40:09 +0000
reviewersmayhemer, leo
bugs881723
milestone18.1
Bug 881723 - Keep all session storage IPC connections alive until there's no chance of forking/cloning them. r=mayhemer, a=leo+
docshell/base/nsDocShell.cpp
dom/base/nsGlobalWindow.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -798,20 +798,30 @@ nsDocShell::nsDocShell():
   ++gNumberOfDocShells;
   if (!PR_GetEnv("MOZ_QUIET")) {
       printf("++DOCSHELL %p == %ld [id = %llu]\n", (void*) this,
              gNumberOfDocShells, mHistoryID);
   }
 #endif
 }
 
+static PLDHashOperator
+NeuterSessionStorages(nsCStringHashKey::KeyType aKey, nsIDOMStorage* aStorage,
+                      void* aUserArg)
+{
+    aStorage->MarkOwnerDead();
+    return PL_DHASH_NEXT;
+}
+
 nsDocShell::~nsDocShell()
 {
     Destroy();
 
+    mStorages.EnumerateRead(NeuterSessionStorages, nullptr);
+
     nsCOMPtr<nsISHistoryInternal>
         shPrivate(do_QueryInterface(mSessionHistory));
     if (shPrivate) {
         shPrivate->SetRootDocShell(nullptr);
     }
 
     if (--gDocShellCount == 0) {
         NS_IF_RELEASE(sURIFixup);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2205,20 +2205,16 @@ nsGlobalWindow::DispatchDOMWindowCreated
 
 void
 nsGlobalWindow::NeuterStorageInstances()
 {
   if (mLocalStorage) {
     mLocalStorage->MarkOwnerDead();
     mLocalStorage = nullptr;
   }
-  if (mSessionStorage) {
-    mSessionStorage->MarkOwnerDead();
-    mSessionStorage = nullptr;
-  }
 }
 
 void
 nsGlobalWindow::ClearStatus()
 {
   SetStatus(EmptyString());
   SetDefaultStatus(EmptyString());
 }