mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Back out 8d1b087b9713 (bug 707436) for mochitest-ipcplugins leaks
This commit is contained in:
parent
bae5eefc8a
commit
e18a9fe91e
34
netwerk/cache/nsCacheService.cpp
vendored
34
netwerk/cache/nsCacheService.cpp
vendored
@ -75,7 +75,6 @@
|
||||
#include "mozilla/Util.h" // for DebugOnly
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
|
||||
@ -219,20 +218,6 @@ private:
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCacheProfilePrefObserver, nsIObserver)
|
||||
|
||||
class nsSetDiskSmartSizeCallback : public nsITimerCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Notify(nsITimer* aTimer) {
|
||||
nsCacheService::gService->SetDiskSmartSize(true);
|
||||
NS_RELEASE(aTimer);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsSetDiskSmartSizeCallback, nsITimerCallback)
|
||||
|
||||
// Runnable sent to main thread after the cache IO thread calculates available
|
||||
// disk space, so that there is no race in setting mDiskCacheCapacity.
|
||||
class nsSetSmartSizeEvent: public nsRunnable
|
||||
@ -467,7 +452,7 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject,
|
||||
return rv;
|
||||
PRInt32 newCapacity = 0;
|
||||
if (smartSizeEnabled) {
|
||||
nsCacheService::SetDiskSmartSize(false);
|
||||
nsCacheService::SetDiskSmartSize();
|
||||
} else {
|
||||
// Smart sizing switched off: use user specified size
|
||||
rv = branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &newCapacity);
|
||||
@ -1462,19 +1447,8 @@ nsCacheService::CreateDiskDevice()
|
||||
mDiskDevice = nsnull;
|
||||
}
|
||||
|
||||
// Disk device is usually created during the startup. Delay smart size
|
||||
// calculation to avoid possible massive IO caused by eviction of entries
|
||||
// in case the new smart size is smaller than current cache usage.
|
||||
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
SetDiskSmartSize_Locked(true);
|
||||
|
||||
rv = timer->InitWithCallback(new nsSetDiskSmartSizeCallback(), 1000*60*3,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
timer.forget();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2672,13 +2646,13 @@ nsCacheService::OnEnterExitPrivateBrowsing()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCacheService::SetDiskSmartSize(bool checkPref)
|
||||
nsCacheService::SetDiskSmartSize()
|
||||
{
|
||||
nsCacheServiceAutoLock lock;
|
||||
|
||||
if (!gService) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return gService->SetDiskSmartSize_Locked(checkPref);
|
||||
return gService->SetDiskSmartSize_Locked(false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
3
netwerk/cache/nsCacheService.h
vendored
3
netwerk/cache/nsCacheService.h
vendored
@ -182,7 +182,7 @@ public:
|
||||
static void OnEnterExitPrivateBrowsing();
|
||||
|
||||
// Starts smart cache size computation if disk device is available
|
||||
static nsresult SetDiskSmartSize(bool checkPref);
|
||||
static nsresult SetDiskSmartSize();
|
||||
|
||||
nsresult Init();
|
||||
void Shutdown();
|
||||
@ -196,7 +196,6 @@ private:
|
||||
friend class nsProcessRequestEvent;
|
||||
friend class nsSetSmartSizeEvent;
|
||||
friend class nsBlockOnCacheThreadEvent;
|
||||
friend class nsSetDiskSmartSizeCallback;
|
||||
|
||||
/**
|
||||
* Internal Methods
|
||||
|
26
netwerk/cache/nsDiskCacheDevice.cpp
vendored
26
netwerk/cache/nsDiskCacheDevice.cpp
vendored
@ -118,22 +118,6 @@ private:
|
||||
nsDiskCacheBinding *mBinding;
|
||||
};
|
||||
|
||||
class nsEvictDiskCacheEntriesEvent : public nsRunnable {
|
||||
public:
|
||||
nsEvictDiskCacheEntriesEvent(nsDiskCacheDevice *device)
|
||||
: mDevice(device) {}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsCacheServiceAutoLock lock;
|
||||
mDevice->EvictDiskCacheEntries(mDevice->mCacheCapacity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsDiskCacheDevice *mDevice;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* nsDiskCacheEvictor
|
||||
*
|
||||
@ -1136,14 +1120,8 @@ nsDiskCacheDevice::SetCapacity(PRUint32 capacity)
|
||||
// Units are KiB's
|
||||
mCacheCapacity = capacity;
|
||||
if (Initialized()) {
|
||||
if (NS_IsMainThread()) {
|
||||
// Do not evict entries on the main thread
|
||||
nsCacheService::DispatchToCacheIOThread(
|
||||
new nsEvictDiskCacheEntriesEvent(this));
|
||||
} else {
|
||||
// start evicting entries if the new size is smaller!
|
||||
EvictDiskCacheEntries(mCacheCapacity);
|
||||
}
|
||||
// start evicting entries if the new size is smaller!
|
||||
EvictDiskCacheEntries(mCacheCapacity);
|
||||
}
|
||||
// Let cache map know of the new capacity
|
||||
mCacheMap.NotifyCapacityChange(capacity);
|
||||
|
1
netwerk/cache/nsDiskCacheDevice.h
vendored
1
netwerk/cache/nsDiskCacheDevice.h
vendored
@ -107,7 +107,6 @@ public:
|
||||
|
||||
private:
|
||||
friend class nsDiskCacheDeviceDeactivateEntryEvent;
|
||||
friend class nsEvictDiskCacheEntriesEvent;
|
||||
/**
|
||||
* Private methods
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user