зеркало из https://github.com/mozilla/pjs.git
Fix bug 111049 "add attribute to nsICacheSession to detect device availability". sr=darin.
This commit is contained in:
Родитель
b7b8a863cb
Коммит
a69d2f5a62
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче