mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
[not part of build] Changed nsCacheEntry data members from PRTime to PRUint32. Changed //** comments to // XXX to make it easier to search for 'to do' items. Added dooming of expired entries.
This commit is contained in:
parent
49b1062eb3
commit
14f776650c
2
netwerk/cache/src/nsCacheDevice.h
vendored
2
netwerk/cache/src/nsCacheDevice.h
vendored
@ -52,7 +52,7 @@ public:
|
||||
|
||||
virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize ) = 0;
|
||||
|
||||
//** need to define methods for enumerating entries
|
||||
// XXX need to define methods for enumerating entries
|
||||
};
|
||||
|
||||
#endif // _nsCacheDevice_h_
|
||||
|
33
netwerk/cache/src/nsCacheEntry.cpp
vendored
33
netwerk/cache/src/nsCacheEntry.cpp
vendored
@ -30,14 +30,19 @@
|
||||
#include "nsError.h"
|
||||
#include "nsICacheService.h"
|
||||
|
||||
#define ONE_YEAR (PR_USEC_PER_SEC * 60 * 60 * 24 * 365)
|
||||
|
||||
// XXX find better place to put this
|
||||
// Convert PRTime to unix-style time_t, i.e. seconds since the epoch
|
||||
PRUint32 ConvertPRTimeToSeconds(PRTime time64);
|
||||
|
||||
|
||||
nsCacheEntry::nsCacheEntry(nsCString * key,
|
||||
PRBool streamBased,
|
||||
nsCacheStoragePolicy storagePolicy)
|
||||
: mKey(key),
|
||||
mFetchCount(0),
|
||||
mLastValidated(LL_ZERO),
|
||||
mExpirationTime(LL_ZERO),
|
||||
mLastValidated(0),
|
||||
mExpirationTime(0),
|
||||
mFlags(0),
|
||||
mDataSize(0),
|
||||
mMetaSize(0),
|
||||
@ -49,7 +54,7 @@ nsCacheEntry::nsCacheEntry(nsCString * key,
|
||||
PR_INIT_CLIST(&mRequestQ);
|
||||
PR_INIT_CLIST(&mDescriptorQ);
|
||||
|
||||
mLastFetched = PR_Now();
|
||||
mLastFetched = ConvertPRTimeToSeconds(PR_Now());
|
||||
|
||||
if (streamBased) MarkStreamBased();
|
||||
|
||||
@ -225,9 +230,9 @@ nsCacheEntry::Open(nsCacheRequest * request, nsICacheEntryDescriptor ** result)
|
||||
} else if (rv == NS_ERROR_CACHE_WAIT_FOR_VALIDATION) {
|
||||
// queue request
|
||||
PR_APPEND_LINK(request->GetListNode(), &mRequestQ);
|
||||
//** allocate PRCondVar for request, if none
|
||||
//** release service lock
|
||||
//** wait until valid or doomed
|
||||
// XXX allocate PRCondVar for request, if none
|
||||
// XXX release service lock
|
||||
// XXX wait until valid or doomed
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -244,11 +249,11 @@ nsCacheEntry::AsyncOpen(nsCacheRequest * request)
|
||||
nsICacheEntryDescriptor * descriptor;
|
||||
rv = nsCacheEntryDescriptor::Create(this, accessGranted, &descriptor);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
//** queue the descriptor
|
||||
//** post event to call listener with
|
||||
// XXX queue the descriptor
|
||||
// XXX post event to call listener with
|
||||
}
|
||||
} else if (rv == NS_ERROR_CACHE_WAIT_FOR_VALIDATION) {
|
||||
//** queue request and we're done (MarkValid will notify pending requests)
|
||||
// XXX queue request and we're done (MarkValid will notify pending requests)
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -257,7 +262,7 @@ nsCacheEntry::AsyncOpen(nsCacheRequest * request)
|
||||
PRBool
|
||||
nsCacheEntry::RemoveRequest(nsCacheRequest * request)
|
||||
{
|
||||
//** if debug: verify this request belongs to this entry
|
||||
// XXX if debug: verify this request belongs to this entry
|
||||
PR_REMOVE_AND_INIT_LINK(request->GetListNode());
|
||||
|
||||
// return true if this entry should stay active
|
||||
@ -269,7 +274,7 @@ nsCacheEntry::RemoveRequest(nsCacheRequest * request)
|
||||
PRBool
|
||||
nsCacheEntry::RemoveDescriptor(nsCacheEntryDescriptor * descriptor)
|
||||
{
|
||||
//** if debug: verify this descriptor belongs to this entry
|
||||
// XXX if debug: verify this descriptor belongs to this entry
|
||||
PR_REMOVE_AND_INIT_LINK(descriptor->GetListNode());
|
||||
|
||||
if (!PR_CLIST_IS_EMPTY(&mDescriptorQ))
|
||||
@ -278,7 +283,7 @@ nsCacheEntry::RemoveDescriptor(nsCacheEntryDescriptor * descriptor)
|
||||
if (PR_CLIST_IS_EMPTY(&mRequestQ))
|
||||
return PR_FALSE; // no descriptors or requests, we can deactivate
|
||||
|
||||
//** find next best request to give a descriptor to
|
||||
// XXX find next best request to give a descriptor to
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@ -363,7 +368,7 @@ nsCacheEntryHashTable::RemoveEntry( nsCacheEntry *cacheEntry)
|
||||
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
|
||||
if (!cacheEntry) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//** debug code to make sure we have the entry we're trying to remove
|
||||
// XXX debug code to make sure we have the entry we're trying to remove
|
||||
|
||||
(void) PL_DHashTableOperate(&table, cacheEntry->mKey, PL_DHASH_REMOVE);
|
||||
return NS_OK;
|
||||
|
36
netwerk/cache/src/nsCacheEntry.h
vendored
36
netwerk/cache/src/nsCacheEntry.h
vendored
@ -59,23 +59,23 @@ public:
|
||||
|
||||
nsCString * Key(void) { return mKey; }
|
||||
|
||||
PRInt32 FetchCount(void) { return mFetchCount;}
|
||||
void SetFetchCount( PRInt32 count) { mFetchCount = count;}
|
||||
PRInt32 FetchCount(void) { return mFetchCount;}
|
||||
void SetFetchCount( PRInt32 count) { mFetchCount = count;}
|
||||
|
||||
PRTime LastFetched(void) { return mLastFetched;}
|
||||
void SetLastFetched( PRTime lastFetched) { mLastFetched = lastFetched;}
|
||||
PRUint32 LastFetched(void) { return mLastFetched;}
|
||||
void SetLastFetched( PRUint32 lastFetched) { mLastFetched = lastFetched;}
|
||||
|
||||
PRTime LastValidated(void) { return mLastValidated;}
|
||||
void SetLastValidated( PRTime lastValidated) { mLastValidated = lastValidated;}
|
||||
PRUint32 LastValidated(void) { return mLastValidated;}
|
||||
void SetLastValidated( PRUint32 lastValidated) { mLastValidated = lastValidated;}
|
||||
|
||||
PRTime ExpirationTime(void) { return mExpirationTime;}
|
||||
void SetExpirationTime( PRTime expires) { mExpirationTime = expires;}
|
||||
PRUint32 ExpirationTime(void) { return mExpirationTime;}
|
||||
void SetExpirationTime( PRUint32 expires) { mExpirationTime = expires;}
|
||||
|
||||
PRUint32 DataSize(void) { return mDataSize;}
|
||||
void SetDataSize( PRUint32 size) { mDataSize = size;}
|
||||
PRUint32 DataSize(void) { return mDataSize;}
|
||||
void SetDataSize( PRUint32 size) { mDataSize = size;}
|
||||
|
||||
PRUint32 MetaDataSize(void) { return mMetaSize;}
|
||||
void SetMetaDataSize( PRUint32 size) { mMetaSize = size;}
|
||||
PRUint32 MetaDataSize(void) { return mMetaSize;}
|
||||
void SetMetaDataSize( PRUint32 size) { mMetaSize = size;}
|
||||
|
||||
nsCacheDevice * CacheDevice(void) { return mCacheDevice;}
|
||||
void SetCacheDevice( nsCacheDevice * device) { mCacheDevice = device;}
|
||||
@ -91,7 +91,7 @@ public:
|
||||
nsresult FlattenMetaData(char ** data, PRUint32 * size);
|
||||
nsresult UnflattenMetaData(char * data, PRUint32 size);
|
||||
|
||||
//** enumerate MetaData method
|
||||
// XXX enumerate MetaData method
|
||||
|
||||
|
||||
enum CacheEntryFlags {
|
||||
@ -161,11 +161,11 @@ private:
|
||||
void MarkInactive() { mFlags &= ~eActiveMask; }
|
||||
|
||||
PRCList mListLink; // 8 for holding entry on various lists
|
||||
nsCString * mKey; // 4 //** ask scc about const'ness
|
||||
nsCString * mKey; // 4 // XXX ask scc about const'ness
|
||||
PRUint32 mFetchCount; // 4
|
||||
PRTime mLastFetched; // 8
|
||||
PRTime mLastValidated; // 8
|
||||
PRTime mExpirationTime; // 8
|
||||
PRUint32 mLastFetched; // 8
|
||||
PRUint32 mLastValidated; // 8
|
||||
PRUint32 mExpirationTime; // 8
|
||||
PRUint32 mFlags; // 4
|
||||
PRUint32 mDataSize; // 4
|
||||
PRUint32 mMetaSize; // 4
|
||||
@ -194,7 +194,7 @@ public:
|
||||
nsCacheEntry *GetEntry( const nsCString * key);
|
||||
nsresult AddEntry( nsCacheEntry *entry);
|
||||
nsresult RemoveEntry( nsCacheEntry *entry);
|
||||
//** enumerate entries?
|
||||
// XXX enumerate entries?
|
||||
|
||||
private:
|
||||
|
||||
|
18
netwerk/cache/src/nsCacheEntryDescriptor.cpp
vendored
18
netwerk/cache/src/nsCacheEntryDescriptor.cpp
vendored
@ -114,7 +114,7 @@ nsCacheEntryDescriptor::GetLastFetched(PRTime *result)
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->LastFetched();
|
||||
*result = ConvertSecondsToPRTime(mCacheEntry->LastFetched());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ nsCacheEntryDescriptor::GetLastValidated(PRTime *result)
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->LastValidated();
|
||||
*result = ConvertSecondsToPRTime(mCacheEntry->LastValidated());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ nsCacheEntryDescriptor::GetExpirationTime(PRTime *result)
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->ExpirationTime();
|
||||
*result = ConvertSecondsToPRTime(mCacheEntry->ExpirationTime());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ nsCacheEntryDescriptor::SetExpirationTime(PRTime expirationTime)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
mCacheEntry->SetExpirationTime(expirationTime);
|
||||
mCacheEntry->SetExpirationTime(ConvertPRTimeToSeconds(expirationTime));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::IsStreamBased(PRBool *result)
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->IsStreamData(); //** which name is better?
|
||||
*result = mCacheEntry->IsStreamData(); // XXX which name is better?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ nsCacheEntryDescriptor::RequestDataSizeChange(PRInt32 deltaSize)
|
||||
nsresult rv;
|
||||
rv = nsCacheService::GlobalInstance()->OnDataSizeChange(mCacheEntry, deltaSize);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
//** review for signed/unsigned math errors
|
||||
// XXX review for signed/unsigned math errors
|
||||
PRUint32 newDataSize = mCacheEntry->DataSize() + deltaSize;
|
||||
mCacheEntry->SetDataSize(newDataSize);
|
||||
}
|
||||
@ -190,7 +190,7 @@ nsCacheEntryDescriptor::SetDataSize(PRUint32 dataSize)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
//** review for signed/unsigned math errors
|
||||
// XXX review for signed/unsigned math errors
|
||||
PRInt32 deltaSize = dataSize - mCacheEntry->DataSize();
|
||||
|
||||
// this had better be NS_OK, this call instance is advisory
|
||||
@ -328,7 +328,7 @@ nsCacheEntryDescriptor::SetMetaDataElement(const char *key, const char *value)
|
||||
|
||||
if (!key) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//** allow null value, for clearing key?
|
||||
// XXX allow null value, for clearing key?
|
||||
nsresult rv = mCacheEntry->SetMetaDataElement(nsLiteralCString(key),
|
||||
nsLiteralCString(value));
|
||||
return rv;
|
||||
@ -483,7 +483,7 @@ nsCacheOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, PRUi
|
||||
nsresult
|
||||
nsCacheOutputStream::OnWrite(PRUint32 count)
|
||||
{
|
||||
//** if count > 2^31 error_write_too_big
|
||||
// XXX if count > 2^31 error_write_too_big
|
||||
return mDescriptor->RequestDataSizeChange((PRInt32)count);
|
||||
|
||||
#if 0
|
||||
|
15
netwerk/cache/src/nsCacheMetaData.cpp
vendored
15
netwerk/cache/src/nsCacheMetaData.cpp
vendored
@ -50,7 +50,6 @@ nsCacheMetaData::nsCacheMetaData()
|
||||
|
||||
nsCacheMetaData::~nsCacheMetaData()
|
||||
{
|
||||
//** maybe we should finalize the table...
|
||||
PL_DHashTableFinish(&table);
|
||||
}
|
||||
|
||||
@ -90,8 +89,8 @@ nsCacheMetaData::GetElement(const nsAReadableCString * key)
|
||||
PLDHashEntryHdr * hashEntry;
|
||||
nsCString * result = nsnull;
|
||||
|
||||
//** need to copy string until we have scc's new flat string abstract class
|
||||
//** see nsCacheMetaData::HashKey below (bug 70075)
|
||||
// XXX need to copy string until we have scc's new flat string abstract class
|
||||
// XXX see nsCacheMetaData::HashKey below (bug 70075)
|
||||
nsCString * tempKey = new nsCString(*key);
|
||||
if (!tempKey) return result;
|
||||
|
||||
@ -114,12 +113,12 @@ nsCacheMetaData::SetElement(const nsAReadableCString& key,
|
||||
|
||||
NS_ASSERTION(initialized, "nsCacheMetaDataHashTable not initialized");
|
||||
|
||||
//** need to copy string until we have scc's new flat string abstract class
|
||||
//** see nsCacheMetaData::HashKey below (bug 70075)
|
||||
// XXX need to copy string until we have scc's new flat string abstract class
|
||||
// XXX see nsCacheMetaData::HashKey below (bug 70075)
|
||||
nsCString * tempKey = new nsCString(key);
|
||||
if (!tempKey) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
//** should empty value remove the key?
|
||||
// XXX should empty value remove the key?
|
||||
|
||||
metaEntry = (nsCacheMetaDataHashTableEntry *)
|
||||
PL_DHashTableOperate(&table, tempKey, PL_DHASH_ADD);
|
||||
@ -135,7 +134,7 @@ nsCacheMetaData::SetElement(const nsAReadableCString& key,
|
||||
|
||||
metaEntry->value = new nsCString(value);
|
||||
if (metaEntry->value == nsnull) {
|
||||
//** remove key?
|
||||
// XXX remove key?
|
||||
delete tempKey;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -195,7 +194,7 @@ nsCacheMetaData::GetKey( PLDHashTable * /* table */, PLDHashEntryHdr *hashEntry)
|
||||
PLDHashNumber
|
||||
nsCacheMetaData::HashKey( PLDHashTable * table, const void *key)
|
||||
{
|
||||
//** need scc's new flat string abstract class here (bug 70075)
|
||||
// XXX need scc's new flat string abstract class here (bug 70075)
|
||||
return PL_DHashStringKey(table, ((nsCString *)key)->get());
|
||||
}
|
||||
|
||||
|
6
netwerk/cache/src/nsCacheRequest.h
vendored
6
netwerk/cache/src/nsCacheRequest.h
vendored
@ -53,10 +53,10 @@ private:
|
||||
PR_INIT_CLIST(&mListLink);
|
||||
}
|
||||
|
||||
virtual ~nsCacheRequest()
|
||||
~nsCacheRequest()
|
||||
{
|
||||
// delete mKey;
|
||||
// XXX need to do anything with mListLink?
|
||||
delete mKey;
|
||||
NS_ASSERTION(PR_CLIST_IS_EMPTY(&mListLink), "request still on a list");
|
||||
}
|
||||
|
||||
|
||||
|
64
netwerk/cache/src/nsCacheService.cpp
vendored
64
netwerk/cache/src/nsCacheService.cpp
vendored
@ -112,9 +112,9 @@ nsCacheService::Shutdown()
|
||||
"can't shutdown nsCacheService unless it has been initialized.");
|
||||
|
||||
if (mCacheServiceLock) {
|
||||
//** check for pending requests...
|
||||
// XXX check for pending requests...
|
||||
|
||||
//** finalize active entries
|
||||
// XXX finalize active entries
|
||||
|
||||
// deallocate memory and disk caches
|
||||
delete mMemoryDevice;
|
||||
@ -221,12 +221,12 @@ nsCacheService::OpenCacheEntry(nsCacheSession * session,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (1) {
|
||||
//** acquire lock
|
||||
// XXX acquire lock
|
||||
rv = ActivateEntry(request, &entry);
|
||||
if (NS_FAILED(rv)) break;
|
||||
//** check for NS_ERROR_CACHE_KEY_NOT_FOUND & READ-ONLY request
|
||||
// XXX check for NS_ERROR_CACHE_KEY_NOT_FOUND & READ-ONLY request
|
||||
|
||||
rv = entry->Open(request, result); //** release lock before waiting on request
|
||||
rv = entry->Open(request, result); // XXX release lock before waiting on request
|
||||
if (rv != NS_ERROR_CACHE_ENTRY_DOOMED) break;
|
||||
|
||||
}
|
||||
@ -250,10 +250,10 @@ nsCacheService::AsyncOpenCacheEntry(nsCacheSession * session,
|
||||
|
||||
nsresult rv = CreateRequest(session, key, accessRequested, listener, &request);
|
||||
|
||||
//** acquire service lock PR_Lock(mCacheServiceLock);
|
||||
// XXX acquire service lock PR_Lock(mCacheServiceLock);
|
||||
rv = ActivateEntry(request, &entry);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
entry->AsyncOpen(request); //** release lock after request queued, etc.
|
||||
entry->AsyncOpen(request); // XXX release lock after request queued, etc.
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -286,11 +286,16 @@ nsCacheService::ActivateEntry(nsCacheRequest * request,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (entry && (request->mAccessRequested == nsICache::ACCESS_WRITE)) {
|
||||
// this is FORCE-WRITE request
|
||||
if (entry &&
|
||||
((request->mAccessRequested == nsICache::ACCESS_WRITE) ||
|
||||
(entry->mExpirationTime &&
|
||||
entry->mExpirationTime < ConvertPRTimeToSeconds(PR_Now()))))
|
||||
// XXX beginning to look a lot like lisp
|
||||
{
|
||||
// this is FORCE-WRITE request or the entry has expired
|
||||
rv = DoomEntry_Internal(entry);
|
||||
if (NS_FAILED(rv)) {
|
||||
//** what to do?
|
||||
// XXX what to do? Increment FailedDooms counter?
|
||||
}
|
||||
|
||||
if (entry->IsNotInUse()) {
|
||||
@ -306,7 +311,7 @@ nsCacheService::ActivateEntry(nsCacheRequest * request,
|
||||
if (!entry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
//** we could perform an early bind in some cases based on storage policy
|
||||
// XXX we could perform an early bind in some cases based on storage policy
|
||||
}
|
||||
|
||||
rv = mActiveEntries.AddEntry(entry);
|
||||
@ -319,7 +324,7 @@ nsCacheService::ActivateEntry(nsCacheRequest * request,
|
||||
error:
|
||||
*result = nsnull;
|
||||
if (entry) {
|
||||
//** clean up
|
||||
// XXX clean up
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -368,8 +373,8 @@ nsCacheService::BindEntry(nsCacheEntry * entry)
|
||||
nsresult
|
||||
nsCacheService::ValidateEntry(nsCacheEntry * entry)
|
||||
{
|
||||
//** bind if not bound
|
||||
//** convert pending requests to descriptors, etc.
|
||||
// XXX bind if not bound
|
||||
// XXX convert pending requests to descriptors, etc.
|
||||
entry->MarkValid();
|
||||
return NS_OK;
|
||||
}
|
||||
@ -394,7 +399,7 @@ nsCacheService::DoomEntry_Internal(nsCacheEntry * entry)
|
||||
nsCacheDevice * device = entry->CacheDevice();
|
||||
if (device) {
|
||||
rv = device->DoomEntry(entry);
|
||||
//** check rv, but what can we really do...
|
||||
// XXX check rv, but what can we really do...
|
||||
}
|
||||
|
||||
if (entry->IsActive()) {
|
||||
@ -402,7 +407,7 @@ nsCacheService::DoomEntry_Internal(nsCacheEntry * entry)
|
||||
rv = mActiveEntries.RemoveEntry(entry);
|
||||
entry->MarkInactive();
|
||||
if (NS_FAILED(rv)) {
|
||||
//** what to do
|
||||
// XXX what to do
|
||||
}
|
||||
}
|
||||
// put on doom list to wait for descriptors to close
|
||||
@ -497,3 +502,30 @@ nsCacheService::DeactivateEntry(nsCacheEntry * entry)
|
||||
delete entry; // because no one else will
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache Service Utility Functions
|
||||
*/
|
||||
|
||||
// time conversion utils from nsCachedNetData.cpp
|
||||
// Convert PRTime to unix-style time_t, i.e. seconds since the epoch
|
||||
PRUint32
|
||||
ConvertPRTimeToSeconds(PRTime time64)
|
||||
{
|
||||
double fpTime;
|
||||
LL_L2D(fpTime, time64);
|
||||
return (PRUint32)(fpTime * 1e-6 + 0.5);
|
||||
}
|
||||
|
||||
|
||||
// Convert unix-style time_t, i.e. seconds since the epoch, to PRTime
|
||||
PRTime
|
||||
ConvertSecondsToPRTime(PRUint32 seconds)
|
||||
{
|
||||
PRInt64 t64;
|
||||
LL_I2L(t64, seconds);
|
||||
PRInt64 mil;
|
||||
LL_I2L(mil, 1000000);
|
||||
LL_MUL(t64, t64, mil);
|
||||
return t64;
|
||||
}
|
||||
|
12
netwerk/cache/src/nsCacheService.h
vendored
12
netwerk/cache/src/nsCacheService.h
vendored
@ -137,4 +137,16 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Cache Service Utility Functions
|
||||
*/
|
||||
|
||||
// time conversion utils from nsCachedNetData.cpp
|
||||
|
||||
// Convert PRTime to unix-style time_t, i.e. seconds since the epoch
|
||||
PRUint32 ConvertPRTimeToSeconds(PRTime time64);
|
||||
|
||||
// Convert unix-style time_t, i.e. seconds since the epoch, to PRTime
|
||||
PRTime ConvertSecondsToPRTime(PRUint32 seconds);
|
||||
|
||||
#endif // _nsCacheService_h_
|
||||
|
13
netwerk/cache/src/nsDiskCacheDevice.cpp
vendored
13
netwerk/cache/src/nsDiskCacheDevice.cpp
vendored
@ -148,6 +148,8 @@ private:
|
||||
};
|
||||
NS_IMPL_ISUPPORTS0(DiskCacheEntry);
|
||||
|
||||
#if 0
|
||||
// get rid of warning on linux until this routine is used.
|
||||
static DiskCacheEntry*
|
||||
getDiskCacheEntry(nsCacheEntry * entry)
|
||||
{
|
||||
@ -155,6 +157,7 @@ getDiskCacheEntry(nsCacheEntry * entry)
|
||||
entry->GetData(getter_AddRefs(data));
|
||||
return (DiskCacheEntry*) data.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
static DiskCacheEntry*
|
||||
ensureDiskCacheEntry(nsCacheEntry * entry)
|
||||
@ -240,7 +243,7 @@ nsDiskCacheDevice::FindEntry(nsCString * key)
|
||||
}
|
||||
}
|
||||
|
||||
//** find eviction element and move it to the tail of the queue
|
||||
// XXX find eviction element and move it to the tail of the queue
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -428,9 +431,9 @@ nsresult nsDiskCacheDevice::scanEntries()
|
||||
struct MetaDataHeader {
|
||||
PRUint32 mHeaderSize;
|
||||
PRInt32 mFetchCount;
|
||||
PRTime mLastFetched;
|
||||
PRTime mLastValidated; // NOT NEEDED
|
||||
PRTime mExpirationTime;
|
||||
PRUint32 mLastFetched;
|
||||
PRUint32 mLastValidated; // NOT NEEDED
|
||||
PRUint32 mExpirationTime;
|
||||
PRUint32 mDataSize;
|
||||
PRUint32 mKeySize;
|
||||
PRUint32 mMetaDataSize;
|
||||
@ -714,4 +717,4 @@ nsresult nsDiskCacheDevice::deleteDiskCacheEntry(nsCacheEntry* entry)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//** need methods for enumerating entries
|
||||
// XXX need methods for enumerating entries
|
||||
|
14
netwerk/cache/src/nsMemoryCacheDevice.cpp
vendored
14
netwerk/cache/src/nsMemoryCacheDevice.cpp
vendored
@ -36,7 +36,7 @@ nsMemoryCacheDevice::nsMemoryCacheDevice()
|
||||
|
||||
nsMemoryCacheDevice::~nsMemoryCacheDevice()
|
||||
{
|
||||
//** dealloc all memory
|
||||
// XXX dealloc all memory
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ nsMemoryCacheDevice::Init()
|
||||
|
||||
rv = mMemCacheEntries.Init();
|
||||
|
||||
//** read user prefs for memory cache limits
|
||||
// XXX read user prefs for memory cache limits
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -79,7 +79,7 @@ nsMemoryCacheDevice::DeactivateEntry(nsCacheEntry * entry)
|
||||
{
|
||||
if (entry->IsDoomed()) {
|
||||
#if debug
|
||||
//** verify we've removed it from mMemCacheEntries & eviction list
|
||||
// XXX verify we've removed it from mMemCacheEntries & eviction list
|
||||
#endif
|
||||
delete entry;
|
||||
return NS_OK;
|
||||
@ -110,7 +110,7 @@ nsMemoryCacheDevice::BindEntry(nsCacheEntry * entry)
|
||||
return rv;
|
||||
}
|
||||
|
||||
//** add size of entry to memory totals
|
||||
// XXX add size of entry to memory totals
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -161,11 +161,11 @@ nsMemoryCacheDevice::GetTransportForEntry( nsCacheEntry * entry,
|
||||
nsresult
|
||||
nsMemoryCacheDevice::OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize)
|
||||
{
|
||||
//** keep track of totals
|
||||
// XXX keep track of totals
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//** need methods for enumerating entries
|
||||
// XXX need methods for enumerating entries
|
||||
|
||||
|
||||
//** check entry->IsInUse() before evicting.
|
||||
// XXX check entry->IsInUse() before evicting.
|
||||
|
2
netwerk/cache/src/nsMemoryCacheDevice.h
vendored
2
netwerk/cache/src/nsMemoryCacheDevice.h
vendored
@ -59,7 +59,7 @@ private:
|
||||
|
||||
PRCList mEvictionList;
|
||||
|
||||
//** what other stats do we want to keep?
|
||||
// XXX what other stats do we want to keep?
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user