mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Fix bug 111049 "add attribute to nsICacheSession to detect device availability". sr=darin.
This commit is contained in:
parent
efd43a6ced
commit
b032cdadb8
6
netwerk/cache/public/nsICacheSession.idl
vendored
6
netwerk/cache/public/nsICacheSession.idl
vendored
@ -71,4 +71,10 @@ interface nsICacheSession : nsISupports
|
||||
* Evict all entries for this session's clientID according to its storagePolicy.
|
||||
*/
|
||||
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
vendored
25
netwerk/cache/src/nsCacheService.cpp
vendored
@ -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)
|
||||
{
|
||||
nsAutoLock lock(mCacheServiceLock);
|
||||
|
3
netwerk/cache/src/nsCacheService.h
vendored
3
netwerk/cache/src/nsCacheService.h
vendored
@ -77,6 +77,9 @@ public:
|
||||
nsresult EvictEntriesForClient(const char * clientID,
|
||||
nsCacheStoragePolicy storagePolicy);
|
||||
|
||||
static nsresult IsStorageEnabledForPolicy(nsCacheStoragePolicy storagePolicy,
|
||||
PRBool * result);
|
||||
|
||||
/**
|
||||
* Methods called by nsCacheEntryDescriptor
|
||||
*/
|
||||
|
8
netwerk/cache/src/nsCacheSession.cpp
vendored
8
netwerk/cache/src/nsCacheSession.cpp
vendored
@ -104,3 +104,11 @@ NS_IMETHODIMP nsCacheSession::EvictEntries()
|
||||
{
|
||||
return nsCacheService::GlobalInstance()->EvictEntriesForSession(this);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::IsStorageEnabled(PRBool *result)
|
||||
{
|
||||
|
||||
return nsCacheService::IsStorageEnabledForPolicy(StoragePolicy(), result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user