Fix bug 111049 "add attribute to nsICacheSession to detect device availability". sr=darin.

This commit is contained in:
gordon%netscape.com 2002-01-24 01:25:25 +00:00
Родитель b7b8a863cb
Коммит a69d2f5a62
4 изменённых файлов: 42 добавлений и 0 удалений

6
netwerk/cache/public/nsICacheSession.idl поставляемый
Просмотреть файл

@ -71,4 +71,10 @@ interface nsICacheSession : nsISupports
* Evict all entries for this session's clientID according to its storagePolicy. * Evict all entries for this session's clientID according to its storagePolicy.
*/ */
void evictEntries(); void evictEntries();
/**
* Return whether any of the cache devices implied by the session storage policy
* are currently enabled for instantiation if they don't already exist.
*/
PRBool isStorageEnabled();
}; };

25
netwerk/cache/src/nsCacheService.cpp поставляемый
Просмотреть файл

@ -555,6 +555,31 @@ nsCacheService::EvictEntriesForClient(const char * clientID,
} }
nsresult
nsCacheService::IsStorageEnabledForPolicy(nsCacheStoragePolicy storagePolicy,
PRBool * result)
{
if (gService == nsnull) return NS_ERROR_NOT_AVAILABLE;
nsAutoLock lock(gService->mCacheServiceLock);
if (gService->mEnableMemoryDevice &&
(storagePolicy == nsICache::STORE_ANYWHERE ||
storagePolicy == nsICache::STORE_IN_MEMORY)) {
*result = PR_TRUE;
}
else if (gService->mEnableDiskDevice &&
(storagePolicy == nsICache::STORE_ANYWHERE ||
storagePolicy == nsICache::STORE_ON_DISK ||
storagePolicy == nsICache::STORE_ON_DISK_AS_FILE)) {
*result = PR_TRUE;
} else {
*result = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor) NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor)
{ {
nsAutoLock lock(mCacheServiceLock); nsAutoLock lock(mCacheServiceLock);

3
netwerk/cache/src/nsCacheService.h поставляемый
Просмотреть файл

@ -77,6 +77,9 @@ public:
nsresult EvictEntriesForClient(const char * clientID, nsresult EvictEntriesForClient(const char * clientID,
nsCacheStoragePolicy storagePolicy); nsCacheStoragePolicy storagePolicy);
static nsresult IsStorageEnabledForPolicy(nsCacheStoragePolicy storagePolicy,
PRBool * result);
/** /**
* Methods called by nsCacheEntryDescriptor * Methods called by nsCacheEntryDescriptor
*/ */

8
netwerk/cache/src/nsCacheSession.cpp поставляемый
Просмотреть файл

@ -104,3 +104,11 @@ NS_IMETHODIMP nsCacheSession::EvictEntries()
{ {
return nsCacheService::GlobalInstance()->EvictEntriesForSession(this); return nsCacheService::GlobalInstance()->EvictEntriesForSession(this);
} }
NS_IMETHODIMP nsCacheSession::IsStorageEnabled(PRBool *result)
{
return nsCacheService::IsStorageEnabledForPolicy(StoragePolicy(), result);
}