mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1187116 (part 6) - Replace nsBaseHashtable::EnumerateRead() calls in dom/indexedDB/ with iterators. r=khuey.
This commit is contained in:
parent
6afdc6b0fd
commit
f01997aef8
@ -21028,110 +21028,6 @@ OpenDatabaseOp::AssertMetadataConsistency(const FullDatabaseMetadata* aMetadata)
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
class MOZ_STACK_CLASS Helper final
|
||||
{
|
||||
const ObjectStoreTable& mOtherObjectStores;
|
||||
IndexTable* mCurrentOtherIndexTable;
|
||||
|
||||
public:
|
||||
static void
|
||||
AssertConsistent(const ObjectStoreTable& aThisObjectStores,
|
||||
const ObjectStoreTable& aOtherObjectStores)
|
||||
{
|
||||
Helper helper(aOtherObjectStores);
|
||||
aThisObjectStores.EnumerateRead(Enumerate, &helper);
|
||||
}
|
||||
|
||||
private:
|
||||
explicit Helper(const ObjectStoreTable& aOtherObjectStores)
|
||||
: mOtherObjectStores(aOtherObjectStores)
|
||||
, mCurrentOtherIndexTable(nullptr)
|
||||
{ }
|
||||
|
||||
static PLDHashOperator
|
||||
Enumerate(const uint64_t& /* aKey */,
|
||||
FullObjectStoreMetadata* aThisObjectStore,
|
||||
void* aClosure)
|
||||
{
|
||||
MOZ_ASSERT(aThisObjectStore);
|
||||
MOZ_ASSERT(!aThisObjectStore->mDeleted);
|
||||
MOZ_ASSERT(aClosure);
|
||||
|
||||
auto* helper = static_cast<Helper*>(aClosure);
|
||||
|
||||
MOZ_ASSERT(!helper->mCurrentOtherIndexTable);
|
||||
|
||||
auto* otherObjectStore =
|
||||
MetadataNameOrIdMatcher<FullObjectStoreMetadata>::Match(
|
||||
helper->mOtherObjectStores, aThisObjectStore->mCommonMetadata.id());
|
||||
MOZ_ASSERT(otherObjectStore);
|
||||
|
||||
MOZ_ASSERT(aThisObjectStore != otherObjectStore);
|
||||
|
||||
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.id() ==
|
||||
otherObjectStore->mCommonMetadata.id());
|
||||
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.name() ==
|
||||
otherObjectStore->mCommonMetadata.name());
|
||||
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.autoIncrement() ==
|
||||
otherObjectStore->mCommonMetadata.autoIncrement());
|
||||
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.keyPath() ==
|
||||
otherObjectStore->mCommonMetadata.keyPath());
|
||||
// mNextAutoIncrementId and mComittedAutoIncrementId may be modified
|
||||
// concurrently with this OpenOp, so it is not possible to assert equality
|
||||
// here.
|
||||
MOZ_ASSERT(aThisObjectStore->mNextAutoIncrementId <=
|
||||
otherObjectStore->mNextAutoIncrementId);
|
||||
MOZ_ASSERT(aThisObjectStore->mComittedAutoIncrementId <=
|
||||
otherObjectStore->mComittedAutoIncrementId);
|
||||
MOZ_ASSERT(!otherObjectStore->mDeleted);
|
||||
|
||||
MOZ_ASSERT(aThisObjectStore->mIndexes.Count() ==
|
||||
otherObjectStore->mIndexes.Count());
|
||||
|
||||
AutoRestore<IndexTable*> ar(helper->mCurrentOtherIndexTable);
|
||||
helper->mCurrentOtherIndexTable = &otherObjectStore->mIndexes;
|
||||
|
||||
aThisObjectStore->mIndexes.EnumerateRead(Enumerate, helper);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
Enumerate(const uint64_t& /* aKey */,
|
||||
FullIndexMetadata* aThisIndex,
|
||||
void* aClosure)
|
||||
{
|
||||
MOZ_ASSERT(aThisIndex);
|
||||
MOZ_ASSERT(!aThisIndex->mDeleted);
|
||||
MOZ_ASSERT(aClosure);
|
||||
|
||||
auto* helper = static_cast<Helper*>(aClosure);
|
||||
|
||||
MOZ_ASSERT(helper->mCurrentOtherIndexTable);
|
||||
|
||||
auto* otherIndex =
|
||||
MetadataNameOrIdMatcher<FullIndexMetadata>::Match(
|
||||
*helper->mCurrentOtherIndexTable, aThisIndex->mCommonMetadata.id());
|
||||
MOZ_ASSERT(otherIndex);
|
||||
|
||||
MOZ_ASSERT(aThisIndex != otherIndex);
|
||||
|
||||
MOZ_ASSERT(aThisIndex->mCommonMetadata.id() ==
|
||||
otherIndex->mCommonMetadata.id());
|
||||
MOZ_ASSERT(aThisIndex->mCommonMetadata.name() ==
|
||||
otherIndex->mCommonMetadata.name());
|
||||
MOZ_ASSERT(aThisIndex->mCommonMetadata.keyPath() ==
|
||||
otherIndex->mCommonMetadata.keyPath());
|
||||
MOZ_ASSERT(aThisIndex->mCommonMetadata.unique() ==
|
||||
otherIndex->mCommonMetadata.unique());
|
||||
MOZ_ASSERT(aThisIndex->mCommonMetadata.multiEntry() ==
|
||||
otherIndex->mCommonMetadata.multiEntry());
|
||||
MOZ_ASSERT(!otherIndex->mDeleted);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
};
|
||||
|
||||
const FullDatabaseMetadata* thisDB = mMetadata;
|
||||
const FullDatabaseMetadata* otherDB = aMetadata;
|
||||
|
||||
@ -21156,7 +21052,67 @@ OpenDatabaseOp::AssertMetadataConsistency(const FullDatabaseMetadata* aMetadata)
|
||||
|
||||
MOZ_ASSERT(thisDB->mObjectStores.Count() == otherDB->mObjectStores.Count());
|
||||
|
||||
Helper::AssertConsistent(thisDB->mObjectStores, otherDB->mObjectStores);
|
||||
for (auto objectStoreIter = thisDB->mObjectStores.ConstIter();
|
||||
!objectStoreIter.Done();
|
||||
objectStoreIter.Next()) {
|
||||
FullObjectStoreMetadata* thisObjectStore = objectStoreIter.UserData();
|
||||
MOZ_ASSERT(thisObjectStore);
|
||||
MOZ_ASSERT(!thisObjectStore->mDeleted);
|
||||
|
||||
auto* otherObjectStore =
|
||||
MetadataNameOrIdMatcher<FullObjectStoreMetadata>::Match(
|
||||
otherDB->mObjectStores, thisObjectStore->mCommonMetadata.id());
|
||||
MOZ_ASSERT(otherObjectStore);
|
||||
|
||||
MOZ_ASSERT(thisObjectStore != otherObjectStore);
|
||||
|
||||
MOZ_ASSERT(thisObjectStore->mCommonMetadata.id() ==
|
||||
otherObjectStore->mCommonMetadata.id());
|
||||
MOZ_ASSERT(thisObjectStore->mCommonMetadata.name() ==
|
||||
otherObjectStore->mCommonMetadata.name());
|
||||
MOZ_ASSERT(thisObjectStore->mCommonMetadata.autoIncrement() ==
|
||||
otherObjectStore->mCommonMetadata.autoIncrement());
|
||||
MOZ_ASSERT(thisObjectStore->mCommonMetadata.keyPath() ==
|
||||
otherObjectStore->mCommonMetadata.keyPath());
|
||||
// mNextAutoIncrementId and mComittedAutoIncrementId may be modified
|
||||
// concurrently with this OpenOp, so it is not possible to assert equality
|
||||
// here.
|
||||
MOZ_ASSERT(thisObjectStore->mNextAutoIncrementId <=
|
||||
otherObjectStore->mNextAutoIncrementId);
|
||||
MOZ_ASSERT(thisObjectStore->mComittedAutoIncrementId <=
|
||||
otherObjectStore->mComittedAutoIncrementId);
|
||||
MOZ_ASSERT(!otherObjectStore->mDeleted);
|
||||
|
||||
MOZ_ASSERT(thisObjectStore->mIndexes.Count() ==
|
||||
otherObjectStore->mIndexes.Count());
|
||||
|
||||
for (auto indexIter = thisObjectStore->mIndexes.Iter();
|
||||
!indexIter.Done();
|
||||
indexIter.Next()) {
|
||||
FullIndexMetadata* thisIndex = indexIter.UserData();
|
||||
MOZ_ASSERT(thisIndex);
|
||||
MOZ_ASSERT(!thisIndex->mDeleted);
|
||||
|
||||
auto* otherIndex =
|
||||
MetadataNameOrIdMatcher<FullIndexMetadata>::
|
||||
Match(otherObjectStore->mIndexes, thisIndex->mCommonMetadata.id());
|
||||
MOZ_ASSERT(otherIndex);
|
||||
|
||||
MOZ_ASSERT(thisIndex != otherIndex);
|
||||
|
||||
MOZ_ASSERT(thisIndex->mCommonMetadata.id() ==
|
||||
otherIndex->mCommonMetadata.id());
|
||||
MOZ_ASSERT(thisIndex->mCommonMetadata.name() ==
|
||||
otherIndex->mCommonMetadata.name());
|
||||
MOZ_ASSERT(thisIndex->mCommonMetadata.keyPath() ==
|
||||
otherIndex->mCommonMetadata.keyPath());
|
||||
MOZ_ASSERT(thisIndex->mCommonMetadata.unique() ==
|
||||
otherIndex->mCommonMetadata.unique());
|
||||
MOZ_ASSERT(thisIndex->mCommonMetadata.multiEntry() ==
|
||||
otherIndex->mCommonMetadata.multiEntry());
|
||||
MOZ_ASSERT(!otherIndex->mDeleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user