Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 7c774ed

Browse files
committed
Backed out 8 changesets (bug 1497007) for causing build bustages in /builds/worker/workspace/build/src/dom/indexedDB/IDBTransaction.cpp CLOSED TREE
Backed out changeset 15de0d72f1c4 (bug 1497007) Backed out changeset 7056932f6422 (bug 1497007) Backed out changeset 7304fae8c436 (bug 1497007) Backed out changeset be22a95de04b (bug 1497007) Backed out changeset 98ac48b5f1ef (bug 1497007) Backed out changeset 562d3cda9fa3 (bug 1497007) Backed out changeset 3f96e71be2e3 (bug 1497007) Backed out changeset 3d9e86698c9f (bug 1497007)
1 parent 0cd65a9 commit 7c774ed

5 files changed

Lines changed: 286 additions & 274 deletions

File tree

dom/indexedDB/IDBDatabase.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,6 @@ void IDBDatabase::AbortTransactions(bool aShouldWarn) {
732732
aDatabase->mTransactions;
733733

734734
if (!transactionTable.Count()) {
735-
// Return early as an optimization, the remainder is a no-op in this
736-
// case.
737735
return;
738736
}
739737

@@ -756,8 +754,6 @@ void IDBDatabase::AbortTransactions(bool aShouldWarn) {
756754
MOZ_ASSERT(transactionsToAbort.Length() <= transactionTable.Count());
757755

758756
if (transactionsToAbort.IsEmpty()) {
759-
// Return early as an optimization, the remainder is a no-op in this
760-
// case.
761757
return;
762758
}
763759

@@ -772,10 +768,23 @@ void IDBDatabase::AbortTransactions(bool aShouldWarn) {
772768
MOZ_ASSERT(transaction);
773769
MOZ_ASSERT(!transaction->IsDone());
774770

775-
// We warn for any transactions that could have written data, but
776-
// ignore read-only transactions.
777-
if (aShouldWarn && transaction->IsWriteAllowed()) {
778-
transactionsThatNeedWarning.AppendElement(transaction);
771+
if (aShouldWarn) {
772+
switch (transaction->GetMode()) {
773+
// We ignore transactions that could not have written any data.
774+
case IDBTransaction::READ_ONLY:
775+
break;
776+
777+
// We warn for any transactions that could have written data.
778+
case IDBTransaction::READ_WRITE:
779+
case IDBTransaction::READ_WRITE_FLUSH:
780+
case IDBTransaction::CLEANUP:
781+
case IDBTransaction::VERSION_CHANGE:
782+
transactionsThatNeedWarning.AppendElement(transaction);
783+
break;
784+
785+
default:
786+
MOZ_CRASH("Unknown mode!");
787+
}
779788
}
780789

781790
transaction->Abort(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR);

dom/indexedDB/IDBIndex.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,24 @@ void IDBIndex::RefreshMetadata(bool aMayDelete) {
8888
AssertIsOnOwningThread();
8989
MOZ_ASSERT_IF(mDeletedMetadata, mMetadata == mDeletedMetadata);
9090

91-
const auto& indexes = mObjectStore->Spec().indexes();
92-
const auto foundIt = std::find_if(
93-
indexes.cbegin(), indexes.cend(),
94-
[id = Id()](const auto& metadata) { return metadata.id() == id; });
95-
const bool found = foundIt != indexes.cend();
91+
const nsTArray<IndexMetadata>& indexes = mObjectStore->Spec().indexes();
92+
93+
bool found = false;
94+
95+
for (uint32_t count = indexes.Length(), index = 0; index < count; index++) {
96+
const IndexMetadata& metadata = indexes[index];
97+
98+
if (metadata.id() == Id()) {
99+
mMetadata = &metadata;
100+
101+
found = true;
102+
break;
103+
}
104+
}
96105

97106
MOZ_ASSERT_IF(!aMayDelete && !mDeletedMetadata, found);
98107

99108
if (found) {
100-
mMetadata = &*foundIt;
101109
MOZ_ASSERT(mMetadata != mDeletedMetadata);
102110
mDeletedMetadata = nullptr;
103111
} else {

dom/indexedDB/IDBObjectStore.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,20 +2353,27 @@ void IDBObjectStore::RefreshSpec(bool aMayDelete) {
23532353

23542354
const nsTArray<ObjectStoreSpec>& objectStores = dbSpec->objectStores();
23552355

2356-
const auto foundIt = std::find_if(objectStores.cbegin(), objectStores.cend(),
2357-
[id = Id()](const auto& objSpec) {
2358-
return objSpec.metadata().id() == id;
2359-
});
2360-
const bool found = foundIt != objectStores.cend();
2361-
if (found) {
2362-
mSpec = &*foundIt;
2356+
bool found = false;
23632357

2364-
for (auto& index : mIndexes) {
2365-
index->RefreshMetadata(aMayDelete);
2366-
}
2358+
for (uint32_t objCount = objectStores.Length(), objIndex = 0;
2359+
objIndex < objCount; objIndex++) {
2360+
const ObjectStoreSpec& objSpec = objectStores[objIndex];
2361+
2362+
if (objSpec.metadata().id() == Id()) {
2363+
mSpec = &objSpec;
2364+
2365+
for (uint32_t idxCount = mIndexes.Length(), idxIndex = 0;
2366+
idxIndex < idxCount; idxIndex++) {
2367+
mIndexes[idxIndex]->RefreshMetadata(aMayDelete);
2368+
}
2369+
2370+
for (uint32_t idxCount = mDeletedIndexes.Length(), idxIndex = 0;
2371+
idxIndex < idxCount; idxIndex++) {
2372+
mDeletedIndexes[idxIndex]->RefreshMetadata(false);
2373+
}
23672374

2368-
for (auto& index : mDeletedIndexes) {
2369-
index->RefreshMetadata(false);
2375+
found = true;
2376+
break;
23702377
}
23712378
}
23722379

0 commit comments

Comments
 (0)