Bug 760067 - Release all OfflineCache custom profile files ASAP after custom profile cache update has finished, r=michal

This commit is contained in:
Honza Bambas
2012-07-11 20:20:17 +02:00
parent 52c6aa229f
commit ccbac4dff5
6 changed files with 69 additions and 4 deletions

View File

@@ -685,6 +685,10 @@ nsApplicationCache::Activate()
NS_ENSURE_TRUE(mDevice, NS_ERROR_NOT_AVAILABLE);
mDevice->ActivateCache(mGroup, mClientID);
if (mDevice->AutoShutdown(this))
mDevice = nsnull;
return NS_OK;
}
@@ -830,6 +834,7 @@ nsOfflineCacheDevice::nsOfflineCacheDevice()
: mDB(nsnull)
, mCacheCapacity(0)
, mDeltaCounter(0)
, mAutoShutdown(false)
{
}
@@ -2418,3 +2423,23 @@ nsOfflineCacheDevice::SetCapacity(PRUint32 capacity)
{
mCacheCapacity = capacity * 1024;
}
bool
nsOfflineCacheDevice::AutoShutdown(nsIApplicationCache * aAppCache)
{
if (!mAutoShutdown)
return false;
mAutoShutdown = false;
Shutdown();
nsRefPtr<nsCacheService> cacheService = nsCacheService::GlobalInstance();
cacheService->RemoveCustomOfflineDevice(this);
nsCAutoString clientID;
aAppCache->GetClientID(clientID);
mCaches.Remove(clientID);
return true;
}