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-10 23:49:17 +02:00
parent fbf51f61db
commit 3ac135b59e
5 changed files with 67 additions and 1 deletions

View File

@@ -657,6 +657,10 @@ nsApplicationCache::Activate()
NS_ENSURE_TRUE(mDevice, NS_ERROR_NOT_AVAILABLE);
mDevice->ActivateCache(mGroup, mClientID);
if (mDevice->AutoShutdown(this))
mDevice = nsnull;
return NS_OK;
}
@@ -673,7 +677,12 @@ nsApplicationCache::Discard()
mDevice->DeactivateGroup(mGroup);
}
return mDevice->EvictEntries(mClientID.get());
nsresult rv = mDevice->EvictEntries(mClientID.get());
if (mDevice->AutoShutdown(this))
mDevice = nsnull;
return rv;
}
NS_IMETHODIMP
@@ -804,6 +813,7 @@ nsOfflineCacheDevice::nsOfflineCacheDevice()
: mDB(nsnull)
, mCacheCapacity(0)
, mDeltaCounter(0)
, mAutoShutdown(false)
{
}
@@ -2392,3 +2402,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;
}