Issue #1693 - Use scoped enums for IDBTransaction.

Based on a patch from Mozilla bug 1598164.
Needed due to identifier collision between NSS and IDBTransaction.

Co-authored by: Simon Giesecke <simon.giesecke@gmail.com>
Co-authored by: Matt A. Tobin <email@mattatobin.com>
This commit is contained in:
Job Bautista 2023-03-03 20:07:55 +08:00 • committed by roytam1
commit c920f32df3
25 changed files with 175 additions and 182 deletions

View file

@ -110,7 +110,7 @@ public:
MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() > MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
INT64_MIN); INT64_MIN);
if (aMode == IDBTransaction::VERSION_CHANGE) { if (aMode == IDBTransaction::Mode::VersionChange) {
return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--; return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
} }

View file

@ -9005,7 +9005,7 @@ public:
MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() > MOZ_ASSERT(mLoggingInfo.nextVersionChangeTransactionSerialNumber() >
INT64_MIN); INT64_MIN);
if (aMode == IDBTransaction::VERSION_CHANGE) { if (aMode == IDBTransaction::Mode::VersionChange) {
return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--; return mLoggingInfo.nextVersionChangeTransactionSerialNumber()--;
} }
@ -11330,11 +11330,11 @@ AutoSavepoint::~AutoSavepoint()
if (mConnection) { if (mConnection) {
mConnection->AssertIsOnConnectionThread(); mConnection->AssertIsOnConnectionThread();
MOZ_ASSERT(mDEBUGTransaction); MOZ_ASSERT(mDEBUGTransaction);
MOZ_ASSERT(mDEBUGTransaction->GetMode() == IDBTransaction::READ_WRITE || MOZ_ASSERT(mDEBUGTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
mDEBUGTransaction->GetMode() == mDEBUGTransaction->GetMode() ==
IDBTransaction::READ_WRITE_FLUSH || IDBTransaction::Mode::ReadWriteFlush ||
mDEBUGTransaction->GetMode() == IDBTransaction::CLEANUP || mDEBUGTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
mDEBUGTransaction->GetMode() == IDBTransaction::VERSION_CHANGE); mDEBUGTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
if (NS_FAILED(mConnection->RollbackSavepoint())) { if (NS_FAILED(mConnection->RollbackSavepoint())) {
NS_WARNING("Failed to rollback savepoint!"); NS_WARNING("Failed to rollback savepoint!");
@ -11347,10 +11347,10 @@ DatabaseConnection::
AutoSavepoint::Start(const TransactionBase* aTransaction) AutoSavepoint::Start(const TransactionBase* aTransaction)
{ {
MOZ_ASSERT(aTransaction); MOZ_ASSERT(aTransaction);
MOZ_ASSERT(aTransaction->GetMode() == IDBTransaction::READ_WRITE || MOZ_ASSERT(aTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
aTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH || aTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
aTransaction->GetMode() == IDBTransaction::CLEANUP || aTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
aTransaction->GetMode() == IDBTransaction::VERSION_CHANGE); aTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
DatabaseConnection* connection = aTransaction->GetDatabase()->GetConnection(); DatabaseConnection* connection = aTransaction->GetDatabase()->GetConnection();
MOZ_ASSERT(connection); MOZ_ASSERT(connection);
@ -14478,19 +14478,19 @@ Database::AllocPBackgroundIDBTransactionParent(
return nullptr; return nullptr;
} }
if (NS_WARN_IF(aMode != IDBTransaction::READ_ONLY && if (NS_WARN_IF(aMode != IDBTransaction::Mode::ReadOnly &&
aMode != IDBTransaction::READ_WRITE && aMode != IDBTransaction::Mode::ReadWrite &&
aMode != IDBTransaction::READ_WRITE_FLUSH && aMode != IDBTransaction::Mode::ReadWriteFlush &&
aMode != IDBTransaction::CLEANUP)) { aMode != IDBTransaction::Mode::Cleanup)) {
ASSERT_UNLESS_FUZZING(); ASSERT_UNLESS_FUZZING();
return nullptr; return nullptr;
} }
// If this is a readwrite transaction to a chrome database make sure the child // If this is a readwrite transaction to a chrome database make sure the child
// has write access. // has write access.
if (NS_WARN_IF((aMode == IDBTransaction::READ_WRITE || if (NS_WARN_IF((aMode == IDBTransaction::Mode::ReadWrite ||
aMode == IDBTransaction::READ_WRITE_FLUSH || aMode == IDBTransaction::Mode::ReadWriteFlush ||
aMode == IDBTransaction::CLEANUP) && aMode == IDBTransaction::Mode::Cleanup) &&
mPrincipalInfo.type() == PrincipalInfo::TSystemPrincipalInfo && mPrincipalInfo.type() == PrincipalInfo::TSystemPrincipalInfo &&
!mChromeWriteAccessAllowed)) { !mChromeWriteAccessAllowed)) {
return nullptr; return nullptr;
@ -14553,10 +14553,10 @@ Database::RecvPBackgroundIDBTransactionConstructor(
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor); MOZ_ASSERT(aActor);
MOZ_ASSERT(!aObjectStoreNames.IsEmpty()); MOZ_ASSERT(!aObjectStoreNames.IsEmpty());
MOZ_ASSERT(aMode == IDBTransaction::READ_ONLY || MOZ_ASSERT(aMode == IDBTransaction::Mode::ReadOnly ||
aMode == IDBTransaction::READ_WRITE || aMode == IDBTransaction::Mode::ReadWrite ||
aMode == IDBTransaction::READ_WRITE_FLUSH || aMode == IDBTransaction::Mode::ReadWriteFlush ||
aMode == IDBTransaction::CLEANUP); aMode == IDBTransaction::Mode::Cleanup);
MOZ_ASSERT(!mClosed); MOZ_ASSERT(!mClosed);
if (IsInvalidated()) { if (IsInvalidated()) {
@ -14578,7 +14578,7 @@ Database::RecvPBackgroundIDBTransactionConstructor(
mMetadata->mDatabaseId, mMetadata->mDatabaseId,
transaction->LoggingSerialNumber(), transaction->LoggingSerialNumber(),
aObjectStoreNames, aObjectStoreNames,
aMode != IDBTransaction::READ_ONLY); aMode != IDBTransaction::Mode::ReadOnly);
transaction->SetActive(transactionId); transaction->SetActive(transactionId);
@ -14715,14 +14715,14 @@ StartTransactionOp::DoDatabaseWork(DatabaseConnection* aConnection)
Transaction()->SetActiveOnConnectionThread(); Transaction()->SetActiveOnConnectionThread();
if (Transaction()->GetMode() == IDBTransaction::CLEANUP) { if (Transaction()->GetMode() == IDBTransaction::Mode::Cleanup) {
nsresult rv = aConnection->DisableQuotaChecks(); nsresult rv = aConnection->DisableQuotaChecks();
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
} }
if (Transaction()->GetMode() != IDBTransaction::READ_ONLY) { if (Transaction()->GetMode() != IDBTransaction::Mode::ReadOnly) {
nsresult rv = aConnection->BeginWriteTransaction(); nsresult rv = aConnection->BeginWriteTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -15032,10 +15032,10 @@ TransactionBase::VerifyRequestParams(const RequestParams& aParams) const
} }
case RequestParams::TObjectStoreDeleteParams: { case RequestParams::TObjectStoreDeleteParams: {
if (NS_WARN_IF(mMode != IDBTransaction::READ_WRITE && if (NS_WARN_IF(mMode != IDBTransaction::Mode::ReadWrite &&
mMode != IDBTransaction::READ_WRITE_FLUSH && mMode != IDBTransaction::Mode::ReadWriteFlush &&
mMode != IDBTransaction::CLEANUP && mMode != IDBTransaction::Mode::Cleanup &&
mMode != IDBTransaction::VERSION_CHANGE)) { mMode != IDBTransaction::Mode::VersionChange)) {
ASSERT_UNLESS_FUZZING(); ASSERT_UNLESS_FUZZING();
return false; return false;
} }
@ -15056,10 +15056,10 @@ TransactionBase::VerifyRequestParams(const RequestParams& aParams) const
} }
case RequestParams::TObjectStoreClearParams: { case RequestParams::TObjectStoreClearParams: {
if (NS_WARN_IF(mMode != IDBTransaction::READ_WRITE && if (NS_WARN_IF(mMode != IDBTransaction::Mode::ReadWrite &&
mMode != IDBTransaction::READ_WRITE_FLUSH && mMode != IDBTransaction::Mode::ReadWriteFlush &&
mMode != IDBTransaction::CLEANUP && mMode != IDBTransaction::Mode::Cleanup &&
mMode != IDBTransaction::VERSION_CHANGE)) { mMode != IDBTransaction::Mode::VersionChange)) {
ASSERT_UNLESS_FUZZING(); ASSERT_UNLESS_FUZZING();
return false; return false;
} }
@ -15243,9 +15243,9 @@ TransactionBase::VerifyRequestParams(const ObjectStoreAddPutParams& aParams)
{ {
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();
if (NS_WARN_IF(mMode != IDBTransaction::READ_WRITE && if (NS_WARN_IF(mMode != IDBTransaction::Mode::ReadWrite &&
mMode != IDBTransaction::READ_WRITE_FLUSH && mMode != IDBTransaction::Mode::ReadWriteFlush &&
mMode != IDBTransaction::VERSION_CHANGE)) { mMode != IDBTransaction::Mode::VersionChange)) {
ASSERT_UNLESS_FUZZING(); ASSERT_UNLESS_FUZZING();
return false; return false;
} }
@ -15864,7 +15864,7 @@ NormalTransaction::DeallocPBackgroundIDBCursorParent(
VersionChangeTransaction::VersionChangeTransaction( VersionChangeTransaction::VersionChangeTransaction(
OpenDatabaseOp* aOpenDatabaseOp) OpenDatabaseOp* aOpenDatabaseOp)
: TransactionBase(aOpenDatabaseOp->mDatabase, : TransactionBase(aOpenDatabaseOp->mDatabase,
IDBTransaction::VERSION_CHANGE) IDBTransaction::Mode::VersionChange)
, mOpenDatabaseOp(aOpenDatabaseOp) , mOpenDatabaseOp(aOpenDatabaseOp)
, mActorWasAlive(false) , mActorWasAlive(false)
{ {
@ -22234,7 +22234,7 @@ OpenDatabaseOp::DispatchToWorkThread()
MOZ_ASSERT(mState == State::WaitingForTransactionsToComplete); MOZ_ASSERT(mState == State::WaitingForTransactionsToComplete);
MOZ_ASSERT(mVersionChangeTransaction); MOZ_ASSERT(mVersionChangeTransaction);
MOZ_ASSERT(mVersionChangeTransaction->GetMode() == MOZ_ASSERT(mVersionChangeTransaction->GetMode() ==
IDBTransaction::VERSION_CHANGE); IDBTransaction::Mode::VersionChange);
MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty()); MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) || if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread()) ||
@ -23739,10 +23739,10 @@ CommitOp::WriteAutoIncrementCounts()
{ {
MOZ_ASSERT(mTransaction); MOZ_ASSERT(mTransaction);
mTransaction->AssertIsOnConnectionThread(); mTransaction->AssertIsOnConnectionThread();
MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::READ_WRITE || MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH || mTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
mTransaction->GetMode() == IDBTransaction::CLEANUP || mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
mTransaction->GetMode() == IDBTransaction::VERSION_CHANGE); mTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
const nsTArray<RefPtr<FullObjectStoreMetadata>>& metadataArray = const nsTArray<RefPtr<FullObjectStoreMetadata>>& metadataArray =
mTransaction->mModifiedAutoIncrementObjectStoreMetadataArray; mTransaction->mModifiedAutoIncrementObjectStoreMetadataArray;
@ -23807,10 +23807,10 @@ CommitOp::CommitOrRollbackAutoIncrementCounts()
{ {
MOZ_ASSERT(mTransaction); MOZ_ASSERT(mTransaction);
mTransaction->AssertIsOnConnectionThread(); mTransaction->AssertIsOnConnectionThread();
MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::READ_WRITE || MOZ_ASSERT(mTransaction->GetMode() == IDBTransaction::Mode::ReadWrite ||
mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH || mTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush ||
mTransaction->GetMode() == IDBTransaction::CLEANUP || mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
mTransaction->GetMode() == IDBTransaction::VERSION_CHANGE); mTransaction->GetMode() == IDBTransaction::Mode::VersionChange);
nsTArray<RefPtr<FullObjectStoreMetadata>>& metadataArray = nsTArray<RefPtr<FullObjectStoreMetadata>>& metadataArray =
mTransaction->mModifiedAutoIncrementObjectStoreMetadataArray; mTransaction->mModifiedAutoIncrementObjectStoreMetadataArray;
@ -23841,7 +23841,7 @@ CommitOp::AssertForeignKeyConsistency(DatabaseConnection* aConnection)
MOZ_ASSERT(aConnection); MOZ_ASSERT(aConnection);
MOZ_ASSERT(mTransaction); MOZ_ASSERT(mTransaction);
mTransaction->AssertIsOnConnectionThread(); mTransaction->AssertIsOnConnectionThread();
MOZ_ASSERT(mTransaction->GetMode() != IDBTransaction::READ_ONLY); MOZ_ASSERT(mTransaction->GetMode() != IDBTransaction::Mode::ReadOnly);
DatabaseConnection::CachedStatement pragmaStmt; DatabaseConnection::CachedStatement pragmaStmt;
MOZ_ALWAYS_SUCCEEDS( MOZ_ALWAYS_SUCCEEDS(
@ -23891,7 +23891,7 @@ CommitOp::Run()
mTransaction->LoggingSerialNumber(), mTransaction->LoggingSerialNumber(),
mLoggingSerialNumber); mLoggingSerialNumber);
if (mTransaction->GetMode() != IDBTransaction::READ_ONLY && if (mTransaction->GetMode() != IDBTransaction::Mode::ReadOnly &&
mTransaction->mHasBeenActiveOnConnectionThread) { mTransaction->mHasBeenActiveOnConnectionThread) {
Database* database = mTransaction->GetDatabase(); Database* database = mTransaction->GetDatabase();
MOZ_ASSERT(database); MOZ_ASSERT(database);
@ -23920,7 +23920,7 @@ CommitOp::Run()
NS_WARNING_ASSERTION(NS_SUCCEEDED(mResultCode), "Commit failed!"); NS_WARNING_ASSERTION(NS_SUCCEEDED(mResultCode), "Commit failed!");
if (NS_SUCCEEDED(mResultCode) && if (NS_SUCCEEDED(mResultCode) &&
mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH) { mTransaction->GetMode() == IDBTransaction::Mode::ReadWriteFlush) {
mResultCode = connection->Checkpoint(); mResultCode = connection->Checkpoint();
} }
@ -23943,7 +23943,7 @@ CommitOp::Run()
connection->FinishWriteTransaction(); connection->FinishWriteTransaction();
if (mTransaction->GetMode() == IDBTransaction::CLEANUP) { if (mTransaction->GetMode() == IDBTransaction::Mode::Cleanup) {
connection->DoIdleProcessing(/* aNeedsCheckpoint */ true); connection->DoIdleProcessing(/* aNeedsCheckpoint */ true);
connection->EnableQuotaChecks(); connection->EnableQuotaChecks();
@ -25789,7 +25789,7 @@ NormalTransactionOp::ObjectStoreHasIndexes(NormalTransactionOp* aOp,
MOZ_ASSERT(aHasIndexes); MOZ_ASSERT(aHasIndexes);
bool hasIndexes; bool hasIndexes;
if (aOp->Transaction()->GetMode() == IDBTransaction::VERSION_CHANGE && if (aOp->Transaction()->GetMode() == IDBTransaction::Mode::VersionChange &&
aMayHaveIndexes) { aMayHaveIndexes) {
// If this is a version change transaction then mObjectStoreMayHaveIndexes // 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 // could be wrong (e.g. if a unique index failed to be created due to a

View file

@ -685,7 +685,7 @@ IDBCursor::Update(JSContext* aCx, JS::Handle<JS::Value> aValue,
return nullptr; return nullptr;
} }
if (mTransaction->GetMode() == IDBTransaction::CLEANUP || if (mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
IsSourceDeleted() || IsSourceDeleted() ||
!mHaveValue || !mHaveValue ||
mType == Type_ObjectStoreKey || mType == Type_ObjectStoreKey ||

View file

@ -425,7 +425,7 @@ IDBDatabase::CreateObjectStore(
IDBTransaction* transaction = IDBTransaction::GetCurrent(); IDBTransaction* transaction = IDBTransaction::GetCurrent();
if (!transaction || if (!transaction ||
transaction->Database() != this || transaction->Database() != this ||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) { transaction->GetMode() != IDBTransaction::Mode::VersionChange) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr; return nullptr;
} }
@ -503,7 +503,7 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv)
IDBTransaction* transaction = IDBTransaction::GetCurrent(); IDBTransaction* transaction = IDBTransaction::GetCurrent();
if (!transaction || if (!transaction ||
transaction->Database() != this || transaction->Database() != this ||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) { transaction->GetMode() != IDBTransaction::Mode::VersionChange) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return; return;
} }
@ -666,21 +666,21 @@ IDBDatabase::Transaction(JSContext* aCx,
IDBTransaction::Mode mode; IDBTransaction::Mode mode;
switch (aMode) { switch (aMode) {
case IDBTransactionMode::Readonly: case IDBTransactionMode::Readonly:
mode = IDBTransaction::READ_ONLY; mode = IDBTransaction::Mode::ReadOnly;
break; break;
case IDBTransactionMode::Readwrite: case IDBTransactionMode::Readwrite:
if (mQuotaExceeded) { if (mQuotaExceeded) {
mode = IDBTransaction::CLEANUP; mode = IDBTransaction::Mode::Cleanup;
mQuotaExceeded = false; mQuotaExceeded = false;
} else { } else {
mode = IDBTransaction::READ_WRITE; mode = IDBTransaction::Mode::ReadWrite;
} }
break; break;
case IDBTransactionMode::Readwriteflush: case IDBTransactionMode::Readwriteflush:
mode = IDBTransaction::READ_WRITE_FLUSH; mode = IDBTransaction::Mode::ReadWriteFlush;
break; break;
case IDBTransactionMode::Cleanup: case IDBTransactionMode::Cleanup:
mode = IDBTransaction::CLEANUP; mode = IDBTransaction::Mode::Cleanup;
mQuotaExceeded = false; mQuotaExceeded = false;
break; break;
case IDBTransactionMode::Versionchange: case IDBTransactionMode::Versionchange:
@ -715,7 +715,7 @@ IDBDatabase::Transaction(JSContext* aCx,
transaction->SetBackgroundActor(actor); transaction->SetBackgroundActor(actor);
if (mode == IDBTransaction::CLEANUP) { if (mode == IDBTransaction::Mode::Cleanup) {
ExpireFileActors(/* aExpireAll */ true); ExpireFileActors(/* aExpireAll */ true);
} }
@ -859,14 +859,14 @@ IDBDatabase::AbortTransactions(bool aShouldWarn)
if (aShouldWarn) { if (aShouldWarn) {
switch (transaction->GetMode()) { switch (transaction->GetMode()) {
// We ignore transactions that could not have written any data. // We ignore transactions that could not have written any data.
case IDBTransaction::READ_ONLY: case IDBTransaction::Mode::ReadOnly:
break; break;
// We warn for any transactions that could have written data. // We warn for any transactions that could have written data.
case IDBTransaction::READ_WRITE: case IDBTransaction::Mode::ReadWrite:
case IDBTransaction::READ_WRITE_FLUSH: case IDBTransaction::Mode::ReadWriteFlush:
case IDBTransaction::CLEANUP: case IDBTransaction::Mode::Cleanup:
case IDBTransaction::VERSION_CHANGE: case IDBTransaction::Mode::VersionChange:
transactionsThatNeedWarning.AppendElement(transaction); transactionsThatNeedWarning.AppendElement(transaction);
break; break;

View file

@ -158,7 +158,7 @@ IDBIndex::SetName(const nsAString& aName, ErrorResult& aRv)
IDBTransaction* transaction = mObjectStore->Transaction(); IDBTransaction* transaction = mObjectStore->Transaction();
if (transaction->GetMode() != IDBTransaction::VERSION_CHANGE || if (transaction->GetMode() != IDBTransaction::Mode::VersionChange ||
mDeletedMetadata) { mDeletedMetadata) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return; return;

View file

@ -1407,7 +1407,7 @@ IDBObjectStore::AddOrPut(JSContext* aCx,
MOZ_ASSERT(aCx); MOZ_ASSERT(aCx);
MOZ_ASSERT_IF(aFromCursor, aOverwrite); MOZ_ASSERT_IF(aFromCursor, aOverwrite);
if (mTransaction->GetMode() == IDBTransaction::CLEANUP || if (mTransaction->GetMode() == IDBTransaction::Mode::Cleanup ||
mDeletedSpec) { mDeletedSpec) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr; return nullptr;
@ -1991,7 +1991,7 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE || if (mTransaction->GetMode() != IDBTransaction::Mode::VersionChange ||
mDeletedSpec) { mDeletedSpec) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr; return nullptr;
@ -2101,7 +2101,7 @@ IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv)
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE || if (mTransaction->GetMode() != IDBTransaction::Mode::VersionChange ||
mDeletedSpec) { mDeletedSpec) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return; return;
@ -2424,7 +2424,7 @@ IDBObjectStore::SetName(const nsAString& aName, ErrorResult& aRv)
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
if (mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE || if (mTransaction->GetMode() != IDBTransaction::Mode::VersionChange ||
mDeletedSpec) { mDeletedSpec) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return; return;

View file

@ -82,7 +82,7 @@ IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
, mPendingRequestCount(0) , mPendingRequestCount(0)
, mLineNo(0) , mLineNo(0)
, mColumn(0) , mColumn(0)
, mReadyState(IDBTransaction::INITIAL) , mReadyState(IDBTransaction::ReadyState::Initial)
, mMode(aMode) , mMode(aMode)
, mCreating(false) , mCreating(false)
, mRegistered(false) , mRegistered(false)
@ -134,10 +134,10 @@ IDBTransaction::~IDBTransaction()
MOZ_ASSERT(!mPendingRequestCount); MOZ_ASSERT(!mPendingRequestCount);
MOZ_ASSERT(!mCreating); MOZ_ASSERT(!mCreating);
MOZ_ASSERT(mSentCommitOrAbort); MOZ_ASSERT(mSentCommitOrAbort);
MOZ_ASSERT_IF(mMode == VERSION_CHANGE && MOZ_ASSERT_IF(mMode == Mode::VersionChange &&
mBackgroundActor.mVersionChangeBackgroundActor, mBackgroundActor.mVersionChangeBackgroundActor,
mFiredCompleteOrAbort); mFiredCompleteOrAbort);
MOZ_ASSERT_IF(mMode != VERSION_CHANGE && MOZ_ASSERT_IF(mMode != Mode::VersionChange &&
mBackgroundActor.mNormalBackgroundActor, mBackgroundActor.mNormalBackgroundActor,
mFiredCompleteOrAbort); mFiredCompleteOrAbort);
@ -148,7 +148,7 @@ IDBTransaction::~IDBTransaction()
#endif #endif
} }
if (mMode == VERSION_CHANGE) { if (mMode == Mode::VersionChange) {
if (auto* actor = mBackgroundActor.mVersionChangeBackgroundActor) { if (auto* actor = mBackgroundActor.mVersionChangeBackgroundActor) {
actor->SendDeleteMeInternal(/* aFailedConstructor */ false); actor->SendDeleteMeInternal(/* aFailedConstructor */ false);
@ -184,7 +184,7 @@ IDBTransaction::CreateVersionChange(
RefPtr<IDBTransaction> transaction = RefPtr<IDBTransaction> transaction =
new IDBTransaction(aDatabase, new IDBTransaction(aDatabase,
emptyObjectStoreNames, emptyObjectStoreNames,
VERSION_CHANGE); Mode::VersionChange);
aOpenRequest->GetCallerLocation(transaction->mFilename, aOpenRequest->GetCallerLocation(transaction->mFilename,
&transaction->mLineNo, &transaction->mColumn); &transaction->mLineNo, &transaction->mColumn);
@ -213,10 +213,10 @@ IDBTransaction::Create(JSContext* aCx, IDBDatabase* aDatabase,
MOZ_ASSERT(aDatabase); MOZ_ASSERT(aDatabase);
aDatabase->AssertIsOnOwningThread(); aDatabase->AssertIsOnOwningThread();
MOZ_ASSERT(!aObjectStoreNames.IsEmpty()); MOZ_ASSERT(!aObjectStoreNames.IsEmpty());
MOZ_ASSERT(aMode == READ_ONLY || MOZ_ASSERT(aMode == Mode::ReadOnly ||
aMode == READ_WRITE || aMode == Mode::ReadWrite ||
aMode == READ_WRITE_FLUSH || aMode == Mode::ReadWriteFlush ||
aMode == CLEANUP); aMode == Mode::Cleanup);
RefPtr<IDBTransaction> transaction = RefPtr<IDBTransaction> transaction =
new IDBTransaction(aDatabase, aObjectStoreNames, aMode); new IDBTransaction(aDatabase, aObjectStoreNames, aMode);
@ -281,7 +281,7 @@ IDBTransaction::SetBackgroundActor(indexedDB::BackgroundTransactionChild* aBackg
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aBackgroundActor); MOZ_ASSERT(aBackgroundActor);
MOZ_ASSERT(!mBackgroundActor.mNormalBackgroundActor); MOZ_ASSERT(!mBackgroundActor.mNormalBackgroundActor);
MOZ_ASSERT(mMode != VERSION_CHANGE); MOZ_ASSERT(mMode != Mode::VersionChange);
mBackgroundActor.mNormalBackgroundActor = aBackgroundActor; mBackgroundActor.mNormalBackgroundActor = aBackgroundActor;
} }
@ -295,7 +295,7 @@ IDBTransaction::StartRequest(IDBRequest* aRequest, const RequestParams& aParams)
BackgroundRequestChild* actor = new BackgroundRequestChild(aRequest); BackgroundRequestChild* actor = new BackgroundRequestChild(aRequest);
if (mMode == VERSION_CHANGE) { if (mMode == Mode::VersionChange) {
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
mBackgroundActor.mVersionChangeBackgroundActor-> mBackgroundActor.mVersionChangeBackgroundActor->
@ -321,7 +321,7 @@ IDBTransaction::OpenCursor(BackgroundCursorChild* aBackgroundActor,
MOZ_ASSERT(aBackgroundActor); MOZ_ASSERT(aBackgroundActor);
MOZ_ASSERT(aParams.type() != OpenCursorParams::T__None); MOZ_ASSERT(aParams.type() != OpenCursorParams::T__None);
if (mMode == VERSION_CHANGE) { if (mMode == Mode::VersionChange) {
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
mBackgroundActor.mVersionChangeBackgroundActor-> mBackgroundActor.mVersionChangeBackgroundActor->
@ -361,8 +361,8 @@ IDBTransaction::OnNewRequest()
AssertIsOnOwningThread(); AssertIsOnOwningThread();
if (!mPendingRequestCount) { if (!mPendingRequestCount) {
MOZ_ASSERT(INITIAL == mReadyState); MOZ_ASSERT(ReadyState::Initial == mReadyState);
mReadyState = LOADING; mReadyState = ReadyState::Loading;
} }
++mPendingRequestCount; ++mPendingRequestCount;
@ -377,7 +377,7 @@ IDBTransaction::OnRequestFinished(bool aActorDestroyedNormally)
--mPendingRequestCount; --mPendingRequestCount;
if (!mPendingRequestCount) { if (!mPendingRequestCount) {
mReadyState = COMMITTING; mReadyState = ReadyState::Committing;
if (aActorDestroyedNormally) { if (aActorDestroyedNormally) {
if (NS_SUCCEEDED(mAbortCode)) { if (NS_SUCCEEDED(mAbortCode)) {
@ -421,7 +421,7 @@ IDBTransaction::SendCommit()
LoggingSerialNumber(), LoggingSerialNumber(),
requestSerialNumber); requestSerialNumber);
if (mMode == VERSION_CHANGE) { if (mMode == Mode::VersionChange) {
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
mBackgroundActor.mVersionChangeBackgroundActor->SendCommit(); mBackgroundActor.mVersionChangeBackgroundActor->SendCommit();
} else { } else {
@ -454,7 +454,7 @@ IDBTransaction::SendAbort(nsresult aResultCode)
requestSerialNumber, requestSerialNumber,
aResultCode); aResultCode);
if (mMode == VERSION_CHANGE) { if (mMode == Mode::VersionChange) {
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
mBackgroundActor.mVersionChangeBackgroundActor->SendAbort(aResultCode); mBackgroundActor.mVersionChangeBackgroundActor->SendAbort(aResultCode);
} else { } else {
@ -473,7 +473,7 @@ IDBTransaction::IsOpen() const
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// If we haven't started anything then we're open. // If we haven't started anything then we're open.
if (mReadyState == IDBTransaction::INITIAL) { if (mReadyState == IDBTransaction::ReadyState::Initial) {
return true; return true;
} }
@ -482,7 +482,7 @@ IDBTransaction::IsOpen() const
// from the time we were created) then we are open. Otherwise check the // 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 // currently running transaction to see if it's the same. We only allow other
// requests to be made if this transaction is currently running. // requests to be made if this transaction is currently running.
if (mReadyState == IDBTransaction::LOADING && if (mReadyState == IDBTransaction::ReadyState::Loading &&
(mCreating || GetCurrent() == this)) { (mCreating || GetCurrent() == this)) {
return true; return true;
} }
@ -508,7 +508,7 @@ IDBTransaction::CreateObjectStore(const ObjectStoreSpec& aSpec)
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aSpec.metadata().id()); MOZ_ASSERT(aSpec.metadata().id());
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
MOZ_ASSERT(IsOpen()); MOZ_ASSERT(IsOpen());
@ -540,7 +540,7 @@ IDBTransaction::DeleteObjectStore(int64_t aObjectStoreId)
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aObjectStoreId); MOZ_ASSERT(aObjectStoreId);
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
MOZ_ASSERT(IsOpen()); MOZ_ASSERT(IsOpen());
@ -571,7 +571,7 @@ IDBTransaction::RenameObjectStore(int64_t aObjectStoreId,
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aObjectStoreId); MOZ_ASSERT(aObjectStoreId);
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
MOZ_ASSERT(IsOpen()); MOZ_ASSERT(IsOpen());
@ -586,7 +586,7 @@ IDBTransaction::CreateIndex(IDBObjectStore* aObjectStore,
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aObjectStore); MOZ_ASSERT(aObjectStore);
MOZ_ASSERT(aMetadata.id()); MOZ_ASSERT(aMetadata.id());
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
MOZ_ASSERT(IsOpen()); MOZ_ASSERT(IsOpen());
@ -601,7 +601,7 @@ IDBTransaction::DeleteIndex(IDBObjectStore* aObjectStore,
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aObjectStore); MOZ_ASSERT(aObjectStore);
MOZ_ASSERT(aIndexId); MOZ_ASSERT(aIndexId);
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
MOZ_ASSERT(IsOpen()); MOZ_ASSERT(IsOpen());
@ -617,7 +617,7 @@ IDBTransaction::RenameIndex(IDBObjectStore* aObjectStore,
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(aObjectStore); MOZ_ASSERT(aObjectStore);
MOZ_ASSERT(aIndexId); MOZ_ASSERT(aIndexId);
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor); MOZ_ASSERT(mBackgroundActor.mVersionChangeBackgroundActor);
MOZ_ASSERT(IsOpen()); MOZ_ASSERT(IsOpen());
@ -637,12 +637,12 @@ IDBTransaction::AbortInternal(nsresult aAbortCode,
RefPtr<DOMError> error = aError; RefPtr<DOMError> error = aError;
const bool isVersionChange = mMode == VERSION_CHANGE; const bool isVersionChange = mMode == Mode::VersionChange;
const bool isInvalidated = mDatabase->IsInvalidated(); const bool isInvalidated = mDatabase->IsInvalidated();
bool needToSendAbort = mReadyState == INITIAL; bool needToSendAbort = mReadyState == ReadyState::Initial;
mAbortCode = aAbortCode; mAbortCode = aAbortCode;
mReadyState = DONE; mReadyState = ReadyState::Done;
mError = error.forget(); mError = error.forget();
if (isVersionChange) { if (isVersionChange) {
@ -775,7 +775,7 @@ IDBTransaction::FireCompleteOrAbortEvents(nsresult aResult)
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(!mFiredCompleteOrAbort); MOZ_ASSERT(!mFiredCompleteOrAbort);
mReadyState = DONE; mReadyState = ReadyState::Done;
#ifdef DEBUG #ifdef DEBUG
mFiredCompleteOrAbort = true; mFiredCompleteOrAbort = true;
@ -834,7 +834,7 @@ int64_t
IDBTransaction::NextObjectStoreId() IDBTransaction::NextObjectStoreId()
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
return mNextObjectStoreId++; return mNextObjectStoreId++;
} }
@ -843,7 +843,7 @@ int64_t
IDBTransaction::NextIndexId() IDBTransaction::NextIndexId()
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(VERSION_CHANGE == mMode); MOZ_ASSERT(Mode::VersionChange == mMode);
return mNextIndexId++; return mNextIndexId++;
} }
@ -862,22 +862,22 @@ IDBTransaction::GetMode(ErrorResult& aRv) const
AssertIsOnOwningThread(); AssertIsOnOwningThread();
switch (mMode) { switch (mMode) {
case READ_ONLY: case Mode::ReadOnly:
return IDBTransactionMode::Readonly; return IDBTransactionMode::Readonly;
case READ_WRITE: case Mode::ReadWrite:
return IDBTransactionMode::Readwrite; return IDBTransactionMode::Readwrite;
case READ_WRITE_FLUSH: case Mode::ReadWriteFlush:
return IDBTransactionMode::Readwriteflush; return IDBTransactionMode::Readwriteflush;
case CLEANUP: case Mode::Cleanup:
return IDBTransactionMode::Cleanup; return IDBTransactionMode::Cleanup;
case VERSION_CHANGE: case Mode::VersionChange:
return IDBTransactionMode::Versionchange; return IDBTransactionMode::Versionchange;
case MODE_INVALID: case Mode::Invalid:
default: default:
MOZ_CRASH("Bad mode!"); MOZ_CRASH("Bad mode!");
} }
@ -896,7 +896,7 @@ IDBTransaction::ObjectStoreNames() const
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
if (mMode == IDBTransaction::VERSION_CHANGE) { if (mMode == IDBTransaction::Mode::VersionChange) {
return mDatabase->ObjectStoreNames(); return mDatabase->ObjectStoreNames();
} }
@ -917,7 +917,7 @@ IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
const ObjectStoreSpec* spec = nullptr; const ObjectStoreSpec* spec = nullptr;
if (IDBTransaction::VERSION_CHANGE == mMode || if (IDBTransaction::Mode::VersionChange == mMode ||
mObjectStoreNames.Contains(aName)) { mObjectStoreNames.Contains(aName)) {
const nsTArray<ObjectStoreSpec>& objectStores = const nsTArray<ObjectStoreSpec>& objectStores =
mDatabase->Spec()->objectStores(); mDatabase->Spec()->objectStores();
@ -1014,8 +1014,8 @@ IDBTransaction::Run()
mCreating = false; mCreating = false;
// Maybe commit if there were no requests generated. // Maybe commit if there were no requests generated.
if (mReadyState == IDBTransaction::INITIAL) { if (mReadyState == IDBTransaction::ReadyState::Initial) {
mReadyState = DONE; mReadyState = ReadyState::Done;
SendCommit(); SendCommit();
} }

View file

@ -53,25 +53,18 @@ class IDBTransaction final
friend class WorkerHolder; friend class WorkerHolder;
public: public:
enum Mode enum struct Mode {
{ ReadOnly = 0,
READ_ONLY = 0, ReadWrite,
READ_WRITE, ReadWriteFlush,
READ_WRITE_FLUSH, Cleanup,
CLEANUP, VersionChange,
VERSION_CHANGE,
// Only needed for IPC serialization helper, should never be used in code. // Only needed for IPC serialization helper, should never be used in code.
MODE_INVALID Invalid
}; };
enum ReadyState enum struct ReadyState { Initial = 0, Loading, Inactive, Committing, Done };
{
INITIAL = 0,
LOADING,
COMMITTING,
DONE
};
private: private:
RefPtr<IDBDatabase> mDatabase; RefPtr<IDBDatabase> mDatabase;
@ -81,7 +74,7 @@ private:
nsTArray<RefPtr<IDBObjectStore>> mDeletedObjectStores; nsTArray<RefPtr<IDBObjectStore>> mDeletedObjectStores;
nsAutoPtr<WorkerHolder> mWorkerHolder; nsAutoPtr<WorkerHolder> mWorkerHolder;
// Tagged with mMode. If mMode is VERSION_CHANGE then mBackgroundActor will be // Tagged with mMode. If mMode is Mode::VersionChange then mBackgroundActor will be
// a BackgroundVersionChangeTransactionChild. Otherwise it will be a // a BackgroundVersionChangeTransactionChild. Otherwise it will be a
// BackgroundTransactionChild. // BackgroundTransactionChild.
union { union {
@ -91,7 +84,7 @@ private:
const int64_t mLoggingSerialNumber; const int64_t mLoggingSerialNumber;
// Only used for VERSION_CHANGE transactions. // Only used for Mode::VersionChange transactions.
int64_t mNextObjectStoreId; int64_t mNextObjectStoreId;
int64_t mNextIndexId; int64_t mNextIndexId;
@ -146,7 +139,7 @@ public:
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
if (mMode == VERSION_CHANGE) { if (mMode == Mode::VersionChange) {
mBackgroundActor.mVersionChangeBackgroundActor = nullptr; mBackgroundActor.mVersionChangeBackgroundActor = nullptr;
} else { } else {
mBackgroundActor.mNormalBackgroundActor = nullptr; mBackgroundActor.mNormalBackgroundActor = nullptr;
@ -171,7 +164,7 @@ public:
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
return mReadyState == COMMITTING || mReadyState == DONE; return mReadyState == ReadyState::Committing || mReadyState == ReadyState::Done;
} }
bool bool
@ -179,17 +172,17 @@ public:
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
return mReadyState == DONE; return mReadyState == ReadyState::Done;
} }
bool bool
IsWriteAllowed() const IsWriteAllowed() const
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
return mMode == READ_WRITE || return mMode == Mode::ReadWrite ||
mMode == READ_WRITE_FLUSH || mMode == Mode::ReadWriteFlush ||
mMode == CLEANUP || mMode == Mode::Cleanup ||
mMode == VERSION_CHANGE; mMode == Mode::VersionChange;
} }
bool bool
@ -295,11 +288,11 @@ public:
void void
FireCompleteOrAbortEvents(nsresult aResult); FireCompleteOrAbortEvents(nsresult aResult);
// Only for VERSION_CHANGE transactions. // Only for Mode::VersionChange transactions.
int64_t int64_t
NextObjectStoreId(); NextObjectStoreId();
// Only for VERSION_CHANGE transactions. // Only for Mode::VersionChange transactions.
int64_t int64_t
NextIndexId(); NextIndexId();

View file

@ -119,19 +119,19 @@ public:
Append(kCommaSpace); Append(kCommaSpace);
switch (aTransaction->GetMode()) { switch (aTransaction->GetMode()) {
case IDBTransaction::READ_ONLY: case IDBTransaction::Mode::ReadOnly:
AppendLiteral("\"readonly\""); AppendLiteral("\"readonly\"");
break; break;
case IDBTransaction::READ_WRITE: case IDBTransaction::Mode::ReadWrite:
AppendLiteral("\"readwrite\""); AppendLiteral("\"readwrite\"");
break; break;
case IDBTransaction::READ_WRITE_FLUSH: case IDBTransaction::Mode::ReadWriteFlush:
AppendLiteral("\"readwriteflush\""); AppendLiteral("\"readwriteflush\"");
break; break;
case IDBTransaction::CLEANUP: case IDBTransaction::Mode::Cleanup:
AppendLiteral("\"cleanup\""); AppendLiteral("\"cleanup\"");
break; break;
case IDBTransaction::VERSION_CHANGE: case IDBTransaction::Mode::VersionChange:
AppendLiteral("\"versionchange\""); AppendLiteral("\"versionchange\"");
break; break;
default: default:

View file

@ -86,8 +86,8 @@ template <>
struct ParamTraits<mozilla::dom::IDBTransaction::Mode> : struct ParamTraits<mozilla::dom::IDBTransaction::Mode> :
public ContiguousEnumSerializer< public ContiguousEnumSerializer<
mozilla::dom::IDBTransaction::Mode, mozilla::dom::IDBTransaction::Mode,
mozilla::dom::IDBTransaction::READ_ONLY, mozilla::dom::IDBTransaction::Mode::ReadOnly,
mozilla::dom::IDBTransaction::MODE_INVALID> mozilla::dom::IDBTransaction::Mode::Invalid>
{ }; { };
} // namespace IPC } // namespace IPC

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const databaseInfo = [ const databaseInfo = [
{ name: window.location.pathname + "1" }, { name: window.location.pathname + "1" },
@ -72,7 +72,7 @@
for (let i = 1; i < databases.length; i++) { for (let i = 1; i < databases.length; i++) {
let db = databases[i]; let db = databases[i];
let objectStore = db.transaction([objectStoreName], READ_WRITE) let objectStore = db.transaction([objectStoreName], Mode::ReadWrite)
.objectStore(objectStoreName); .objectStore(objectStoreName);
request = objectStore.add(refResult, 2); request = objectStore.add(refResult, 2);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -48,7 +48,7 @@
is(event.type, "success", "Got correct event type"); is(event.type, "success", "Got correct event type");
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
trans.objectStore(objectStoreName).delete(fileData1.key); trans.objectStore(objectStoreName).delete(fileData1.key);
trans.oncomplete = grabEventAndContinueHandler; trans.oncomplete = grabEventAndContinueHandler;
event = yield undefined; event = yield undefined;
@ -80,7 +80,7 @@
let db = event.target.result; let db = event.target.result;
db.onerror = errorHandler; db.onerror = errorHandler;
trans = db.transaction([objectStoreName], READ_WRITE); trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.get(fileData2.key); request = objectStore.get(fileData2.key);
@ -100,7 +100,7 @@
is(getFileDBRefCount(name, 2), 0, "Correct db ref count"); is(getFileDBRefCount(name, 2), 0, "Correct db ref count");
trans = db.transaction([objectStoreName], READ_WRITE); trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
objectStore.delete(fileData3.key); objectStore.delete(fileData3.key);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -67,7 +67,7 @@
is(usage, startUsage + fileData1.obj.file.size + fileData2.obj.file.size, is(usage, startUsage + fileData1.obj.file.size + fileData2.obj.file.size,
"Correct file usage"); "Correct file usage");
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
trans.objectStore(objectStoreName).delete(fileData1.key); trans.objectStore(objectStoreName).delete(fileData1.key);
trans.oncomplete = grabEventAndContinueHandler; trans.oncomplete = grabEventAndContinueHandler;
event = yield undefined; event = yield undefined;

View file

@ -21,7 +21,7 @@
*/ */
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const databaseInfo = [ const databaseInfo = [
{ name: window.location.pathname + "1", source: true }, { name: window.location.pathname + "1", source: true },
@ -106,7 +106,7 @@
for (let i = 1; i < databases.length; i++) { for (let i = 1; i < databases.length; i++) {
let db = databases[i]; let db = databases[i];
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
let objectStore = trans.objectStore(objectStoreName); let objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(fileBackedFile, 2); request = objectStore.add(fileBackedFile, 2);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -42,7 +42,7 @@
is(event.type, "success", "Got correct event type"); is(event.type, "success", "Got correct event type");
let objectStore = db.transaction([objectStoreName], READ_WRITE) let objectStore = db.transaction([objectStoreName], Mode::ReadWrite)
.objectStore(objectStoreName); .objectStore(objectStoreName);
request = objectStore.add(blobData.blob, blobData.key); request = objectStore.add(blobData.blob, blobData.key);
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
@ -65,7 +65,7 @@
verifyBlob(event.target.result, blobData.blob, 1); verifyBlob(event.target.result, blobData.blob, 1);
yield undefined; yield undefined;
objectStore = db.transaction([objectStoreName], READ_WRITE) objectStore = db.transaction([objectStoreName], Mode::ReadWrite)
.objectStore(objectStoreName); .objectStore(objectStoreName);
request = objectStore.add(fileData.file, fileData.key); request = objectStore.add(fileData.file, fileData.key);
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -40,7 +40,7 @@
is(event.type, "success", "Got correct event type"); is(event.type, "success", "Got correct event type");
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
objectStore.delete(fileData.key); objectStore.delete(fileData.key);
@ -50,7 +50,7 @@
is(getFileDBRefCount(name, 1), 0, "Correct db ref count"); is(getFileDBRefCount(name, 1), 0, "Correct db ref count");
trans = db.transaction([objectStoreName], READ_WRITE); trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(fileData.file, fileData.key); request = objectStore.add(fileData.file, fileData.key);
@ -81,7 +81,7 @@
let db = event.target.result; let db = event.target.result;
db.onerror = errorHandler; db.onerror = errorHandler;
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.get(fileData.key); request = objectStore.get(fileData.key);
@ -98,7 +98,7 @@
is(getFileDBRefCount(name, 1), 0, "Correct db ref count"); is(getFileDBRefCount(name, 1), 0, "Correct db ref count");
trans = db.transaction([objectStoreName], READ_WRITE); trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(result, fileData.key); request = objectStore.add(result, fileData.key);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -38,7 +38,7 @@
is(event.type, "success", "Got correct event type"); is(event.type, "success", "Got correct event type");
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(fileData.file, fileData.key); request = objectStore.add(fileData.file, fileData.key);
@ -58,7 +58,7 @@
is(getFileDBRefCount(name, 1), 0, "Correct db ref count"); is(getFileDBRefCount(name, 1), 0, "Correct db ref count");
trans = db.transaction([objectStoreName], READ_WRITE); trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(result, fileData.key); request = objectStore.add(result, fileData.key);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -67,7 +67,7 @@
for (let i = 1; i < objectStoreInfo.length; i++) { for (let i = 1; i < objectStoreInfo.length; i++) {
let info = objectStoreInfo[i]; let info = objectStoreInfo[i];
let objectStore = db.transaction([info.name], READ_WRITE) let objectStore = db.transaction([info.name], Mode::ReadWrite)
.objectStore(info.name); .objectStore(info.name);
request = objectStore.add(refResult, 2); request = objectStore.add(refResult, 2);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -38,7 +38,7 @@
is(event.type, "success", "Got correct event type"); is(event.type, "success", "Got correct event type");
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(fileData.file, fileData.key); request = objectStore.add(fileData.file, fileData.key);

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const databaseInfo = [ const databaseInfo = [
{ name: window.location.pathname + "1" }, { name: window.location.pathname + "1" },
@ -56,7 +56,7 @@
is(mutableFile.name, "random.bin", "Correct name"); is(mutableFile.name, "random.bin", "Correct name");
is(mutableFile.type, "binary/random", "Correct type"); is(mutableFile.type, "binary/random", "Correct type");
let trans = db1.transaction([objectStoreName], READ_WRITE); let trans = db1.transaction([objectStoreName], Mode::ReadWrite);
let objectStore = trans.objectStore(objectStoreName); let objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(mutableFile, 42); request = objectStore.add(mutableFile, 42);
@ -74,7 +74,7 @@
let db2 = databases[1]; let db2 = databases[1];
trans = db2.transaction([objectStoreName], READ_WRITE); trans = db2.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
try { try {

View file

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7"> <script type="text/javascript;version=1.7">
function testSteps() function testSteps()
{ {
const READ_WRITE = "readwrite"; const Mode::ReadWrite = "readwrite";
const name = window.location.pathname; const name = window.location.pathname;
@ -58,7 +58,7 @@
let file = event.target.result; let file = event.target.result;
let trans = db.transaction([objectStoreName], READ_WRITE); let trans = db.transaction([objectStoreName], Mode::ReadWrite);
objectStore = trans.objectStore(objectStoreName); objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(file, 42); request = objectStore.add(file, 42);

View file

@ -55,10 +55,10 @@ function testSteps()
try { try {
db.transaction("foo").objectStore("foo").clear(); db.transaction("foo").objectStore("foo").clear();
ok(false, "clear should throw on READ_ONLY transactions"); ok(false, "clear should throw on Mode::ReadOnly transactions");
} }
catch (e) { catch (e) {
ok(true, "clear should throw on READ_ONLY transactions"); ok(true, "clear should throw on Mode::ReadOnly transactions");
} }
request = db.transaction("foo", "readwriteflush") request = db.transaction("foo", "readwriteflush")

View file

@ -28,7 +28,7 @@ function testSteps()
is(db.version, 1, "Database has correct version"); is(db.version, 1, "Database has correct version");
db.onupgradeneeded = function() { db.onupgradeneeded = function() {
ok(false, "our ongoing VERSION_CHANGE transaction should exclude any others!"); ok(false, "our ongoing Mode::VersionChange transaction should exclude any others!");
} }
db.createObjectStore("foo"); db.createObjectStore("foo");

View file

@ -258,7 +258,7 @@ function testSteps()
abortEventCount = 0; abortEventCount = 0;
let expectedAbortEventCount = 0; let expectedAbortEventCount = 0;
// During INITIAL // During ReadyState::Initial
transaction = db.transaction("foo"); transaction = db.transaction("foo");
transaction.abort(); transaction.abort();
try { try {
@ -269,7 +269,7 @@ function testSteps()
ok(true, "second abort should throw an error"); ok(true, "second abort should throw an error");
} }
// During LOADING // During ReadyState::Loading
transaction = db.transaction("foo"); transaction = db.transaction("foo");
transaction.objectStore("foo").get(1).onerror = abortErrorHandler; transaction.objectStore("foo").get(1).onerror = abortErrorHandler;
expectedAbortEventCount++; expectedAbortEventCount++;
@ -282,7 +282,7 @@ function testSteps()
ok(true, "second abort should throw an error"); ok(true, "second abort should throw an error");
} }
// During LOADING from callback // During ReadyState::Loading from callback
transaction = db.transaction("foo"); transaction = db.transaction("foo");
transaction.objectStore("foo").get(1).onsuccess = grabEventAndContinueHandler; transaction.objectStore("foo").get(1).onsuccess = grabEventAndContinueHandler;
event = yield undefined; event = yield undefined;
@ -297,7 +297,7 @@ function testSteps()
ok(true, "second abort should throw an error"); ok(true, "second abort should throw an error");
} }
// During LOADING from error callback // During ReadyState::Loading from error callback
transaction = db.transaction("foo", "readwrite"); transaction = db.transaction("foo", "readwrite");
transaction.objectStore("foo").add({}, 1).onerror = function(event) { transaction.objectStore("foo").add({}, 1).onerror = function(event) {
event.preventDefault(); event.preventDefault();
@ -327,7 +327,7 @@ function testSteps()
}; };
yield undefined; yield undefined;
// During COMMITTING // During ReadyState::Committing
transaction = db.transaction("foo", "readwrite"); transaction = db.transaction("foo", "readwrite");
transaction.objectStore("foo").put({hello: "world"}, 1).onsuccess = function(event) { transaction.objectStore("foo").put({hello: "world"}, 1).onsuccess = function(event) {
continueToNextStep(); continueToNextStep();