Bug 1157029 - More changes to bulletproof shutdown of failed connections, r=janv.
authorBen Turner <bent.mozilla@gmail.com>
Thu, 23 Apr 2015 15:08:40 -0700
changeset 270714 12409cbb8d6157fe0665afb9a0fe99e840afde3c
parent 270713 45bbfe5ef9b20adebd5a4306ae0c666fd38b3bcf
child 270715 ed85216e30a09e655c03b6d38770609938fe46bf
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1157029
milestone40.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 1157029 - More changes to bulletproof shutdown of failed connections, r=janv.
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -6622,19 +6622,16 @@ private:
 
   void
   EnsureDatabaseActor();
 
   nsresult
   EnsureDatabaseActorIsAlive();
 
   void
-  CleanupBackgroundThreadObjects(bool aInvalidate);
-
-  void
   MetadataToSpec(DatabaseSpec& aSpec);
 
   void
   AssertMetadataConsistency(const FullDatabaseMetadata* aMetadata)
 #ifdef DEBUG
   ;
 #else
   { }
@@ -17114,20 +17111,16 @@ OpenDatabaseOp::OpenDatabaseOp(Factory* 
 
 void
 OpenDatabaseOp::ActorDestroy(ActorDestroyReason aWhy)
 {
   AssertIsOnOwningThread();
 
   FactoryOp::ActorDestroy(aWhy);
 
-  if (aWhy != Deletion) {
-    CleanupBackgroundThreadObjects(/* aInvalidate */ true);
-  }
-
   if (mVersionChangeOp) {
     mVersionChangeOp->NoteActorDestroyed();
   }
 }
 
 nsresult
 OpenDatabaseOp::QuotaManagerOpen()
 {
@@ -17902,17 +17895,35 @@ OpenDatabaseOp::SendResults()
 #endif
       response = ClampResultCode(mResultCode);
     }
 
     unused <<
       PBackgroundIDBFactoryRequestParent::Send__delete__(this, response);
   }
 
-  CleanupBackgroundThreadObjects(NS_FAILED(mResultCode));
+  if (mDatabase) {
+    MOZ_ASSERT(!mOfflineStorage);
+
+    if (NS_FAILED(mResultCode)) {
+      mDatabase->Invalidate();
+    }
+
+    // Make sure to release the database on this thread.
+    mDatabase = nullptr;
+  } else if (mOfflineStorage) {
+    mOfflineStorage->CloseOnOwningThread();
+
+    nsCOMPtr<nsIRunnable> callback =
+      NS_NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback);
+
+    nsRefPtr<WaitForTransactionsHelper> helper =
+      new WaitForTransactionsHelper(mDatabaseId, callback);
+    helper->WaitForTransactions();
+  }
 
   FinishSendResults();
 }
 
 void
 OpenDatabaseOp::ConnectionClosedCallback()
 {
   AssertIsOnOwningThread();
@@ -17995,43 +18006,16 @@ OpenDatabaseOp::EnsureDatabaseActorIsAli
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   return NS_OK;
 }
 
 void
-OpenDatabaseOp::CleanupBackgroundThreadObjects(bool aInvalidate)
-{
-  AssertIsOnOwningThread();
-  MOZ_ASSERT(IsActorDestroyed());
-
-  if (mDatabase) {
-    MOZ_ASSERT(!mOfflineStorage);
-
-    if (aInvalidate) {
-      mDatabase->Invalidate();
-    }
-
-    // Make sure to release the database on this thread.
-    mDatabase = nullptr;
-  } else if (mOfflineStorage) {
-    mOfflineStorage->CloseOnOwningThread();
-
-    nsCOMPtr<nsIRunnable> callback =
-      NS_NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback);
-
-    nsRefPtr<WaitForTransactionsHelper> helper =
-      new WaitForTransactionsHelper(mDatabaseId, callback);
-    helper->WaitForTransactions();
-  }
-}
-
-void
 OpenDatabaseOp::MetadataToSpec(DatabaseSpec& aSpec)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mMetadata);
 
   class MOZ_STACK_CLASS Helper final
   {
     DatabaseSpec& mSpec;