Bug 1102570 - Prevent quota operations from running too soon, r=janv.
authorBen Turner <bent.mozilla@gmail.com>
Thu, 20 Nov 2014 15:54:49 -0800
changeset 241257 03510730721acbd931b79f6495ae1df7606324f7
parent 241256 08df10804c35859cb99a5637a45de0af467c7ca2
child 241258 1fe4af5711ac8d338b2397c2ccfad831d65c2067
push idunknown
push userunknown
push dateunknown
reviewersjanv
bugs1102570
milestone36.0a1
Bug 1102570 - Prevent quota operations from running too soon, r=janv.
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -5342,16 +5342,23 @@ public:
     MOZ_ASSERT(!mRegisteredWithQuotaManager);
 
     mRegisteredWithQuotaManager = true;
   }
 
   void
   CloseOnOwningThread();
 
+  void
+  AssertInvalidatedOnMainThread() const
+  {
+    MOZ_ASSERT(NS_IsMainThread());
+    MOZ_ASSERT(mInvalidatedOnMainThread);
+  }
+
   NS_DECL_THREADSAFE_ISUPPORTS
 
 private:
   ~DatabaseOfflineStorage()
   {
     MOZ_ASSERT(!mDatabase);
     MOZ_ASSERT(!mRegisteredWithQuotaManager);
   }
@@ -9509,17 +9516,19 @@ QuotaClient::WaitForStoragesToComplete(n
 }
 
 void
 QuotaClient::AbortTransactionsForStorage(nsIOfflineStorage* aStorage)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aStorage);
   MOZ_ASSERT(aStorage->GetClient() == this);
-  MOZ_ASSERT(aStorage->IsClosed());
+
+  static_cast<DatabaseOfflineStorage*>(aStorage)->
+    AssertInvalidatedOnMainThread();
 
   // Nothing to do here, calling DatabaseOfflineStorage::Close() should have
   // aborted any transactions already.
 }
 
 bool
 QuotaClient::HasTransactionsForStorage(nsIOfflineStorage* aStorage)
 {
@@ -9904,18 +9913,16 @@ DatabaseOfflineStorage::InvalidateOnMain
   nsCOMPtr<nsIRunnable> runnable =
     NS_NewRunnableMethod(this,
                          &DatabaseOfflineStorage::InvalidateOnOwningThread);
   MOZ_ASSERT(runnable);
 
   nsCOMPtr<nsIEventTarget> owningThread = mOwningThread;
   MOZ_ASSERT(owningThread);
 
-  CloseOnMainThread();
-
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(owningThread->Dispatch(runnable,
                                                       NS_DISPATCH_NORMAL)));
 }
 
 void
 DatabaseOfflineStorage::InvalidateOnOwningThread()
 {
   AssertIsOnBackgroundThread();