mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1312954
- part 2: Add a new interface nsICacheStorageService.asyncVisitAllStorages() to allow visiting every cache entry. r=mayhemer
This commit is contained in:
parent
f747db3bbd
commit
4af0ebd9ee
@ -1332,16 +1332,12 @@ CacheIndex::GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t *
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!aInfo) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
*aSize = 0;
|
||||
*aCount = 0;
|
||||
|
||||
for (auto iter = index->mFrecencyArray.Iter(); !iter.Done(); iter.Next()) {
|
||||
CacheIndexRecord *record = iter.Get();
|
||||
if (!CacheIndexEntry::RecordMatchesLoadContextInfo(record, aInfo))
|
||||
if (aInfo && !CacheIndexEntry::RecordMatchesLoadContextInfo(record, aInfo))
|
||||
continue;
|
||||
|
||||
*aSize += CacheIndexEntry::GetFileSize(record);
|
||||
|
@ -264,6 +264,8 @@ public:
|
||||
static bool RecordMatchesLoadContextInfo(CacheIndexRecord *aRec,
|
||||
nsILoadContextInfo *aInfo)
|
||||
{
|
||||
MOZ_ASSERT(aInfo);
|
||||
|
||||
if (!aInfo->IsPrivate() &&
|
||||
GetOriginAttrsHash(*aInfo->OriginAttributesPtr()) == aRec->mOriginAttrsHash &&
|
||||
aInfo->IsAnonymous() == !!(aRec->mFlags & kAnonymousMask)) {
|
||||
@ -666,7 +668,8 @@ public:
|
||||
static nsresult GetEntryFileCount(uint32_t *_retval);
|
||||
|
||||
// Synchronously returns the disk occupation and number of entries per-context.
|
||||
// Callable on any thread.
|
||||
// Callable on any thread. It will ignore loadContextInfo and get stats for
|
||||
// all entries if the aInfo is a nullptr.
|
||||
static nsresult GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t *aCount);
|
||||
|
||||
// Asynchronously gets the disk cache size, used for display in the UI.
|
||||
|
@ -931,6 +931,21 @@ NS_IMETHODIMP CacheStorageService::GetIoTarget(nsIEventTarget** aEventTarget)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CacheStorageService::AsyncVisitAllStorages(
|
||||
nsICacheStorageVisitor* aVisitor,
|
||||
bool aVisitEntries)
|
||||
{
|
||||
LOG(("CacheStorageService::AsyncVisitAllStorages [cb=%p]", aVisitor));
|
||||
NS_ENSURE_FALSE(mShutdown, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// Walking the disk cache also walks the memory cache.
|
||||
RefPtr<WalkDiskCacheRunnable> event =
|
||||
new WalkDiskCacheRunnable(nullptr, aVisitEntries, aVisitor);
|
||||
return event->Walk();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Methods used by CacheEntry for management of in-memory structures.
|
||||
|
||||
namespace {
|
||||
|
@ -9,6 +9,7 @@ interface nsILoadContextInfo;
|
||||
interface nsIApplicationCache;
|
||||
interface nsIEventTarget;
|
||||
interface nsICacheStorageConsumptionObserver;
|
||||
interface nsICacheStorageVisitor;
|
||||
|
||||
/**
|
||||
* Provides access to particual cache storages of the network URI cache.
|
||||
@ -109,6 +110,17 @@ interface nsICacheStorageService : nsISupports
|
||||
* NOTE: the observer MUST implement nsISupportsWeakReference.
|
||||
*/
|
||||
void asyncGetDiskConsumption(in nsICacheStorageConsumptionObserver aObserver);
|
||||
|
||||
/**
|
||||
* Asynchronously visits all storages of the disk cache and memory cache.
|
||||
* @see nsICacheStorageVisitor
|
||||
* @param aVisitor
|
||||
* A visitor callback.
|
||||
* @param aVisitEntries
|
||||
* A boolean indicates whether visits entries.
|
||||
*/
|
||||
void asyncVisitAllStorages(in nsICacheStorageVisitor aVisitor,
|
||||
in boolean aVisitEntries);
|
||||
};
|
||||
|
||||
[scriptable, uuid(7728ab5b-4c01-4483-a606-32bf5b8136cb)]
|
||||
|
Loading…
Reference in New Issue
Block a user