Bug 1157029 - More changes to bulletproof shutdown of failed connections, r=janv.

This commit is contained in:
Ben Turner 2015-04-23 15:08:40 -07:00
parent b9e62b0591
commit 5c08f8889a

View File

@ -6626,9 +6626,6 @@ private:
nsresult
EnsureDatabaseActorIsAlive();
void
CleanupBackgroundThreadObjects(bool aInvalidate);
void
MetadataToSpec(DatabaseSpec& aSpec);
@ -17119,10 +17116,6 @@ OpenDatabaseOp::ActorDestroy(ActorDestroyReason aWhy)
FactoryOp::ActorDestroy(aWhy);
if (aWhy != Deletion) {
CleanupBackgroundThreadObjects(/* aInvalidate */ true);
}
if (mVersionChangeOp) {
mVersionChangeOp->NoteActorDestroyed();
}
@ -17907,7 +17900,25 @@ OpenDatabaseOp::SendResults()
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();
}
@ -17999,33 +18010,6 @@ OpenDatabaseOp::EnsureDatabaseActorIsAlive()
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)
{