[network] Use a proof of lock everywhere in cache v2.

This commit is contained in:
Moonchild 2021-08-11 23:49:44 +00:00 • committed by roytam1
commit 9aed4d8a38
6 changed files with 355 additions and 344 deletions

View file

@ -9,12 +9,13 @@
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "mozilla/SHA1.h"
#include "mozilla/StaticMutex.h"
namespace mozilla {
namespace net {
class CacheIndex;
struct CacheIndexRecord;
class CacheIndexRecordWrapper;
class CacheIndexIterator
{
@ -42,14 +43,18 @@ protected:
nsresult CloseInternal(nsresult aStatus);
bool ShouldBeNewAdded() { return mAddNew; }
virtual void AddRecord(CacheIndexRecord *aRecord);
bool RemoveRecord(CacheIndexRecord *aRecord);
bool ReplaceRecord(CacheIndexRecord *aOldRecord,
CacheIndexRecord *aNewRecord);
virtual void AddRecord(CacheIndexRecordWrapper* aRecord,
const StaticMutexAutoLock& aProofOfLock);
bool RemoveRecord(CacheIndexRecordWrapper* aRecord,
const StaticMutexAutoLock& aProofOfLock);
bool ReplaceRecord(CacheIndexRecordWrapper* aOldRecord,
CacheIndexRecordWrapper* aNewRecord,
const StaticMutexAutoLock& aProofOfLock);
void ClearRecords(const StaticMutexAutoLock& aProofOfLock);
nsresult mStatus;
RefPtr<CacheIndex> mIndex;
nsTArray<CacheIndexRecord *> mRecords;
nsTArray<RefPtr<CacheIndexRecordWrapper>> mRecords;
bool mAddNew;
};