зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1600906 - Encapsulate DatabaseOperationBase::mResultCode. r=dom-workers-and-storage-reviewers,ytausky
Differential Revision: https://phabricator.services.mozilla.com/D56014 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ff97600e5a
Коммит
c87fdd4c9a
|
@ -5385,14 +5385,14 @@ class DatabaseOperationBase : public Runnable,
|
||||||
|
|
||||||
typedef nsDataHashtable<nsUint64HashKey, bool> UniqueIndexTable;
|
typedef nsDataHashtable<nsUint64HashKey, bool> UniqueIndexTable;
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> mOwningEventTarget;
|
const nsCOMPtr<nsIEventTarget> mOwningEventTarget;
|
||||||
const nsID mBackgroundChildLoggingId;
|
const nsID mBackgroundChildLoggingId;
|
||||||
const uint64_t mLoggingSerialNumber;
|
const uint64_t mLoggingSerialNumber;
|
||||||
nsresult mResultCode;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
nsresult mResultCode = NS_OK;
|
||||||
Atomic<bool> mOperationMayProceed;
|
Atomic<bool> mOperationMayProceed;
|
||||||
bool mActorDestroyed;
|
FlippedOnce<false> mActorDestroyed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
@ -5413,7 +5413,7 @@ class DatabaseOperationBase : public Runnable,
|
||||||
void NoteActorDestroyed() {
|
void NoteActorDestroyed() {
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
|
|
||||||
mActorDestroyed = true;
|
mActorDestroyed.Flip();
|
||||||
mOperationMayProceed = false;
|
mOperationMayProceed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5435,13 +5435,19 @@ class DatabaseOperationBase : public Runnable,
|
||||||
|
|
||||||
nsresult ResultCode() const { return mResultCode; }
|
nsresult ResultCode() const { return mResultCode; }
|
||||||
|
|
||||||
void SetFailureCode(nsresult aErrorCode) {
|
void SetFailureCode(nsresult aFailureCode) {
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
||||||
MOZ_ASSERT(NS_FAILED(aErrorCode));
|
OverrideFailureCode(aFailureCode);
|
||||||
|
|
||||||
mResultCode = aErrorCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetFailureCodeIfUnset(nsresult aFailureCode) {
|
||||||
|
if (NS_SUCCEEDED(mResultCode)) {
|
||||||
|
OverrideFailureCode(aFailureCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasFailed() const { return NS_FAILED(mResultCode); }
|
||||||
|
|
||||||
static nsresult GetStructuredCloneReadInfoFromStatement(
|
static nsresult GetStructuredCloneReadInfoFromStatement(
|
||||||
mozIStorageStatement* aStatement, uint32_t aDataIndex,
|
mozIStorageStatement* aStatement, uint32_t aDataIndex,
|
||||||
uint32_t aFileIdsIndex, const FileManager& aFileManager,
|
uint32_t aFileIdsIndex, const FileManager& aFileManager,
|
||||||
|
@ -5457,14 +5463,18 @@ class DatabaseOperationBase : public Runnable,
|
||||||
mOwningEventTarget(GetCurrentThreadEventTarget()),
|
mOwningEventTarget(GetCurrentThreadEventTarget()),
|
||||||
mBackgroundChildLoggingId(aBackgroundChildLoggingId),
|
mBackgroundChildLoggingId(aBackgroundChildLoggingId),
|
||||||
mLoggingSerialNumber(aLoggingSerialNumber),
|
mLoggingSerialNumber(aLoggingSerialNumber),
|
||||||
mResultCode(NS_OK),
|
mOperationMayProceed(true) {
|
||||||
mOperationMayProceed(true),
|
|
||||||
mActorDestroyed(false) {
|
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
~DatabaseOperationBase() override { MOZ_ASSERT(mActorDestroyed); }
|
~DatabaseOperationBase() override { MOZ_ASSERT(mActorDestroyed); }
|
||||||
|
|
||||||
|
void OverrideFailureCode(nsresult aFailureCode) {
|
||||||
|
MOZ_ASSERT(NS_FAILED(aFailureCode));
|
||||||
|
|
||||||
|
mResultCode = aFailureCode;
|
||||||
|
}
|
||||||
|
|
||||||
static nsAutoCString MaybeGetBindingClauseForKeyRange(
|
static nsAutoCString MaybeGetBindingClauseForKeyRange(
|
||||||
const Maybe<SerializedKeyRange>& aOptionalKeyRange,
|
const Maybe<SerializedKeyRange>& aOptionalKeyRange,
|
||||||
const nsACString& aKeyColumnName);
|
const nsACString& aKeyColumnName);
|
||||||
|
@ -13627,7 +13637,7 @@ mozilla::ipc::IPCResult Database::RecvClose() {
|
||||||
void Database::StartTransactionOp::RunOnConnectionThread() {
|
void Database::StartTransactionOp::RunOnConnectionThread() {
|
||||||
MOZ_ASSERT(!IsOnBackgroundThread());
|
MOZ_ASSERT(!IsOnBackgroundThread());
|
||||||
MOZ_ASSERT(Transaction());
|
MOZ_ASSERT(Transaction());
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
MOZ_ASSERT(!HasFailed());
|
||||||
|
|
||||||
IDB_LOG_MARK_PARENT_TRANSACTION("Beginning database work", "DB Start",
|
IDB_LOG_MARK_PARENT_TRANSACTION("Beginning database work", "DB Start",
|
||||||
IDB_LOG_ID_STRING(mBackgroundChildLoggingId),
|
IDB_LOG_ID_STRING(mBackgroundChildLoggingId),
|
||||||
|
@ -14759,7 +14769,7 @@ void VersionChangeTransaction::UpdateMetadata(nsresult aResult) {
|
||||||
void VersionChangeTransaction::SendCompleteNotification(nsresult aResult) {
|
void VersionChangeTransaction::SendCompleteNotification(nsresult aResult) {
|
||||||
AssertIsOnBackgroundThread();
|
AssertIsOnBackgroundThread();
|
||||||
MOZ_ASSERT(mOpenDatabaseOp);
|
MOZ_ASSERT(mOpenDatabaseOp);
|
||||||
MOZ_ASSERT_IF(!mActorWasAlive, NS_FAILED(mOpenDatabaseOp->mResultCode));
|
MOZ_ASSERT_IF(!mActorWasAlive, mOpenDatabaseOp->HasFailed());
|
||||||
MOZ_ASSERT_IF(!mActorWasAlive, mOpenDatabaseOp->mState >
|
MOZ_ASSERT_IF(!mActorWasAlive, mOpenDatabaseOp->mState >
|
||||||
OpenDatabaseOp::State::SendingResults);
|
OpenDatabaseOp::State::SendingResults);
|
||||||
|
|
||||||
|
@ -14770,12 +14780,12 @@ void VersionChangeTransaction::SendCompleteNotification(nsresult aResult) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(aResult) && NS_SUCCEEDED(openDatabaseOp->mResultCode)) {
|
if (NS_FAILED(aResult)) {
|
||||||
// 3.3.1 Opening a database:
|
// 3.3.1 Opening a database:
|
||||||
// "If the upgrade transaction was aborted, run the steps for closing a
|
// "If the upgrade transaction was aborted, run the steps for closing a
|
||||||
// database connection with connection, create and return a new AbortError
|
// database connection with connection, create and return a new AbortError
|
||||||
// exception and abort these steps."
|
// exception and abort these steps."
|
||||||
openDatabaseOp->mResultCode = NS_ERROR_DOM_INDEXEDDB_ABORT_ERR;
|
openDatabaseOp->SetFailureCodeIfUnset(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
openDatabaseOp->mState = OpenDatabaseOp::State::SendingResults;
|
openDatabaseOp->mState = OpenDatabaseOp::State::SendingResults;
|
||||||
|
@ -20303,9 +20313,7 @@ FactoryOp::Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::SendingResults) {
|
if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::SendingResults) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(rv);
|
||||||
mResultCode = rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must set mState before dispatching otherwise we will race with the owning
|
// Must set mState before dispatching otherwise we will race with the owning
|
||||||
// thread.
|
// thread.
|
||||||
|
@ -20335,9 +20343,7 @@ void FactoryOp::DirectoryLockAcquired(DirectoryLock* aLock) {
|
||||||
|
|
||||||
nsresult rv = DirectoryOpen();
|
nsresult rv = DirectoryOpen();
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(rv);
|
||||||
mResultCode = rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The caller holds a strong reference to us, no need for a self reference
|
// The caller holds a strong reference to us, no need for a self reference
|
||||||
// before calling Run().
|
// before calling Run().
|
||||||
|
@ -20354,9 +20360,9 @@ void FactoryOp::DirectoryLockFailed() {
|
||||||
MOZ_ASSERT(mState == State::DirectoryOpenPending);
|
MOZ_ASSERT(mState == State::DirectoryOpenPending);
|
||||||
MOZ_ASSERT(!mDirectoryLock);
|
MOZ_ASSERT(!mDirectoryLock);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
if (!HasFailed()) {
|
||||||
IDB_REPORT_INTERNAL_ERR();
|
IDB_REPORT_INTERNAL_ERR();
|
||||||
mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
SetFailureCode(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The caller holds a strong reference to us, no need for a self reference
|
// The caller holds a strong reference to us, no need for a self reference
|
||||||
|
@ -21188,9 +21194,7 @@ void OpenDatabaseOp::NoteDatabaseClosed(Database* aDatabase) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(rv);
|
||||||
mResultCode = rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A strong reference is held in kungFuDeathGrip, so it's safe to call Run()
|
// A strong reference is held in kungFuDeathGrip, so it's safe to call Run()
|
||||||
// directly.
|
// directly.
|
||||||
|
@ -21261,7 +21265,7 @@ nsresult OpenDatabaseOp::SendUpgradeNeeded() {
|
||||||
MOZ_ASSERT(mState == State::DatabaseWorkVersionChange);
|
MOZ_ASSERT(mState == State::DatabaseWorkVersionChange);
|
||||||
MOZ_ASSERT(mVersionChangeTransaction);
|
MOZ_ASSERT(mVersionChangeTransaction);
|
||||||
MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
|
MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
MOZ_ASSERT(!HasFailed());
|
||||||
MOZ_ASSERT_IF(!IsActorDestroyed(), mDatabase);
|
MOZ_ASSERT_IF(!IsActorDestroyed(), mDatabase);
|
||||||
|
|
||||||
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
|
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
|
||||||
|
@ -21294,8 +21298,8 @@ nsresult OpenDatabaseOp::SendUpgradeNeeded() {
|
||||||
void OpenDatabaseOp::SendResults() {
|
void OpenDatabaseOp::SendResults() {
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
MOZ_ASSERT(mState == State::SendingResults);
|
MOZ_ASSERT(mState == State::SendingResults);
|
||||||
MOZ_ASSERT_IF(NS_SUCCEEDED(mResultCode), mMaybeBlockedDatabases.IsEmpty());
|
MOZ_ASSERT_IF(!HasFailed(), mMaybeBlockedDatabases.IsEmpty());
|
||||||
MOZ_ASSERT_IF(NS_SUCCEEDED(mResultCode), !mVersionChangeTransaction);
|
MOZ_ASSERT_IF(!HasFailed(), !mVersionChangeTransaction);
|
||||||
|
|
||||||
mMaybeBlockedDatabases.Clear();
|
mMaybeBlockedDatabases.Clear();
|
||||||
|
|
||||||
|
@ -21312,20 +21316,18 @@ void OpenDatabaseOp::SendResults() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVersionChangeTransaction) {
|
if (mVersionChangeTransaction) {
|
||||||
MOZ_ASSERT(NS_FAILED(mResultCode));
|
MOZ_ASSERT(HasFailed());
|
||||||
|
|
||||||
mVersionChangeTransaction->Abort(mResultCode, /* aForce */ true);
|
mVersionChangeTransaction->Abort(ResultCode(), /* aForce */ true);
|
||||||
mVersionChangeTransaction = nullptr;
|
mVersionChangeTransaction = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsActorDestroyed()) {
|
if (IsActorDestroyed()) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
FactoryRequestResponse response;
|
FactoryRequestResponse response;
|
||||||
|
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
if (!HasFailed()) {
|
||||||
// If we just successfully completed a versionchange operation then we
|
// If we just successfully completed a versionchange operation then we
|
||||||
// need to update the version in our metadata.
|
// need to update the version in our metadata.
|
||||||
mMetadata->mCommonMetadata.version() = mRequestedVersion;
|
mMetadata->mCommonMetadata.version() = mRequestedVersion;
|
||||||
|
@ -21340,7 +21342,7 @@ void OpenDatabaseOp::SendResults() {
|
||||||
} else {
|
} else {
|
||||||
response = ClampResultCode(rv);
|
response = ClampResultCode(rv);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mResultCode = response.get_nsresult();
|
SetFailureCode(response.get_nsresult());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -21350,7 +21352,7 @@ void OpenDatabaseOp::SendResults() {
|
||||||
// sure we find such cases.
|
// sure we find such cases.
|
||||||
mMetadata = nullptr;
|
mMetadata = nullptr;
|
||||||
#endif
|
#endif
|
||||||
response = ClampResultCode(mResultCode);
|
response = ClampResultCode(ResultCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Unused << PBackgroundIDBFactoryRequestParent::Send__delete__(this,
|
Unused << PBackgroundIDBFactoryRequestParent::Send__delete__(this,
|
||||||
|
@ -21360,7 +21362,7 @@ void OpenDatabaseOp::SendResults() {
|
||||||
if (mDatabase) {
|
if (mDatabase) {
|
||||||
MOZ_ASSERT(!mDirectoryLock);
|
MOZ_ASSERT(!mDirectoryLock);
|
||||||
|
|
||||||
if (NS_FAILED(mResultCode)) {
|
if (HasFailed()) {
|
||||||
mDatabase->Invalidate();
|
mDatabase->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21386,7 +21388,7 @@ void OpenDatabaseOp::SendResults() {
|
||||||
|
|
||||||
void OpenDatabaseOp::ConnectionClosedCallback() {
|
void OpenDatabaseOp::ConnectionClosedCallback() {
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
MOZ_ASSERT(NS_FAILED(mResultCode));
|
MOZ_ASSERT(HasFailed());
|
||||||
MOZ_ASSERT(mDirectoryLock);
|
MOZ_ASSERT(mDirectoryLock);
|
||||||
|
|
||||||
mDirectoryLock = nullptr;
|
mDirectoryLock = nullptr;
|
||||||
|
@ -21399,7 +21401,7 @@ void OpenDatabaseOp::EnsureDatabaseActor() {
|
||||||
MOZ_ASSERT(mState == State::BeginVersionChange ||
|
MOZ_ASSERT(mState == State::BeginVersionChange ||
|
||||||
mState == State::DatabaseWorkVersionChange ||
|
mState == State::DatabaseWorkVersionChange ||
|
||||||
mState == State::SendingResults);
|
mState == State::SendingResults);
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
MOZ_ASSERT(!HasFailed());
|
||||||
MOZ_ASSERT(!mDatabaseFilePath.IsEmpty());
|
MOZ_ASSERT(!mDatabaseFilePath.IsEmpty());
|
||||||
MOZ_ASSERT(!IsActorDestroyed());
|
MOZ_ASSERT(!IsActorDestroyed());
|
||||||
|
|
||||||
|
@ -21441,7 +21443,7 @@ nsresult OpenDatabaseOp::EnsureDatabaseActorIsAlive() {
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
MOZ_ASSERT(mState == State::DatabaseWorkVersionChange ||
|
MOZ_ASSERT(mState == State::DatabaseWorkVersionChange ||
|
||||||
mState == State::SendingResults);
|
mState == State::SendingResults);
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
MOZ_ASSERT(!HasFailed());
|
||||||
MOZ_ASSERT(!IsActorDestroyed());
|
MOZ_ASSERT(!IsActorDestroyed());
|
||||||
|
|
||||||
EnsureDatabaseActor();
|
EnsureDatabaseActor();
|
||||||
|
@ -21952,9 +21954,7 @@ void DeleteDatabaseOp::NoteDatabaseClosed(Database* aDatabase) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(rv);
|
||||||
mResultCode = rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A strong reference is held in kungFuDeathGrip, so it's safe to call Run()
|
// A strong reference is held in kungFuDeathGrip, so it's safe to call Run()
|
||||||
// directly.
|
// directly.
|
||||||
|
@ -21980,10 +21980,10 @@ void DeleteDatabaseOp::SendResults() {
|
||||||
if (!IsActorDestroyed()) {
|
if (!IsActorDestroyed()) {
|
||||||
FactoryRequestResponse response;
|
FactoryRequestResponse response;
|
||||||
|
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
if (!HasFailed()) {
|
||||||
response = DeleteDatabaseRequestResponse(mPreviousVersion);
|
response = DeleteDatabaseRequestResponse(mPreviousVersion);
|
||||||
} else {
|
} else {
|
||||||
response = ClampResultCode(mResultCode);
|
response = ClampResultCode(ResultCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Unused << PBackgroundIDBFactoryRequestParent::Send__delete__(this,
|
Unused << PBackgroundIDBFactoryRequestParent::Send__delete__(this,
|
||||||
|
@ -22058,10 +22058,8 @@ void DeleteDatabaseOp::VersionChangeOp::RunOnOwningThread() {
|
||||||
info->mWaitingFactoryOp = nullptr;
|
info->mWaitingFactoryOp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(mResultCode)) {
|
if (HasFailed()) {
|
||||||
if (NS_SUCCEEDED(deleteOp->ResultCode())) {
|
deleteOp->SetFailureCodeIfUnset(ResultCode());
|
||||||
deleteOp->SetFailureCode(mResultCode);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Inform all the other databases that they are now invalidated. That
|
// Inform all the other databases that they are now invalidated. That
|
||||||
// should remove the previous metadata from our table.
|
// should remove the previous metadata from our table.
|
||||||
|
@ -22115,9 +22113,7 @@ nsresult DeleteDatabaseOp::VersionChangeOp::Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(rv);
|
||||||
mResultCode = rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ALWAYS_SUCCEEDS(mOwningEventTarget->Dispatch(this, NS_DISPATCH_NORMAL));
|
MOZ_ALWAYS_SUCCEEDS(mOwningEventTarget->Dispatch(this, NS_DISPATCH_NORMAL));
|
||||||
}
|
}
|
||||||
|
@ -22189,7 +22185,7 @@ void TransactionDatabaseOperationBase::RunOnConnectionThread() {
|
||||||
MOZ_ASSERT(!IsOnBackgroundThread());
|
MOZ_ASSERT(!IsOnBackgroundThread());
|
||||||
MOZ_ASSERT(mInternalState == InternalState::DatabaseWork);
|
MOZ_ASSERT(mInternalState == InternalState::DatabaseWork);
|
||||||
MOZ_ASSERT(mTransaction);
|
MOZ_ASSERT(mTransaction);
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
|
MOZ_ASSERT(!HasFailed());
|
||||||
|
|
||||||
AUTO_PROFILER_LABEL("TransactionDatabaseOperationBase::RunOnConnectionThread",
|
AUTO_PROFILER_LABEL("TransactionDatabaseOperationBase::RunOnConnectionThread",
|
||||||
DOM);
|
DOM);
|
||||||
|
@ -22198,12 +22194,12 @@ void TransactionDatabaseOperationBase::RunOnConnectionThread() {
|
||||||
|
|
||||||
if (mTransactionIsAborted || mTransaction->IsInvalidatedOnAnyThread()) {
|
if (mTransactionIsAborted || mTransaction->IsInvalidatedOnAnyThread()) {
|
||||||
// This transaction is already set to be aborted or invalidated.
|
// This transaction is already set to be aborted or invalidated.
|
||||||
mResultCode = NS_ERROR_DOM_INDEXEDDB_ABORT_ERR;
|
SetFailureCode(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
|
||||||
} else if (!OperationMayProceed()) {
|
} else if (!OperationMayProceed()) {
|
||||||
// The operation was canceled in some way, likely because the child process
|
// The operation was canceled in some way, likely because the child process
|
||||||
// has crashed.
|
// has crashed.
|
||||||
IDB_REPORT_INTERNAL_ERR();
|
IDB_REPORT_INTERNAL_ERR();
|
||||||
mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
OverrideFailureCode(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
} else {
|
} else {
|
||||||
Database* database = mTransaction->GetDatabase();
|
Database* database = mTransaction->GetDatabase();
|
||||||
MOZ_ASSERT(database);
|
MOZ_ASSERT(database);
|
||||||
|
@ -22211,7 +22207,7 @@ void TransactionDatabaseOperationBase::RunOnConnectionThread() {
|
||||||
// Here we're actually going to perform the database operation.
|
// Here we're actually going to perform the database operation.
|
||||||
nsresult rv = database->EnsureConnection();
|
nsresult rv = database->EnsureConnection();
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
mResultCode = rv;
|
SetFailureCode(rv);
|
||||||
} else {
|
} else {
|
||||||
DatabaseConnection* connection = database->GetConnection();
|
DatabaseConnection* connection = database->GetConnection();
|
||||||
MOZ_ASSERT(connection);
|
MOZ_ASSERT(connection);
|
||||||
|
@ -22221,7 +22217,7 @@ void TransactionDatabaseOperationBase::RunOnConnectionThread() {
|
||||||
if (mLoggingSerialNumber) {
|
if (mLoggingSerialNumber) {
|
||||||
rv = autoProgress.Register(connection->GetStorageConnection(), this);
|
rv = autoProgress.Register(connection->GetStorageConnection(), this);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
mResultCode = rv;
|
SetFailureCode(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22243,7 +22239,7 @@ void TransactionDatabaseOperationBase::RunOnConnectionThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mResultCode = rv;
|
SetFailureCode(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22331,35 +22327,39 @@ void TransactionDatabaseOperationBase::SendPreprocessInfoOrResults(
|
||||||
// destroyed. Normal operations redundantly check if the actor was
|
// destroyed. Normal operations redundantly check if the actor was
|
||||||
// destroyed in SendSuccessResult and SendFailureResult, therefore it's
|
// destroyed in SendSuccessResult and SendFailureResult, therefore it's
|
||||||
// ok to call it in all cases here.
|
// ok to call it in all cases here.
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
if (!HasFailed()) {
|
||||||
IDB_REPORT_INTERNAL_ERR();
|
IDB_REPORT_INTERNAL_ERR();
|
||||||
mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
SetFailureCode(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
}
|
}
|
||||||
} else if (mTransaction->IsInvalidated() || mTransaction->IsAborted()) {
|
} else if (mTransaction->IsInvalidated() || mTransaction->IsAborted()) {
|
||||||
// Aborted transactions always see their requests fail with ABORT_ERR,
|
// Aborted transactions always see their requests fail with ABORT_ERR,
|
||||||
// even if the request succeeded or failed with another error.
|
// even if the request succeeded or failed with another error.
|
||||||
mResultCode = NS_ERROR_DOM_INDEXEDDB_ABORT_ERR;
|
OverrideFailureCode(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
const nsresult rv = [aSendPreprocessInfo, this] {
|
||||||
|
if (HasFailed()) {
|
||||||
|
return ResultCode();
|
||||||
|
}
|
||||||
if (aSendPreprocessInfo) {
|
if (aSendPreprocessInfo) {
|
||||||
// This should not release the IPDL reference.
|
// This should not release the IPDL reference.
|
||||||
mResultCode = SendPreprocessInfo();
|
return SendPreprocessInfo();
|
||||||
} else {
|
|
||||||
// This may release the IPDL reference.
|
|
||||||
mResultCode = SendSuccessResult();
|
|
||||||
}
|
}
|
||||||
}
|
// This may release the IPDL reference.
|
||||||
|
return SendSuccessResult();
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
SetFailureCodeIfUnset(rv);
|
||||||
|
|
||||||
if (NS_FAILED(mResultCode)) {
|
|
||||||
// This should definitely release the IPDL reference.
|
// This should definitely release the IPDL reference.
|
||||||
if (!SendFailureResult(mResultCode)) {
|
if (!SendFailureResult(rv)) {
|
||||||
// Abort the transaction.
|
// Abort the transaction.
|
||||||
mTransaction->Abort(mResultCode, /* aForce */ false);
|
mTransaction->Abort(rv, /* aForce */ false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aSendPreprocessInfo && NS_SUCCEEDED(mResultCode)) {
|
if (aSendPreprocessInfo && !HasFailed()) {
|
||||||
mInternalState = InternalState::WaitingForContinue;
|
mInternalState = InternalState::WaitingForContinue;
|
||||||
|
|
||||||
mWaitingForContinue = true;
|
mWaitingForContinue = true;
|
||||||
|
@ -22723,9 +22723,7 @@ DatabaseOp::Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::SendingResults) {
|
if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::SendingResults) {
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
SetFailureCodeIfUnset(rv);
|
||||||
mResultCode = rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must set mState before dispatching otherwise we will race with the owning
|
// Must set mState before dispatching otherwise we will race with the owning
|
||||||
// thread.
|
// thread.
|
||||||
|
@ -22851,7 +22849,7 @@ void CreateFileOp::SendResults() {
|
||||||
if (!IsActorDestroyed() && !mDatabase->IsInvalidated()) {
|
if (!IsActorDestroyed() && !mDatabase->IsInvalidated()) {
|
||||||
DatabaseRequestResponse response;
|
DatabaseRequestResponse response;
|
||||||
|
|
||||||
if (NS_SUCCEEDED(mResultCode)) {
|
if (!HasFailed()) {
|
||||||
RefPtr<MutableFile> mutableFile;
|
RefPtr<MutableFile> mutableFile;
|
||||||
nsresult rv = CreateMutableFile(getter_AddRefs(mutableFile));
|
nsresult rv = CreateMutableFile(getter_AddRefs(mutableFile));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
@ -22863,11 +22861,11 @@ void CreateFileOp::SendResults() {
|
||||||
} else {
|
} else {
|
||||||
response = ClampResultCode(rv);
|
response = ClampResultCode(rv);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mResultCode = response.get_nsresult();
|
SetFailureCode(response.get_nsresult());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
response = ClampResultCode(mResultCode);
|
response = ClampResultCode(ResultCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Unused << PBackgroundIDBDatabaseRequestParent::Send__delete__(this,
|
Unused << PBackgroundIDBDatabaseRequestParent::Send__delete__(this,
|
||||||
|
@ -24314,7 +24312,7 @@ mozilla::ipc::IPCResult NormalTransactionOp::RecvContinue(
|
||||||
|
|
||||||
switch (aResponse.type()) {
|
switch (aResponse.type()) {
|
||||||
case PreprocessResponse::Tnsresult:
|
case PreprocessResponse::Tnsresult:
|
||||||
mResultCode = aResponse.get_nsresult();
|
SetFailureCode(aResponse.get_nsresult());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PreprocessResponse::TObjectStoreGetPreprocessResponse:
|
case PreprocessResponse::TObjectStoreGetPreprocessResponse:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче