mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 1187151 (part 12) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey.
--HG-- extra : rebase_source : d3b87524cd3f2eff118727cadac6d31713cead89
This commit is contained in:
parent
c06d9bb39e
commit
6c7df1f040
@ -1207,32 +1207,6 @@ bool OriginPatternMatches(const nsACString& aOriginSuffix, const OriginAttribute
|
|||||||
return aPattern.Matches(oa);
|
return aPattern.Matches(oa);
|
||||||
}
|
}
|
||||||
|
|
||||||
PLDHashOperator
|
|
||||||
ForgetUpdatesForOrigin(const nsACString& aMapping,
|
|
||||||
nsAutoPtr<DOMStorageDBThread::DBOperation>& aPendingTask,
|
|
||||||
void* aArg)
|
|
||||||
{
|
|
||||||
DOMStorageDBThread::DBOperation* newOp = static_cast<DOMStorageDBThread::DBOperation*>(aArg);
|
|
||||||
|
|
||||||
if (newOp->Type() == DOMStorageDBThread::DBOperation::opClear &&
|
|
||||||
(aPendingTask->OriginNoSuffix() != newOp->OriginNoSuffix() ||
|
|
||||||
aPendingTask->OriginSuffix() != newOp->OriginSuffix())) {
|
|
||||||
return PL_DHASH_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newOp->Type() == DOMStorageDBThread::DBOperation::opClearMatchingOrigin &&
|
|
||||||
!StringBeginsWith(aPendingTask->OriginNoSuffix(), newOp->Origin())) {
|
|
||||||
return PL_DHASH_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newOp->Type() == DOMStorageDBThread::DBOperation::opClearMatchingOriginAttributes &&
|
|
||||||
!OriginPatternMatches(aPendingTask->OriginSuffix(), newOp->OriginPattern())) {
|
|
||||||
return PL_DHASH_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PL_DHASH_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -1304,7 +1278,28 @@ DOMStorageDBThread::PendingOperations::Add(DOMStorageDBThread::DBOperation* aOpe
|
|||||||
// We do this as an optimization as well as a must based on the logic,
|
// We do this as an optimization as well as a must based on the logic,
|
||||||
// if we would not delete the update tasks, changes would have been stored
|
// if we would not delete the update tasks, changes would have been stored
|
||||||
// to the database after clear operations have been executed.
|
// to the database after clear operations have been executed.
|
||||||
mUpdates.Enumerate(ForgetUpdatesForOrigin, aOperation);
|
for (auto iter = mUpdates.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
nsAutoPtr<DBOperation>& pendingTask = iter.Data();
|
||||||
|
|
||||||
|
if (aOperation->Type() == DBOperation::opClear &&
|
||||||
|
(pendingTask->OriginNoSuffix() != aOperation->OriginNoSuffix() ||
|
||||||
|
pendingTask->OriginSuffix() != aOperation->OriginSuffix())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aOperation->Type() == DBOperation::opClearMatchingOrigin &&
|
||||||
|
!StringBeginsWith(pendingTask->OriginNoSuffix(), aOperation->Origin())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aOperation->Type() == DBOperation::opClearMatchingOriginAttributes &&
|
||||||
|
!OriginPatternMatches(pendingTask->OriginSuffix(), aOperation->OriginPattern())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
iter.Remove();
|
||||||
|
}
|
||||||
|
|
||||||
mClears.Put(aOperation->Target(), aOperation);
|
mClears.Put(aOperation->Target(), aOperation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1321,20 +1316,6 @@ DOMStorageDBThread::PendingOperations::Add(DOMStorageDBThread::DBOperation* aOpe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
PLDHashOperator
|
|
||||||
CollectTasks(const nsACString& aMapping, nsAutoPtr<DOMStorageDBThread::DBOperation>& aOperation, void* aArg)
|
|
||||||
{
|
|
||||||
nsTArray<nsAutoPtr<DOMStorageDBThread::DBOperation> >* tasks =
|
|
||||||
static_cast<nsTArray<nsAutoPtr<DOMStorageDBThread::DBOperation> >*>(aArg);
|
|
||||||
|
|
||||||
tasks->AppendElement(aOperation.forget());
|
|
||||||
return PL_DHASH_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DOMStorageDBThread::PendingOperations::Prepare()
|
DOMStorageDBThread::PendingOperations::Prepare()
|
||||||
{
|
{
|
||||||
@ -1345,10 +1326,14 @@ DOMStorageDBThread::PendingOperations::Prepare()
|
|||||||
// scheduled, we drop all updates matching that scope. So,
|
// scheduled, we drop all updates matching that scope. So,
|
||||||
// all scope-related update operations we have here now were
|
// all scope-related update operations we have here now were
|
||||||
// scheduled after the clear operations.
|
// scheduled after the clear operations.
|
||||||
mClears.Enumerate(CollectTasks, &mExecList);
|
for (auto iter = mClears.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
mExecList.AppendElement(iter.Data().forget());
|
||||||
|
}
|
||||||
mClears.Clear();
|
mClears.Clear();
|
||||||
|
|
||||||
mUpdates.Enumerate(CollectTasks, &mExecList);
|
for (auto iter = mUpdates.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
mExecList.AppendElement(iter.Data().forget());
|
||||||
|
}
|
||||||
mUpdates.Clear();
|
mUpdates.Clear();
|
||||||
|
|
||||||
return !!mExecList.Length();
|
return !!mExecList.Length();
|
||||||
|
Loading…
Reference in New Issue
Block a user