mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
[network] Use a proof of lock everywhere in cache v2.
This commit is contained in:
parent
1d1618ff0c
commit
9aed4d8a38
6 changed files with 355 additions and 344 deletions
|
|
@ -24,7 +24,9 @@ CacheIndexIterator::~CacheIndexIterator()
|
|||
{
|
||||
LOG(("CacheIndexIterator::~CacheIndexIterator() [this=%p]", this));
|
||||
|
||||
Close();
|
||||
StaticMutexAutoLock lock(CacheIndex::sLock);
|
||||
ClearRecords(lock);
|
||||
CloseInternal(NS_ERROR_NOT_AVAILABLE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
@ -43,7 +45,7 @@ CacheIndexIterator::GetNextHash(SHA1Sum::Hash *aHash)
|
|||
return mStatus;
|
||||
}
|
||||
|
||||
memcpy(aHash, mRecords[mRecords.Length() - 1]->mHash, sizeof(SHA1Sum::Hash));
|
||||
memcpy(aHash, mRecords[mRecords.Length() - 1]->Get()->mHash, sizeof(SHA1Sum::Hash));
|
||||
mRecords.RemoveElementAt(mRecords.Length() - 1);
|
||||
|
||||
return NS_OK;
|
||||
|
|
@ -82,8 +84,13 @@ CacheIndexIterator::CloseInternal(nsresult aStatus)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
CacheIndexIterator::AddRecord(CacheIndexRecord *aRecord)
|
||||
void CacheIndexIterator::ClearRecords(const StaticMutexAutoLock& aProofOfLock)
|
||||
{
|
||||
mRecords.Clear();
|
||||
}
|
||||
|
||||
void CacheIndexIterator::AddRecord(CacheIndexRecordWrapper* aRecord,
|
||||
const StaticMutexAutoLock& aProofOfLock)
|
||||
{
|
||||
LOG(("CacheIndexIterator::AddRecord() [this=%p, record=%p]", this, aRecord));
|
||||
|
||||
|
|
@ -91,7 +98,8 @@ CacheIndexIterator::AddRecord(CacheIndexRecord *aRecord)
|
|||
}
|
||||
|
||||
bool
|
||||
CacheIndexIterator::RemoveRecord(CacheIndexRecord *aRecord)
|
||||
CacheIndexIterator::RemoveRecord(CacheIndexRecordWrapper *aRecord,
|
||||
const StaticMutexAutoLock& aProofOfLock)
|
||||
{
|
||||
LOG(("CacheIndexIterator::RemoveRecord() [this=%p, record=%p]", this,
|
||||
aRecord));
|
||||
|
|
@ -100,14 +108,15 @@ CacheIndexIterator::RemoveRecord(CacheIndexRecord *aRecord)
|
|||
}
|
||||
|
||||
bool
|
||||
CacheIndexIterator::ReplaceRecord(CacheIndexRecord *aOldRecord,
|
||||
CacheIndexRecord *aNewRecord)
|
||||
CacheIndexIterator::ReplaceRecord(CacheIndexRecordWrapper* aOldRecord,
|
||||
CacheIndexRecordWrapper* aNewRecord,
|
||||
const StaticMutexAutoLock& aProofOfLock)
|
||||
{
|
||||
LOG(("CacheIndexIterator::ReplaceRecord() [this=%p, oldRecord=%p, "
|
||||
"newRecord=%p]", this, aOldRecord, aNewRecord));
|
||||
|
||||
if (RemoveRecord(aOldRecord)) {
|
||||
AddRecord(aNewRecord);
|
||||
if (RemoveRecord(aOldRecord, aProofOfLock)) {
|
||||
AddRecord(aNewRecord, aProofOfLock);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue