Bug 715325 - shutdown indexedDB during xpcom-shutdown. r=benjamin.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Fri, 06 Jan 2012 12:07:29 -0500
changeset 85167 f70cf8170972fd502b2c9b3e9cc92f69fa8d3e77
parent 85166 1f17624f1ab7ea7b7a0dbe847307896b4197826f
child 85168 42550933b54b662ca482e82ebfe33e26748be19b
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs715325
milestone12.0a1
Bug 715325 - shutdown indexedDB during xpcom-shutdown. r=benjamin.
dom/indexedDB/IndexedDatabaseManager.cpp
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -247,23 +247,16 @@ IndexedDatabaseManager::GetOrCreate()
     nsCOMPtr<nsIObserverService> obs = GetObserverService();
     NS_ENSURE_TRUE(obs, nsnull);
 
     // We need this callback to know when to shut down all our threads.
     nsresult rv = obs->AddObserver(instance, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                    false);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
-    // We don't really need this callback but we want the observer service to
-    // hold us alive until XPCOM shutdown. That way other consumers can continue
-    // to use this service until shutdown.
-    rv = obs->AddObserver(instance, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID,
-                          false);
-    NS_ENSURE_SUCCESS(rv, nsnull);
-
     // Make a lazy thread for any IO we need (like clearing or enumerating the
     // contents of indexedDB database directories).
     instance->mIOThread = new LazyIdleThread(DEFAULT_THREAD_TIMEOUT_MS,
                                              LazyIdleThread::ManualShutdown);
 
     // We need one quota callback object to hand to SQLite.
     instance->mQuotaCallbackSingleton = new QuotaCallback();
 
@@ -1219,17 +1212,17 @@ IndexedDatabaseManager::ClearDatabasesFo
 
 NS_IMETHODIMP
 IndexedDatabaseManager::Observe(nsISupports* aSubject,
                                 const char* aTopic,
                                 const PRUnichar* aData)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID)) {
+  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
     // Setting this flag prevents the service from being recreated and prevents
     // further databases from being created.
     if (PR_ATOMIC_SET(&gShutdown, 1)) {
       NS_ERROR("Shutdown more than once?!");
     }
 
     // Make sure to join with our IO thread.
     if (NS_FAILED(mIOThread->Shutdown())) {
@@ -1274,21 +1267,16 @@ IndexedDatabaseManager::Observe(nsISuppo
       for (PRUint32 index = 0; index < count; index++) {
         liveDatabases[index]->Invalidate();
       }
     }
 
     return NS_OK;
   }
 
-  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
-    // We're dying now.
-    return NS_OK;
-  }
-
   NS_NOTREACHED("Unknown topic!");
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(IndexedDatabaseManager::OriginClearRunnable,
                               nsIRunnable)
 
 NS_IMETHODIMP