зеркало из https://github.com/mozilla/gecko-dev.git
Bug 769291 - Move nsOfflineCacheDevice::Discard() to cache IO thread. r=honzab
Discard() is called from destructor of nsApplicationCache. Instances of nsApplicationCache is released by last reference, it can be in main thread. We move Discard() tasks to cache IO thread to avoid blocking the main thread.
This commit is contained in:
Родитель
d5a4600419
Коммит
68ea4f962a
|
@ -220,6 +220,34 @@ nsOfflineCacheEvictionFunction::Apply()
|
|||
Reset();
|
||||
}
|
||||
|
||||
class nsOfflineCacheDiscardCache : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsOfflineCacheDiscardCache(nsOfflineCacheDevice *device,
|
||||
nsCString &group,
|
||||
nsCString &clientID)
|
||||
: mDevice(device)
|
||||
, mGroup(group)
|
||||
, mClientID(clientID)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
if (mDevice->IsActiveCache(mGroup, mClientID))
|
||||
{
|
||||
mDevice->DeactivateGroup(mGroup);
|
||||
}
|
||||
|
||||
return mDevice->EvictEntries(mClientID.get());
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsOfflineCacheDevice> mDevice;
|
||||
nsCString mGroup;
|
||||
nsCString mClientID;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* nsOfflineCacheDeviceInfo
|
||||
*/
|
||||
|
@ -668,12 +696,10 @@ nsApplicationCache::Discard()
|
|||
|
||||
mValid = false;
|
||||
|
||||
if (mDevice->IsActiveCache(mGroup, mClientID))
|
||||
{
|
||||
mDevice->DeactivateGroup(mGroup);
|
||||
}
|
||||
|
||||
return mDevice->EvictEntries(mClientID.get());
|
||||
nsRefPtr<nsIRunnable> ev =
|
||||
new nsOfflineCacheDiscardCache(mDevice, mGroup, mClientID);
|
||||
nsresult rv = nsCacheService::DispatchToCacheIOThread(ev);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче