Bug 760067 - Release all OfflineCache custom profile files ASAP after custom profile cache update has finished, r=michal
This commit is contained in:
32
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
32
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user