Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsDiskCacheEvictor Class Reference
Inheritance diagram for nsDiskCacheEvictor:
Inheritance graph
Collaboration diagram for nsDiskCacheEvictor:
Collaboration graph

List of all members.

Public Member Functions

 nsDiskCacheEvictor (nsDiskCacheDevice *device, nsDiskCacheMap *cacheMap, nsDiskCacheBindery *cacheBindery, PRInt32 targetSize, const char *clientID)
virtual PRInt32 VisitRecord (nsDiskCacheRecord *mapRecord)

Private Attributes

PRInt32 mTargetSize
const char * mClientID

Detailed Description

Definition at line 102 of file nsDiskCacheDevice.cpp.

Constructor & Destructor Documentation

nsDiskCacheEvictor::nsDiskCacheEvictor ( nsDiskCacheDevice device,
nsDiskCacheMap cacheMap,
nsDiskCacheBindery cacheBindery,
PRInt32  targetSize,
const char *  clientID 
) [inline]

Definition at line 105 of file nsDiskCacheDevice.cpp.

        : mDevice(device)
        , mCacheMap(cacheMap)
        , mBindery(cacheBindery)
        , mTargetSize(targetSize)
        , mClientID(clientID)

Member Function Documentation

Implements nsDiskCacheRecordVisitor.

Definition at line 129 of file nsDiskCacheDevice.cpp.

    // read disk cache entry
    nsDiskCacheEntry *   diskEntry = nsnull;
    nsDiskCacheBinding * binding   = nsnull;
    char *               clientID  = nsnull;
    PRInt32              result    = kVisitNextRecord;

    if (mClientID) {
         // we're just evicting records for a specific client
        nsresult  rv = mCacheMap->ReadDiskCacheEntry(mapRecord, &diskEntry);
        if (NS_FAILED(rv))  goto exit;  // XXX or delete record?
        // XXX FIXME compare clientID's without malloc

        // get client ID from key
        rv = ClientIDFromCacheKey(nsDependentCString(diskEntry->mKeyStart), &clientID);
        if (NS_FAILED(rv))  goto exit;
        if (nsCRT::strcmp(mClientID, clientID) != 0) goto exit;
    if (mCacheMap->TotalSize() < mTargetSize) {
        result = kStopVisitingRecords;
        goto exit;
    binding = mBindery->FindActiveBinding(mapRecord->HashNumber());
    if (binding) {
        // We are currently using this entry, so all we can do is doom it.
        // Since we're enumerating the records, we don't want to call
        // DeleteRecord when nsCacheService::DoomEntry() calls us back.
        binding->mDoomed = PR_TRUE;         // mark binding record as 'deleted'
        result = kDeleteRecordAndContinue;  // this will REALLY delete the record

    } else {
        // entry not in use, just delete storage because we're enumerating the records
        (void) mCacheMap->DeleteStorage(mapRecord);
        result = kDeleteRecordAndContinue;  // this will REALLY delete the record

    delete clientID;
    delete [] (char *)diskEntry;
    return result;

Here is the call graph for this function:

Member Data Documentation

Definition at line 122 of file nsDiskCacheDevice.cpp.

Definition at line 121 of file nsDiskCacheDevice.cpp.

Definition at line 124 of file nsDiskCacheDevice.cpp.

Definition at line 120 of file nsDiskCacheDevice.cpp.

Definition at line 123 of file nsDiskCacheDevice.cpp.

The documentation for this class was generated from the following file: