зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1598164 - Use scoped enums in IDBTransaction. r=dom-workers-and-storage-reviewers,edenchuang
Differential Revision: https://phabricator.services.mozilla.com/D54321 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f7864022f8
Коммит
55a2f652bc
|
@ -107,7 +107,7 @@ class ThreadLocal {
|
|||
MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
|
||||
INT64_MIN);
|
||||
|
||||
if (aMode == IDBTransaction::VERSION_CHANGE) {
|
||||
if (aMode == IDBTransaction::Mode::VersionChange) {
|
||||
return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
|
||||
}
|
||||
|
||||
|
|
|
@ -7911,7 +7911,7 @@ class DatabaseLoggingInfo final {
|
|||
MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
|
||||
INT64_MIN);
|
||||
|
||||
if (aMode == IDBTransaction::VERSION_CHANGE) {
|
||||
if (aMode == IDBTransaction::Mode::VersionChange) {
|
||||
return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
|
||||
}
|
||||
|
||||
|
@ -10305,11 +10305,11 @@ DatabaseConnection::AutoSavepoint::~AutoSavepoint() {
|
|||
if (mConnection) {
|
||||
mConnection->AssertIsOnConnectionThread();
|
||||
MOZ_ASSERT(mDEBUGTransaction);
|
||||
MOZ_ASSERT(mDEBUGTransaction->GetMode() == IDBTransaction::READ_WRITE ||
|
||||
mDEBUGTransaction->GetMode() ==
|
||||
IDBTransaction::READ_WRITE_FLUSH ||
|
||||
mDEBUGTransaction->GetMode() == IDBTransaction::CLEANUP ||
|
||||
mDEBUGTransaction->GetMode() == IDBTransaction::VERSION_CHANGE);
|
||||
MOZ_ASSERT(
|
||||
mDEBUGTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
|
||||
mDEBUGTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
|
||||
mDEBUGTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
|
||||
mDEBUGTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
|
||||
|
||||
if (NS_FAILED(mConnection->RollbackSavepoint())) {
|
||||
NS_WARNING("Failed to rollback savepoint!");
|
||||
|
@ -10320,10 +10320,10 @@ DatabaseConnection::AutoSavepoint::~AutoSavepoint() {
|
|||
nsresult DatabaseConnection::AutoSavepoint::Start(
|
||||
const TransactionBase* aTransaction) {
|
||||
MOZ_ASSERT(aTransaction);
|
||||
MOZ_ASSERT(aTransaction->GetMode() == IDBTransaction::READ_WRITE ||
|
||||
aTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH ||
|
||||
aTransaction->GetMode() == IDBTransaction::CLEANUP ||
|
||||
aTransaction->GetMode() == IDBTransaction::VERSION_CHANGE);
|
||||
MOZ_ASSERT(aTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
|
||||
aTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
|
||||
aTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
|
||||
aTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
|
||||
|
||||
DatabaseConnection* connection = aTransaction->GetDatabase()->GetConnection();
|
||||
MOZ_ASSERT(connection);
|
||||
|
@ -13217,19 +13217,19 @@ PBackgroundIDBTransactionParent* Database::AllocPBackgroundIDBTransactionParent(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(aMode != IDBTransaction::READ_ONLY &&
|
||||
aMode != IDBTransaction::READ_WRITE &&
|
||||
aMode != IDBTransaction::READ_WRITE_FLUSH &&
|
||||
aMode != IDBTransaction::CLEANUP)) {
|
||||
if (NS_WARN_IF(aMode != IDBTransaction::Mode::ReadOnly &&
|
||||
aMode != IDBTransaction::Mode::ReadWrite &&
|
||||
aMode != IDBTransaction::Mode::ReadWriteFlush &&
|
||||
aMode != IDBTransaction::Mode::Cleanup)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If this is a readwrite transaction to a chrome database make sure the child
|
||||
// has write access.
|
||||
if (NS_WARN_IF((aMode == IDBTransaction::READ_WRITE ||
|
||||
aMode == IDBTransaction::READ_WRITE_FLUSH ||
|
||||
aMode == IDBTransaction::CLEANUP) &&
|
||||
if (NS_WARN_IF((aMode == IDBTransaction::Mode::ReadWrite ||
|
||||
aMode == IDBTransaction::Mode::ReadWriteFlush ||
|
||||
aMode == IDBTransaction::Mode::Cleanup) &&
|
||||
mPrincipalInfo.type() == PrincipalInfo::TSystemPrincipalInfo &&
|
||||
!mChromeWriteAccessAllowed)) {
|
||||
return nullptr;
|
||||
|
@ -13290,10 +13290,10 @@ mozilla::ipc::IPCResult Database::RecvPBackgroundIDBTransactionConstructor(
|
|||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
MOZ_ASSERT(!aObjectStoreNames.IsEmpty());
|
||||
MOZ_ASSERT(aMode == IDBTransaction::READ_ONLY ||
|
||||
aMode == IDBTransaction::READ_WRITE ||
|
||||
aMode == IDBTransaction::READ_WRITE_FLUSH ||
|
||||
aMode == IDBTransaction::CLEANUP);
|
||||
MOZ_ASSERT(aMode == IDBTransaction::Mode::ReadOnly ||
|
||||
aMode == IDBTransaction::Mode::ReadWrite ||
|
||||
aMode == IDBTransaction::Mode::ReadWriteFlush ||
|
||||
aMode == IDBTransaction::Mode::Cleanup);
|
||||
MOZ_ASSERT(!mClosed);
|
||||
|
||||
if (IsInvalidated()) {
|
||||
|
@ -13313,7 +13313,7 @@ mozilla::ipc::IPCResult Database::RecvPBackgroundIDBTransactionConstructor(
|
|||
uint64_t transactionId = startOp->StartOnConnectionPool(
|
||||
GetLoggingInfo()->Id(), mMetadata->mDatabaseId,
|
||||
transaction->LoggingSerialNumber(), aObjectStoreNames,
|
||||
aMode != IDBTransaction::READ_ONLY);
|
||||
aMode != IDBTransaction::Mode::ReadOnly);
|
||||
|
||||
transaction->SetActive(transactionId);
|
||||
|
||||
|
@ -13433,14 +13433,14 @@ nsresult Database::StartTransactionOp::DoDatabaseWork(
|
|||
|
||||
Transaction()->SetActiveOnConnectionThread();
|
||||
|
||||
if (Transaction()->GetMode() == IDBTransaction::CLEANUP) {
|
||||
if (Transaction()->GetMode() == IDBTransaction::Mode::Cleanup) {
|
||||
nsresult rv = aConnection->DisableQuotaChecks();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (Transaction()->GetMode() != IDBTransaction::READ_ONLY) {
|
||||
if (Transaction()->GetMode() != IDBTransaction::Mode::ReadOnly) {
|
||||
nsresult rv = aConnection->BeginWriteTransaction();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
@ -13723,10 +13723,10 @@ bool TransactionBase::VerifyRequestParams(const RequestParams& aParams) const {
|
|||
}
|
||||
|
||||
case RequestParams::TObjectStoreDeleteParams: {
|
||||
if (NS_WARN_IF(mMode != IDBTransaction::READ_WRITE &&
|
||||
mMode != IDBTransaction::READ_WRITE_FLUSH &&
|
||||
mMode != IDBTransaction::CLEANUP &&
|
||||
mMode != IDBTransaction::VERSION_CHANGE)) {
|
||||
if (NS_WARN_IF(mMode != IDBTransaction::Mode::ReadWrite &&
|
||||
mMode != IDBTransaction::Mode::ReadWriteFlush &&
|
||||
mMode != IDBTransaction::Mode::Cleanup &&
|
||||
mMode != IDBTransaction::Mode::VersionChange)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
|
@ -13747,10 +13747,10 @@ bool TransactionBase::VerifyRequestParams(const RequestParams& aParams) const {
|
|||
}
|
||||
|
||||
case RequestParams::TObjectStoreClearParams: {
|
||||
if (NS_WARN_IF(mMode != IDBTransaction::READ_WRITE &&
|
||||
mMode != IDBTransaction::READ_WRITE_FLUSH &&
|
||||
mMode != IDBTransaction::CLEANUP &&
|
||||
mMode != IDBTransaction::VERSION_CHANGE)) {
|
||||
if (NS_WARN_IF(mMode != IDBTransaction::Mode::ReadWrite &&
|
||||
mMode != IDBTransaction::Mode::ReadWriteFlush &&
|
||||
mMode != IDBTransaction::Mode::Cleanup &&
|
||||
mMode != IDBTransaction::Mode::VersionChange)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
|
@ -13930,9 +13930,9 @@ bool TransactionBase::VerifyRequestParams(
|
|||
const ObjectStoreAddPutParams& aParams) const {
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (NS_WARN_IF(mMode != IDBTransaction::READ_WRITE &&
|
||||
mMode != IDBTransaction::READ_WRITE_FLUSH &&
|
||||
mMode != IDBTransaction::VERSION_CHANGE)) {
|
||||
if (NS_WARN_IF(mMode != IDBTransaction::Mode::ReadWrite &&
|
||||
mMode != IDBTransaction::Mode::ReadWriteFlush &&
|
||||
mMode != IDBTransaction::Mode::VersionChange)) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
|
@ -14434,7 +14434,7 @@ bool NormalTransaction::DeallocPBackgroundIDBCursorParent(
|
|||
VersionChangeTransaction::VersionChangeTransaction(
|
||||
OpenDatabaseOp* aOpenDatabaseOp)
|
||||
: TransactionBase(aOpenDatabaseOp->mDatabase,
|
||||
IDBTransaction::VERSION_CHANGE),
|
||||
IDBTransaction::Mode::VersionChange),
|
||||
mOpenDatabaseOp(aOpenDatabaseOp),
|
||||
mActorWasAlive(false) {
|
||||
AssertIsOnBackgroundThread();
|
||||
|
@ -21030,7 +21030,7 @@ nsresult OpenDatabaseOp::DispatchToWorkThread() {
|
|||
MOZ_ASSERT(mState == State::WaitingForTransactionsToComplete);
|
||||
MOZ_ASSERT(mVersionChangeTransaction);
|
||||
MOZ_ASSERT(mVersionChangeTransaction->GetMode() ==
|
||||
IDBTransaction::VERSION_CHANGE);
|
||||
IDBTransaction::Mode::VersionChange);
|
||||
MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
|
||||
|
||||
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
|
||||
|
@ -22243,10 +22243,10 @@ TransactionBase::CommitOp::CommitOp(TransactionBase* aTransaction,
|
|||
nsresult TransactionBase::CommitOp::WriteAutoIncrementCounts() {
|
||||
MOZ_ASSERT(mTransaction);
|
||||
mTransaction->AssertIsOnConnectionThread();
|
||||
MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::READ_WRITE ||
|
||||
mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH ||
|
||||
mTransaction->GetMode() == IDBTransaction::CLEANUP ||
|
||||
mTransaction->GetMode() == IDBTransaction::VERSION_CHANGE);
|
||||
MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
|
||||
mTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
|
||||
mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
|
||||
mTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
|
||||
|
||||
const nsTArray<RefPtr<FullObjectStoreMetadata>>& metadataArray =
|
||||
mTransaction->mModifiedAutoIncrementObjectStoreMetadataArray;
|
||||
|
@ -22303,10 +22303,10 @@ nsresult TransactionBase::CommitOp::WriteAutoIncrementCounts() {
|
|||
void TransactionBase::CommitOp::CommitOrRollbackAutoIncrementCounts() {
|
||||
MOZ_ASSERT(mTransaction);
|
||||
mTransaction->AssertIsOnConnectionThread();
|
||||
MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::READ_WRITE ||
|
||||
mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH ||
|
||||
mTransaction->GetMode() == IDBTransaction::CLEANUP ||
|
||||
mTransaction->GetMode() == IDBTransaction::VERSION_CHANGE);
|
||||
MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
|
||||
mTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
|
||||
mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
|
||||
mTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
|
||||
|
||||
nsTArray<RefPtr<FullObjectStoreMetadata>>& metadataArray =
|
||||
mTransaction->mModifiedAutoIncrementObjectStoreMetadataArray;
|
||||
|
@ -22331,7 +22331,7 @@ void TransactionBase::CommitOp::AssertForeignKeyConsistency(
|
|||
MOZ_ASSERT(aConnection);
|
||||
MOZ_ASSERT(mTransaction);
|
||||
mTransaction->AssertIsOnConnectionThread();
|
||||
MOZ_ASSERT(mTransaction->GetMode() != IDBTransaction::READ_ONLY);
|
||||
MOZ_ASSERT(mTransaction->GetMode() != IDBTransaction::Mode::ReadOnly);
|
||||
|
||||
DatabaseConnection::CachedStatement pragmaStmt;
|
||||
MOZ_ALWAYS_SUCCEEDS(aConnection->GetCachedStatement(
|
||||
|
@ -22372,7 +22372,7 @@ TransactionBase::CommitOp::Run() {
|
|||
IDB_LOG_ID_STRING(mBackgroundChildLoggingId),
|
||||
mTransaction->LoggingSerialNumber(), mLoggingSerialNumber);
|
||||
|
||||
if (mTransaction->GetMode() != IDBTransaction::READ_ONLY &&
|
||||
if (mTransaction->GetMode() != IDBTransaction::Mode::ReadOnly &&
|
||||
mTransaction->mHasBeenActiveOnConnectionThread) {
|
||||
Database* database = mTransaction->GetDatabase();
|
||||
MOZ_ASSERT(database);
|
||||
|
@ -22401,7 +22401,8 @@ TransactionBase::CommitOp::Run() {
|
|||
NS_WARNING_ASSERTION(NS_SUCCEEDED(mResultCode), "Commit failed!");
|
||||
|
||||
if (NS_SUCCEEDED(mResultCode) &&
|
||||
mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH) {
|
||||
mTransaction->GetMode() ==
|
||||
IDBTransaction::Mode::ReadWriteFlush) {
|
||||
mResultCode = connection->Checkpoint();
|
||||
}
|
||||
|
||||
|
@ -22424,7 +22425,7 @@ TransactionBase::CommitOp::Run() {
|
|||
|
||||
connection->FinishWriteTransaction();
|
||||
|
||||
if (mTransaction->GetMode() == IDBTransaction::CLEANUP) {
|
||||
if (mTransaction->GetMode() == IDBTransaction::Mode::Cleanup) {
|
||||
connection->DoIdleProcessing(/* aNeedsCheckpoint */ true);
|
||||
|
||||
connection->EnableQuotaChecks();
|
||||
|
@ -23981,7 +23982,7 @@ nsresult NormalTransactionOp::ObjectStoreHasIndexes(
|
|||
MOZ_ASSERT(aHasIndexes);
|
||||
|
||||
bool hasIndexes;
|
||||
if (aOp->Transaction()->GetMode() == IDBTransaction::VERSION_CHANGE &&
|
||||
if (aOp->Transaction()->GetMode() == IDBTransaction::Mode::VersionChange &&
|
||||
aMayHaveIndexes) {
|
||||
// If this is a version change transaction then mObjectStoreMayHaveIndexes
|
||||
// could be wrong (e.g. if a unique index failed to be created due to a
|
||||
|
|
|
@ -628,9 +628,9 @@ already_AddRefed<IDBRequest> IDBCursor::Update(JSContext* aCx,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (mTransaction->GetMode() == IDBTransaction::CLEANUP || IsSourceDeleted() ||
|
||||
!mHaveValue || mType == Type_ObjectStoreKey || mType == Type_IndexKey ||
|
||||
mContinueCalled) {
|
||||
if (mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
|
||||
IsSourceDeleted() || !mHaveValue || mType == Type_ObjectStoreKey ||
|
||||
mType == Type_IndexKey || mContinueCalled) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ already_AddRefed<IDBObjectStore> IDBDatabase::CreateObjectStore(
|
|||
|
||||
IDBTransaction* transaction = IDBTransaction::GetCurrent();
|
||||
if (!transaction || transaction->Database() != this ||
|
||||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
|
||||
transaction->GetMode() != IDBTransaction::Mode::VersionChange) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ void IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv) {
|
|||
|
||||
IDBTransaction* transaction = IDBTransaction::GetCurrent();
|
||||
if (!transaction || transaction->Database() != this ||
|
||||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
|
||||
transaction->GetMode() != IDBTransaction::Mode::VersionChange) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -580,21 +580,21 @@ nsresult IDBDatabase::Transaction(JSContext* aCx,
|
|||
IDBTransaction::Mode mode;
|
||||
switch (aMode) {
|
||||
case IDBTransactionMode::Readonly:
|
||||
mode = IDBTransaction::READ_ONLY;
|
||||
mode = IDBTransaction::Mode::ReadOnly;
|
||||
break;
|
||||
case IDBTransactionMode::Readwrite:
|
||||
if (mQuotaExceeded) {
|
||||
mode = IDBTransaction::CLEANUP;
|
||||
mode = IDBTransaction::Mode::Cleanup;
|
||||
mQuotaExceeded = false;
|
||||
} else {
|
||||
mode = IDBTransaction::READ_WRITE;
|
||||
mode = IDBTransaction::Mode::ReadWrite;
|
||||
}
|
||||
break;
|
||||
case IDBTransactionMode::Readwriteflush:
|
||||
mode = IDBTransaction::READ_WRITE_FLUSH;
|
||||
mode = IDBTransaction::Mode::ReadWriteFlush;
|
||||
break;
|
||||
case IDBTransactionMode::Cleanup:
|
||||
mode = IDBTransaction::CLEANUP;
|
||||
mode = IDBTransaction::Mode::Cleanup;
|
||||
mQuotaExceeded = false;
|
||||
break;
|
||||
case IDBTransactionMode::Versionchange:
|
||||
|
@ -626,7 +626,7 @@ nsresult IDBDatabase::Transaction(JSContext* aCx,
|
|||
|
||||
transaction->SetBackgroundActor(actor);
|
||||
|
||||
if (mode == IDBTransaction::CLEANUP) {
|
||||
if (mode == IDBTransaction::Mode::Cleanup) {
|
||||
ExpireFileActors(/* aExpireAll */ true);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ void IDBIndex::SetName(const nsAString& aName, ErrorResult& aRv) {
|
|||
|
||||
IDBTransaction* const transaction = mObjectStore->Transaction();
|
||||
|
||||
if (transaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
|
||||
if (transaction->GetMode() != IDBTransaction::Mode::VersionChange ||
|
||||
mDeletedMetadata) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
|
|
|
@ -1494,7 +1494,8 @@ already_AddRefed<IDBRequest> IDBObjectStore::AddOrPut(
|
|||
MOZ_ASSERT(aCx);
|
||||
MOZ_ASSERT_IF(aFromCursor, aOverwrite);
|
||||
|
||||
if (mTransaction->GetMode() == IDBTransaction::CLEANUP || mDeletedSpec) {
|
||||
if (mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
|
||||
mDeletedSpec) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2047,7 +2048,7 @@ already_AddRefed<IDBIndex> IDBObjectStore::CreateIndex(
|
|||
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
|
||||
if (mTransaction->GetMode() != IDBTransaction::Mode::VersionChange ||
|
||||
mDeletedSpec) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return nullptr;
|
||||
|
@ -2147,7 +2148,7 @@ already_AddRefed<IDBIndex> IDBObjectStore::CreateIndex(
|
|||
void IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
|
||||
if (mTransaction->GetMode() != IDBTransaction::Mode::VersionChange ||
|
||||
mDeletedSpec) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return;
|
||||
|
@ -2423,7 +2424,7 @@ const nsString& IDBObjectStore::Name() const {
|
|||
void IDBObjectStore::SetName(const nsAString& aName, ErrorResult& aRv) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
|
||||
if (mTransaction->GetMode() != IDBTransaction::Mode::VersionChange ||
|
||||
mDeletedSpec) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
|
|
|
@ -74,7 +74,7 @@ using namespace mozilla::dom::indexedDB;
|
|||
using namespace mozilla::ipc;
|
||||
|
||||
bool IDBTransaction::HasTransactionChild() const {
|
||||
return (mMode == VERSION_CHANGE
|
||||
return (mMode == Mode::VersionChange
|
||||
? static_cast<void*>(
|
||||
mBackgroundActor.mVersionChangeBackgroundActor)
|
||||
: mBackgroundActor.mNormalBackgroundActor) != nullptr;
|
||||
|
@ -83,7 +83,7 @@ bool IDBTransaction::HasTransactionChild() const {
|
|||
template <typename Func>
|
||||
auto IDBTransaction::DoWithTransactionChild(const Func& aFunc) const {
|
||||
MOZ_ASSERT(HasTransactionChild());
|
||||
return mMode == VERSION_CHANGE
|
||||
return mMode == Mode::VersionChange
|
||||
? aFunc(*mBackgroundActor.mVersionChangeBackgroundActor)
|
||||
: aFunc(*mBackgroundActor.mNormalBackgroundActor);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ IDBTransaction::IDBTransaction(IDBDatabase* const aDatabase,
|
|||
mFilename(std::move(aFilename)),
|
||||
mLineNo(aLineNo),
|
||||
mColumn(aColumn),
|
||||
mReadyState(IDBTransaction::INITIAL),
|
||||
mReadyState(IDBTransaction::ReadyState::Initial),
|
||||
mMode(aMode),
|
||||
mCreating(false),
|
||||
mRegistered(false),
|
||||
|
@ -119,7 +119,7 @@ IDBTransaction::IDBTransaction(IDBDatabase* const aDatabase,
|
|||
aDatabase->AssertIsOnOwningThread();
|
||||
|
||||
// This also nulls mBackgroundActor.mVersionChangeBackgroundActor, so this is
|
||||
// valid also for mMode == VERSION_CHANGE.
|
||||
// valid also for mMode == Mode::VersionChange.
|
||||
mBackgroundActor.mNormalBackgroundActor = nullptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -154,7 +154,7 @@ IDBTransaction::~IDBTransaction() {
|
|||
}
|
||||
|
||||
if (HasTransactionChild()) {
|
||||
if (mMode == VERSION_CHANGE) {
|
||||
if (mMode == Mode::VersionChange) {
|
||||
mBackgroundActor.mVersionChangeBackgroundActor->SendDeleteMeInternal(
|
||||
/* aFailedConstructor */ false);
|
||||
} else {
|
||||
|
@ -187,7 +187,7 @@ already_AddRefed<IDBTransaction> IDBTransaction::CreateVersionChange(
|
|||
uint32_t lineNo, column;
|
||||
aOpenRequest->GetCallerLocation(filename, &lineNo, &column);
|
||||
RefPtr<IDBTransaction> transaction =
|
||||
new IDBTransaction(aDatabase, emptyObjectStoreNames, VERSION_CHANGE,
|
||||
new IDBTransaction(aDatabase, emptyObjectStoreNames, Mode::VersionChange,
|
||||
std::move(filename), lineNo, column);
|
||||
|
||||
transaction->NoteActiveTransaction();
|
||||
|
@ -209,8 +209,8 @@ already_AddRefed<IDBTransaction> IDBTransaction::Create(
|
|||
MOZ_ASSERT(aDatabase);
|
||||
aDatabase->AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(!aObjectStoreNames.IsEmpty());
|
||||
MOZ_ASSERT(aMode == READ_ONLY || aMode == READ_WRITE ||
|
||||
aMode == READ_WRITE_FLUSH || aMode == CLEANUP);
|
||||
MOZ_ASSERT(aMode == Mode::ReadOnly || aMode == Mode::ReadWrite ||
|
||||
aMode == Mode::ReadWriteFlush || aMode == Mode::Cleanup);
|
||||
|
||||
nsString filename;
|
||||
uint32_t lineNo, column;
|
||||
|
@ -279,7 +279,7 @@ void IDBTransaction::SetBackgroundActor(
|
|||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aBackgroundActor);
|
||||
MOZ_ASSERT(!mBackgroundActor.mNormalBackgroundActor);
|
||||
MOZ_ASSERT(mMode != VERSION_CHANGE);
|
||||
MOZ_ASSERT(mMode != Mode::VersionChange);
|
||||
|
||||
NoteActiveTransaction();
|
||||
|
||||
|
@ -340,8 +340,8 @@ void IDBTransaction::OnNewRequest() {
|
|||
AssertIsOnOwningThread();
|
||||
|
||||
if (!mPendingRequestCount) {
|
||||
MOZ_ASSERT(INITIAL == mReadyState);
|
||||
mReadyState = LOADING;
|
||||
MOZ_ASSERT(ReadyState::Initial == mReadyState);
|
||||
mReadyState = ReadyState::Loading;
|
||||
}
|
||||
|
||||
++mPendingRequestCount;
|
||||
|
@ -355,7 +355,7 @@ void IDBTransaction::OnRequestFinished(
|
|||
--mPendingRequestCount;
|
||||
|
||||
if (!mPendingRequestCount) {
|
||||
mReadyState = COMMITTING;
|
||||
mReadyState = ReadyState::Committing;
|
||||
|
||||
if (aRequestCompletedSuccessfully) {
|
||||
if (NS_SUCCEEDED(mAbortCode)) {
|
||||
|
@ -442,7 +442,7 @@ bool IDBTransaction::IsOpen() const {
|
|||
AssertIsOnOwningThread();
|
||||
|
||||
// If we haven't started anything then we're open.
|
||||
if (mReadyState == IDBTransaction::INITIAL) {
|
||||
if (mReadyState == IDBTransaction::ReadyState::Initial) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ bool IDBTransaction::IsOpen() const {
|
|||
// from the time we were created) then we are open. Otherwise check the
|
||||
// currently running transaction to see if it's the same. We only allow other
|
||||
// requests to be made if this transaction is currently running.
|
||||
if (mReadyState == IDBTransaction::LOADING &&
|
||||
if (mReadyState == IDBTransaction::ReadyState::Loading &&
|
||||
(mCreating || GetCurrent() == this)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ already_AddRefed<IDBObjectStore> IDBTransaction::CreateObjectStore(
|
|||
const ObjectStoreSpec& aSpec) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aSpec.metadata().id());
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
|
||||
MOZ_ASSERT(IsOpen());
|
||||
|
||||
|
@ -509,7 +509,7 @@ already_AddRefed<IDBObjectStore> IDBTransaction::CreateObjectStore(
|
|||
void IDBTransaction::DeleteObjectStore(const int64_t aObjectStoreId) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aObjectStoreId);
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
|
||||
MOZ_ASSERT(IsOpen());
|
||||
|
||||
|
@ -538,7 +538,7 @@ void IDBTransaction::RenameObjectStore(const int64_t aObjectStoreId,
|
|||
const nsAString& aName) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aObjectStoreId);
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
|
||||
MOZ_ASSERT(IsOpen());
|
||||
|
||||
|
@ -552,7 +552,7 @@ void IDBTransaction::CreateIndex(IDBObjectStore* const aObjectStore,
|
|||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aObjectStore);
|
||||
MOZ_ASSERT(aMetadata.id());
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
|
||||
MOZ_ASSERT(IsOpen());
|
||||
|
||||
|
@ -566,7 +566,7 @@ void IDBTransaction::DeleteIndex(IDBObjectStore* const aObjectStore,
|
|||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aObjectStore);
|
||||
MOZ_ASSERT(aIndexId);
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
|
||||
MOZ_ASSERT(IsOpen());
|
||||
|
||||
|
@ -581,7 +581,7 @@ void IDBTransaction::RenameIndex(IDBObjectStore* const aObjectStore,
|
|||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aObjectStore);
|
||||
MOZ_ASSERT(aIndexId);
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
|
||||
MOZ_ASSERT(IsOpen());
|
||||
|
||||
|
@ -598,11 +598,11 @@ void IDBTransaction::AbortInternal(const nsresult aAbortCode,
|
|||
|
||||
RefPtr<DOMException> error = aError;
|
||||
|
||||
const bool isVersionChange = mMode == VERSION_CHANGE;
|
||||
const bool needToSendAbort = mReadyState == INITIAL;
|
||||
const bool isVersionChange = mMode == Mode::VersionChange;
|
||||
const bool needToSendAbort = mReadyState == ReadyState::Initial;
|
||||
|
||||
mAbortCode = aAbortCode;
|
||||
mReadyState = DONE;
|
||||
mReadyState = ReadyState::Done;
|
||||
mError = error.forget();
|
||||
|
||||
if (isVersionChange) {
|
||||
|
@ -723,7 +723,7 @@ void IDBTransaction::FireCompleteOrAbortEvents(const nsresult aResult) {
|
|||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(!mFiredCompleteOrAbort);
|
||||
|
||||
mReadyState = DONE;
|
||||
mReadyState = ReadyState::Done;
|
||||
|
||||
#ifdef DEBUG
|
||||
mFiredCompleteOrAbort = true;
|
||||
|
@ -788,14 +788,14 @@ void IDBTransaction::FireCompleteOrAbortEvents(const nsresult aResult) {
|
|||
|
||||
int64_t IDBTransaction::NextObjectStoreId() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
|
||||
return mNextObjectStoreId++;
|
||||
}
|
||||
|
||||
int64_t IDBTransaction::NextIndexId() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(VERSION_CHANGE == mMode);
|
||||
MOZ_ASSERT(Mode::VersionChange == mMode);
|
||||
|
||||
return mNextIndexId++;
|
||||
}
|
||||
|
@ -831,22 +831,22 @@ IDBTransactionMode IDBTransaction::GetMode(ErrorResult& aRv) const {
|
|||
AssertIsOnOwningThread();
|
||||
|
||||
switch (mMode) {
|
||||
case READ_ONLY:
|
||||
case Mode::ReadOnly:
|
||||
return IDBTransactionMode::Readonly;
|
||||
|
||||
case READ_WRITE:
|
||||
case Mode::ReadWrite:
|
||||
return IDBTransactionMode::Readwrite;
|
||||
|
||||
case READ_WRITE_FLUSH:
|
||||
case Mode::ReadWriteFlush:
|
||||
return IDBTransactionMode::Readwriteflush;
|
||||
|
||||
case CLEANUP:
|
||||
case Mode::Cleanup:
|
||||
return IDBTransactionMode::Cleanup;
|
||||
|
||||
case VERSION_CHANGE:
|
||||
case Mode::VersionChange:
|
||||
return IDBTransactionMode::Versionchange;
|
||||
|
||||
case MODE_INVALID:
|
||||
case Mode::Invalid:
|
||||
default:
|
||||
MOZ_CRASH("Bad mode!");
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ DOMException* IDBTransaction::GetError() const {
|
|||
already_AddRefed<DOMStringList> IDBTransaction::ObjectStoreNames() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
if (mMode == VERSION_CHANGE) {
|
||||
if (mMode == Mode::VersionChange) {
|
||||
return mDatabase->ObjectStoreNames();
|
||||
}
|
||||
|
||||
|
@ -883,7 +883,7 @@ already_AddRefed<IDBObjectStore> IDBTransaction::ObjectStore(
|
|||
|
||||
const ObjectStoreSpec* spec = nullptr;
|
||||
|
||||
if (IDBTransaction::VERSION_CHANGE == mMode ||
|
||||
if (IDBTransaction::Mode::VersionChange == mMode ||
|
||||
mObjectStoreNames.Contains(aName)) {
|
||||
const nsTArray<ObjectStoreSpec>& objectStores =
|
||||
mDatabase->Spec()->objectStores();
|
||||
|
@ -969,8 +969,8 @@ IDBTransaction::Run() {
|
|||
mCreating = false;
|
||||
|
||||
// Maybe commit if there were no requests generated.
|
||||
if (mReadyState == IDBTransaction::INITIAL) {
|
||||
mReadyState = DONE;
|
||||
if (mReadyState == IDBTransaction::ReadyState::Initial) {
|
||||
mReadyState = ReadyState::Done;
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
|
|
@ -48,18 +48,18 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
friend class indexedDB::BackgroundRequestChild;
|
||||
|
||||
public:
|
||||
enum Mode {
|
||||
READ_ONLY = 0,
|
||||
READ_WRITE,
|
||||
READ_WRITE_FLUSH,
|
||||
CLEANUP,
|
||||
VERSION_CHANGE,
|
||||
enum struct Mode {
|
||||
ReadOnly = 0,
|
||||
ReadWrite,
|
||||
ReadWriteFlush,
|
||||
Cleanup,
|
||||
VersionChange,
|
||||
|
||||
// Only needed for IPC serialization helper, should never be used in code.
|
||||
MODE_INVALID
|
||||
Invalid
|
||||
};
|
||||
|
||||
enum ReadyState { INITIAL = 0, LOADING, INACTIVE, COMMITTING, DONE };
|
||||
enum struct ReadyState { Initial = 0, Loading, Inactive, Committing, Done };
|
||||
|
||||
private:
|
||||
// TODO: Only non-const because of Bug 1575173.
|
||||
|
@ -71,8 +71,8 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
RefPtr<StrongWorkerRef> mWorkerRef;
|
||||
nsTArray<IDBCursor*> mCursors;
|
||||
|
||||
// Tagged with mMode. If mMode is VERSION_CHANGE then mBackgroundActor will be
|
||||
// a BackgroundVersionChangeTransactionChild. Otherwise it will be a
|
||||
// Tagged with mMode. If mMode is Mode::VersionChange then mBackgroundActor
|
||||
// will be a BackgroundVersionChangeTransactionChild. Otherwise it will be a
|
||||
// BackgroundTransactionChild.
|
||||
union {
|
||||
indexedDB::BackgroundTransactionChild* mNormalBackgroundActor;
|
||||
|
@ -82,7 +82,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
|
||||
const int64_t mLoggingSerialNumber;
|
||||
|
||||
// Only used for VERSION_CHANGE transactions.
|
||||
// Only used for Mode::VersionChange transactions.
|
||||
int64_t mNextObjectStoreId;
|
||||
int64_t mNextIndexId;
|
||||
|
||||
|
@ -144,7 +144,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
void ClearBackgroundActor() {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
if (mMode == VERSION_CHANGE) {
|
||||
if (mMode == Mode::VersionChange) {
|
||||
mBackgroundActor.mVersionChangeBackgroundActor = nullptr;
|
||||
} else {
|
||||
mBackgroundActor.mNormalBackgroundActor = nullptr;
|
||||
|
@ -168,19 +168,20 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
bool IsCommittingOrDone() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
return mReadyState == COMMITTING || mReadyState == DONE;
|
||||
return mReadyState == ReadyState::Committing ||
|
||||
mReadyState == ReadyState::Done;
|
||||
}
|
||||
|
||||
bool IsDone() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
return mReadyState == DONE;
|
||||
return mReadyState == ReadyState::Done;
|
||||
}
|
||||
|
||||
bool IsWriteAllowed() const {
|
||||
AssertIsOnOwningThread();
|
||||
return mMode == READ_WRITE || mMode == READ_WRITE_FLUSH ||
|
||||
mMode == CLEANUP || mMode == VERSION_CHANGE;
|
||||
return mMode == Mode::ReadWrite || mMode == Mode::ReadWriteFlush ||
|
||||
mMode == Mode::Cleanup || mMode == Mode::VersionChange;
|
||||
}
|
||||
|
||||
bool IsAborted() const {
|
||||
|
@ -190,9 +191,10 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
|
||||
auto TemporarilyProceedToInactive() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mReadyState == INITIAL || mReadyState == LOADING);
|
||||
MOZ_ASSERT(mReadyState == ReadyState::Initial ||
|
||||
mReadyState == ReadyState::Loading);
|
||||
const auto savedReadyState = mReadyState;
|
||||
mReadyState = INACTIVE;
|
||||
mReadyState = ReadyState::Inactive;
|
||||
|
||||
struct AutoRestoreState {
|
||||
IDBTransaction& mOwner;
|
||||
|
@ -203,7 +205,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
|
||||
~AutoRestoreState() {
|
||||
mOwner.AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mOwner.mReadyState == INACTIVE);
|
||||
MOZ_ASSERT(mOwner.mReadyState == ReadyState::Inactive);
|
||||
MOZ_ASSERT(mOwner.mPendingRequestCount == mSavedPendingRequestCount);
|
||||
|
||||
mOwner.mReadyState = mSavedReadyState;
|
||||
|
@ -272,10 +274,10 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
|
||||
void FireCompleteOrAbortEvents(nsresult aResult);
|
||||
|
||||
// Only for VERSION_CHANGE transactions.
|
||||
// Only for Mode::VersionChange transactions.
|
||||
int64_t NextObjectStoreId();
|
||||
|
||||
// Only for VERSION_CHANGE transactions.
|
||||
// Only for Mode::VersionChange transactions.
|
||||
int64_t NextIndexId();
|
||||
|
||||
void InvalidateCursorCaches();
|
||||
|
|
|
@ -110,19 +110,19 @@ class MOZ_STACK_CLASS LoggingString final : public nsAutoCString {
|
|||
Append(kCommaSpace);
|
||||
|
||||
switch (aTransaction->GetMode()) {
|
||||
case IDBTransaction::READ_ONLY:
|
||||
case IDBTransaction::Mode::ReadOnly:
|
||||
AppendLiteral("\"readonly\"");
|
||||
break;
|
||||
case IDBTransaction::READ_WRITE:
|
||||
case IDBTransaction::Mode::ReadWrite:
|
||||
AppendLiteral("\"readwrite\"");
|
||||
break;
|
||||
case IDBTransaction::READ_WRITE_FLUSH:
|
||||
case IDBTransaction::Mode::ReadWriteFlush:
|
||||
AppendLiteral("\"readwriteflush\"");
|
||||
break;
|
||||
case IDBTransaction::CLEANUP:
|
||||
case IDBTransaction::Mode::Cleanup:
|
||||
AppendLiteral("\"cleanup\"");
|
||||
break;
|
||||
case IDBTransaction::VERSION_CHANGE:
|
||||
case IDBTransaction::Mode::VersionChange:
|
||||
AppendLiteral("\"versionchange\"");
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -78,8 +78,8 @@ template <>
|
|||
struct ParamTraits<mozilla::dom::IDBTransaction::Mode>
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::IDBTransaction::Mode,
|
||||
mozilla::dom::IDBTransaction::READ_ONLY,
|
||||
mozilla::dom::IDBTransaction::MODE_INVALID> {};
|
||||
mozilla::dom::IDBTransaction::Mode::ReadOnly,
|
||||
mozilla::dom::IDBTransaction::Mode::Invalid> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче