mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186811 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in dom/storage/ with iterators. r=baku.
This commit is contained in:
parent
bef04866b0
commit
4beb686126
@ -1253,40 +1253,25 @@ DOMStorageDBThread::PendingOperations::Finalize(nsresult aRv)
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class FindPendingOperationForScopeData
|
bool
|
||||||
|
FindPendingClearForScope(const nsACString& aScope,
|
||||||
|
DOMStorageDBThread::DBOperation* aPendingOperation)
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
explicit FindPendingOperationForScopeData(const nsACString& aScope) : mScope(aScope), mFound(false) {}
|
|
||||||
nsCString mScope;
|
|
||||||
bool mFound;
|
|
||||||
};
|
|
||||||
|
|
||||||
PLDHashOperator
|
|
||||||
FindPendingClearForScope(const nsACString& aMapping,
|
|
||||||
DOMStorageDBThread::DBOperation* aPendingOperation,
|
|
||||||
void* aArg)
|
|
||||||
{
|
|
||||||
FindPendingOperationForScopeData* data =
|
|
||||||
static_cast<FindPendingOperationForScopeData*>(aArg);
|
|
||||||
|
|
||||||
if (aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opClearAll) {
|
if (aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opClearAll) {
|
||||||
data->mFound = true;
|
return true;
|
||||||
return PL_DHASH_STOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opClear &&
|
if (aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opClear &&
|
||||||
data->mScope == aPendingOperation->Scope()) {
|
aScope == aPendingOperation->Scope()) {
|
||||||
data->mFound = true;
|
return true;
|
||||||
return PL_DHASH_STOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opClearMatchingScope &&
|
if (aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opClearMatchingScope &&
|
||||||
StringBeginsWith(data->mScope, aPendingOperation->Scope())) {
|
StringBeginsWith(aScope, aPendingOperation->Scope())) {
|
||||||
data->mFound = true;
|
return true;
|
||||||
return PL_DHASH_STOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PL_DHASH_NEXT;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -1296,17 +1281,14 @@ DOMStorageDBThread::PendingOperations::IsScopeClearPending(const nsACString& aSc
|
|||||||
{
|
{
|
||||||
// Called under the lock
|
// Called under the lock
|
||||||
|
|
||||||
FindPendingOperationForScopeData data(aScope);
|
for (auto iter = mClears.Iter(); !iter.Done(); iter.Next()) {
|
||||||
mClears.EnumerateRead(FindPendingClearForScope, &data);
|
if (FindPendingClearForScope(aScope, iter.UserData())) {
|
||||||
if (data.mFound) {
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mExecList.Length(); ++i) {
|
for (uint32_t i = 0; i < mExecList.Length(); ++i) {
|
||||||
DOMStorageDBThread::DBOperation* task = mExecList[i];
|
if (FindPendingClearForScope(aScope, mExecList[i])) {
|
||||||
FindPendingClearForScope(EmptyCString(), task, &data);
|
|
||||||
|
|
||||||
if (data.mFound) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1316,23 +1298,18 @@ DOMStorageDBThread::PendingOperations::IsScopeClearPending(const nsACString& aSc
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
PLDHashOperator
|
bool
|
||||||
FindPendingUpdateForScope(const nsACString& aMapping,
|
FindPendingUpdateForScope(const nsACString& aScope,
|
||||||
DOMStorageDBThread::DBOperation* aPendingOperation,
|
DOMStorageDBThread::DBOperation* aPendingOperation)
|
||||||
void* aArg)
|
|
||||||
{
|
{
|
||||||
FindPendingOperationForScopeData* data =
|
|
||||||
static_cast<FindPendingOperationForScopeData*>(aArg);
|
|
||||||
|
|
||||||
if ((aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opAddItem ||
|
if ((aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opAddItem ||
|
||||||
aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opUpdateItem ||
|
aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opUpdateItem ||
|
||||||
aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opRemoveItem) &&
|
aPendingOperation->Type() == DOMStorageDBThread::DBOperation::opRemoveItem) &&
|
||||||
data->mScope == aPendingOperation->Scope()) {
|
aScope == aPendingOperation->Scope()) {
|
||||||
data->mFound = true;
|
return true;
|
||||||
return PL_DHASH_STOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PL_DHASH_NEXT;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -1342,17 +1319,14 @@ DOMStorageDBThread::PendingOperations::IsScopeUpdatePending(const nsACString& aS
|
|||||||
{
|
{
|
||||||
// Called under the lock
|
// Called under the lock
|
||||||
|
|
||||||
FindPendingOperationForScopeData data(aScope);
|
for (auto iter = mUpdates.Iter(); !iter.Done(); iter.Next()) {
|
||||||
mUpdates.EnumerateRead(FindPendingUpdateForScope, &data);
|
if (FindPendingUpdateForScope(aScope, iter.UserData())) {
|
||||||
if (data.mFound) {
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mExecList.Length(); ++i) {
|
for (uint32_t i = 0; i < mExecList.Length(); ++i) {
|
||||||
DOMStorageDBThread::DBOperation* task = mExecList[i];
|
if (FindPendingUpdateForScope(aScope, mExecList[i])) {
|
||||||
FindPendingUpdateForScope(EmptyCString(), task, &data);
|
|
||||||
|
|
||||||
if (data.mFound) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user