Bug 1157029 - More changes to bulletproof shutdown of failed connections. r=janv, a=lizzard
authorBen Turner <bent.mozilla@gmail.com>
Mon, 04 May 2015 14:08:00 -0400
changeset 267377 7270d0935640e037af289aef151e02ee7090d66a
parent 267376 720b046ff520536d9cff97905ef5a0bc26c73738
child 267378 224226d542368a6f1bf2eab1f5fbda711d4e3ed2
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv, lizzard
bugs1157029
milestone39.0a2
Bug 1157029 - More changes to bulletproof shutdown of failed connections. r=janv, a=lizzard
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -4127,32 +4127,26 @@ private:
 
   void
   EnsureDatabaseActor();
 
   nsresult
   EnsureDatabaseActorIsAlive();
 
   void
-  CleanupBackgroundThreadObjects(bool aInvalidate);
-
-  void
   MetadataToSpec(DatabaseSpec& aSpec);
 
   void
   AssertMetadataConsistency(const FullDatabaseMetadata* aMetadata)
 #ifdef DEBUG
   ;
 #else
   { }
 #endif
 
-  virtual void
-  ActorDestroy(ActorDestroyReason aWhy) override;
-
   virtual nsresult
   QuotaManagerOpen() override;
 
   virtual nsresult
   DoDatabaseWork() override;
 
   virtual nsresult
   BeginVersionChange() override;
@@ -11207,28 +11201,16 @@ OpenDatabaseOp::OpenDatabaseOp(Factory* 
     // This is a little scary but it looks safe to call this off the main thread
     // for now.
     optionalContentParentId = mContentParent->ChildID();
   } else {
     optionalContentParentId = void_t();
   }
 }
 
-void
-OpenDatabaseOp::ActorDestroy(ActorDestroyReason aWhy)
-{
-  AssertIsOnOwningThread();
-
-  FactoryOp::ActorDestroy(aWhy);
-
-  if (aWhy != Deletion) {
-    CleanupBackgroundThreadObjects(/* aInvalidate */ true);
-  }
-}
-
 nsresult
 OpenDatabaseOp::QuotaManagerOpen()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mState == State_OpenPending);
   MOZ_ASSERT(!mOfflineStorage);
 
   QuotaClient* quotaClient = QuotaClient::GetInstance();
@@ -11993,17 +11975,29 @@ 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();
+    DatabaseOfflineStorage::UnregisterOnOwningThread(mOfflineStorage.forget());
+  }
 
   FinishSendResults();
 }
 
 void
 OpenDatabaseOp::EnsureDatabaseActor()
 {
   AssertIsOnOwningThread();
@@ -12076,37 +12070,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();
-    DatabaseOfflineStorage::UnregisterOnOwningThread(mOfflineStorage.forget());
-  }
-}
-
-void
 OpenDatabaseOp::MetadataToSpec(DatabaseSpec& aSpec)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mMetadata);
 
   class MOZ_STACK_CLASS Helper final
   {
     DatabaseSpec& mSpec;