Bug 1184397 - Release the observer service when the permission manager shuts down; r=jdm
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 15 Jul 2015 20:37:06 -0400
changeset 253526 7f5771d7934def34666d0c414fa5175e3bceea10
parent 253525 250cf47bfa768fc0204ad97e179508f3cbc7d56b
child 253527 246aabca6f2cdde2469f47cbe1c3cede8aec6551
push id29067
push userkwierso@gmail.com
push dateSat, 18 Jul 2015 00:57:04 +0000
treeherdermozilla-central@e2f2eb9ecca0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs1184397
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1184397 - Release the observer service when the permission manager shuts down; r=jdm
extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -649,16 +649,17 @@ nsPermissionManager::Init()
   // If the 'permissions.memory_only' pref is set to true, then don't write any
   // permission settings to disk, but keep them in a memory-only database.
   mMemoryOnlyDB = mozilla::Preferences::GetBool("permissions.memory_only", false);
 
   mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     mObserverService->AddObserver(this, "profile-before-change", true);
     mObserverService->AddObserver(this, "profile-do-change", true);
+    mObserverService->AddObserver(this, "xpcom-shutdown", true);
   }
 
   if (IsChildProcess()) {
     // Stop here; we don't need the DB in the child process
     return FetchPermissions();
   }
 
   // ignore failure here, since it's non-fatal (we can run fine without
@@ -1753,26 +1754,30 @@ NS_IMETHODIMP nsPermissionManager::GetEn
     }
   }
 
   return NS_NewArrayEnumerator(aEnum, array);
 }
 
 NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
 {
+  if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
+    mObserverService = nullptr;
+    return NS_OK;
+  }
+
   ENSURE_NOT_CHILD_PROCESS;
 
   if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
     // The profile is about to change,
     // or is going away because the application is shutting down.
     mIsShuttingDown = true;
     RemoveAllFromMemory();
     CloseDB(false);
-  }
-  else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
+  } else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
     // the profile has already changed; init the db from the new location
     InitDB(false);
   }
 
   return NS_OK;
 }
 
 nsresult