зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1395202 - Part 1: Create nsICacheEntry::CacheEntryId. r=michal, f=junior,mayhemer
This commit is contained in:
Родитель
9a5a3a7722
Коммит
f56a0fb03f
|
@ -191,6 +191,13 @@ NS_IMPL_ISUPPORTS(CacheEntry,
|
|||
nsIRunnable,
|
||||
CacheFileListener)
|
||||
|
||||
/* static */
|
||||
uint64_t CacheEntry::GetNextId()
|
||||
{
|
||||
static Atomic<uint64_t, Relaxed> id(0);
|
||||
return ++id;
|
||||
}
|
||||
|
||||
CacheEntry::CacheEntry(const nsACString& aStorageID,
|
||||
const nsACString& aURI,
|
||||
const nsACString& aEnhanceID,
|
||||
|
@ -217,6 +224,7 @@ CacheEntry::CacheEntry(const nsACString& aStorageID,
|
|||
, mWriter(nullptr)
|
||||
, mPredictedDataSize(0)
|
||||
, mUseCount(0)
|
||||
, mCacheEntryId(GetNextId())
|
||||
{
|
||||
LOG(("CacheEntry::CacheEntry [this=%p]", this));
|
||||
|
||||
|
@ -1048,6 +1056,12 @@ NS_IMETHODIMP CacheEntry::GetKey(nsACString & aKey)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CacheEntry::GetCacheEntryId(uint64_t *aCacheEntryId)
|
||||
{
|
||||
*aCacheEntryId = mCacheEntryId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CacheEntry::GetFetchCount(int32_t *aFetchCount)
|
||||
{
|
||||
NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE);
|
||||
|
|
|
@ -54,6 +54,8 @@ public:
|
|||
NS_DECL_NSICACHEENTRY
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
static uint64_t GetNextId();
|
||||
|
||||
CacheEntry(const nsACString& aStorageID, const nsACString& aURI, const nsACString& aEnhanceID,
|
||||
bool aUseDisk, bool aSkipSizeCheck, bool aPin);
|
||||
|
||||
|
@ -383,6 +385,8 @@ private:
|
|||
int64_t mPredictedDataSize;
|
||||
mozilla::TimeStamp mLoadStart;
|
||||
uint32_t mUseCount;
|
||||
|
||||
const uint64_t mCacheEntryId;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -346,13 +346,13 @@ _OldGetDiskConsumption::VisitEntry(const char * deviceID,
|
|||
// _OldCacheEntryWrapper
|
||||
|
||||
_OldCacheEntryWrapper::_OldCacheEntryWrapper(nsICacheEntryDescriptor* desc)
|
||||
: mOldDesc(desc), mOldInfo(desc)
|
||||
: mOldDesc(desc), mOldInfo(desc), mCacheEntryId(CacheEntry::GetNextId())
|
||||
{
|
||||
LOG(("Creating _OldCacheEntryWrapper %p for descriptor %p", this, desc));
|
||||
}
|
||||
|
||||
_OldCacheEntryWrapper::_OldCacheEntryWrapper(nsICacheEntryInfo* info)
|
||||
: mOldDesc(nullptr), mOldInfo(info)
|
||||
: mOldDesc(nullptr), mOldInfo(info), mCacheEntryId(CacheEntry::GetNextId())
|
||||
{
|
||||
LOG(("Creating _OldCacheEntryWrapper %p for info %p", this, info));
|
||||
}
|
||||
|
|
|
@ -115,6 +115,11 @@ public:
|
|||
{
|
||||
return mOldInfo->GetKey(aKey);
|
||||
}
|
||||
NS_IMETHOD GetCacheEntryId(uint64_t *aCacheEntryId) override
|
||||
{
|
||||
*aCacheEntryId = mCacheEntryId;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetFetchCount(int32_t *aFetchCount) override
|
||||
{
|
||||
return mOldInfo->GetFetchCount(aFetchCount);
|
||||
|
@ -176,6 +181,8 @@ private:
|
|||
_OldCacheEntryWrapper() = delete;
|
||||
nsICacheEntryDescriptor* mOldDesc; // ref holded in mOldInfo
|
||||
nsCOMPtr<nsICacheEntryInfo> mOldInfo;
|
||||
|
||||
const uint64_t mCacheEntryId;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ interface nsICacheEntry : nsISupports
|
|||
*/
|
||||
readonly attribute ACString key;
|
||||
|
||||
/**
|
||||
* The unique ID for every nsICacheEntry instance, which can be used to check
|
||||
* whether two pieces of information are from the same nsICacheEntry instance.
|
||||
*/
|
||||
readonly attribute uint64_t cacheEntryId;
|
||||
|
||||
/**
|
||||
* Whether the entry is memory/only or persisted to disk.
|
||||
* Note: private browsing entries are reported as persistent for consistency
|
||||
|
|
Загрузка…
Ссылка в новой задаче