mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 419036 - "Simplify nsCacheEntryHashTable::VisitEntries and break 'friendship'" [p=alfredkayser@gmail.com (Alfred Kayser) r=dcamp sr=biesi a1.9=damons]
This commit is contained in:
parent
74d8a4f62e
commit
fc7cc13805
15
netwerk/cache/src/nsCacheEntry.cpp
vendored
15
netwerk/cache/src/nsCacheEntry.cpp
vendored
@ -488,25 +488,14 @@ nsCacheEntryHashTable::RemoveEntry( nsCacheEntry *cacheEntry)
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntryHashTable::VisitEntries( nsCacheEntryHashTable::Visitor *visitor)
|
||||
nsCacheEntryHashTable::VisitEntries( PLDHashEnumerator etor, void *arg)
|
||||
{
|
||||
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
|
||||
if (!initialized) return; // NS_ERROR_NOT_INITIALIZED
|
||||
PL_DHashTableEnumerate(&table, VisitEntry, visitor);
|
||||
PL_DHashTableEnumerate(&table, etor, arg);
|
||||
}
|
||||
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheEntryHashTable::VisitEntry(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hashEntry,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
nsCacheEntry *cacheEntry = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
|
||||
nsCacheEntryHashTable::Visitor *visitor = (nsCacheEntryHashTable::Visitor*) arg;
|
||||
return (visitor->VisitEntry(cacheEntry) ? PL_DHASH_NEXT : PL_DHASH_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* hash table operation callback functions
|
||||
*/
|
||||
|
12
netwerk/cache/src/nsCacheEntry.h
vendored
12
netwerk/cache/src/nsCacheEntry.h
vendored
@ -295,17 +295,9 @@ public:
|
||||
nsresult AddEntry( nsCacheEntry *entry);
|
||||
void RemoveEntry( nsCacheEntry *entry);
|
||||
|
||||
// XXX enumerate entries?
|
||||
class Visitor {
|
||||
public:
|
||||
virtual PRBool VisitEntry( nsCacheEntry *entry) = 0;
|
||||
};
|
||||
|
||||
void VisitEntries( Visitor *visitor);
|
||||
|
||||
private:
|
||||
friend class nsCacheService; // XXX redefine interface so this isn't necessary
|
||||
void VisitEntries( PLDHashEnumerator etor, void *arg);
|
||||
|
||||
private:
|
||||
// PLDHashTable operation callbacks
|
||||
static PLDHashNumber PR_CALLBACK HashKey( PLDHashTable *table, const void *key);
|
||||
|
||||
|
5
netwerk/cache/src/nsCacheService.cpp
vendored
5
netwerk/cache/src/nsCacheService.cpp
vendored
@ -2139,8 +2139,7 @@ nsCacheService::ClearDoomList()
|
||||
void
|
||||
nsCacheService::ClearActiveEntries()
|
||||
{
|
||||
// XXX really we want a different finalize callback for mActiveEntries
|
||||
PL_DHashTableEnumerate(&mActiveEntries.table, DeactivateAndClearEntry, nsnull);
|
||||
mActiveEntries.VisitEntries(DeactivateAndClearEntry, nsnull);
|
||||
mActiveEntries.Shutdown();
|
||||
}
|
||||
|
||||
@ -2168,7 +2167,7 @@ nsCacheService::DoomActiveEntries()
|
||||
{
|
||||
nsAutoVoidArray array;
|
||||
|
||||
PL_DHashTableEnumerate(&mActiveEntries.table, RemoveActiveEntry, &array);
|
||||
mActiveEntries.VisitEntries(RemoveActiveEntry, &array);
|
||||
|
||||
PRUint32 count = array.Count();
|
||||
for (PRUint32 i=0; i < count; ++i)
|
||||
|
24
netwerk/cache/src/nsMemoryCacheDevice.cpp
vendored
24
netwerk/cache/src/nsMemoryCacheDevice.cpp
vendored
@ -472,22 +472,14 @@ nsMemoryCacheDevice::SetCapacity(PRInt32 capacity)
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
class nsCacheHashCounter : public nsCacheEntryHashTable::Visitor {
|
||||
public:
|
||||
nsCacheHashCounter() : entryCount(0) {}
|
||||
|
||||
PRBool VisitEntry(nsCacheEntry * entry);
|
||||
PRInt32 entryCount;
|
||||
};
|
||||
|
||||
|
||||
PRBool nsCacheHashCounter::VisitEntry(nsCacheEntry * entry)
|
||||
static PLDHashOperator PR_CALLBACK
|
||||
CountEntry(PLDHashTable * table, PLDHashEntryHdr * hdr, PRUint32 number, void * arg)
|
||||
{
|
||||
++entryCount;
|
||||
return PR_TRUE;
|
||||
PRInt32 *entryCount = (PRInt32 *)arg;
|
||||
++(*entryCount);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsMemoryCacheDevice::CheckEntryCount()
|
||||
{
|
||||
@ -503,9 +495,9 @@ nsMemoryCacheDevice::CheckEntryCount()
|
||||
}
|
||||
NS_ASSERTION(mEntryCount == evictionListCount, "### mem cache badness");
|
||||
|
||||
nsCacheHashCounter hash;
|
||||
mMemCacheEntries.VisitEntries(&hash);
|
||||
NS_ASSERTION(mEntryCount == hash.entryCount, "### mem cache badness");
|
||||
PRInt32 entryCount = 0;
|
||||
mMemCacheEntries.VisitEntries(CountEntry, &entryCount);
|
||||
NS_ASSERTION(mEntryCount == entryCount, "### mem cache badness");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user