зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1126739 - Add locking to SurfaceCache entry points that bypass the public API. r=tn CLOSED TREE a=KWierso
--HG-- extra : rebase_source : 88cf49ab4ccf6949a11b78d2a3c8518a55fa852d
This commit is contained in:
Родитель
60707d7dcf
Коммит
ada986b250
|
@ -362,7 +362,7 @@ public:
|
|||
SurfaceCacheImpl(uint32_t aSurfaceCacheExpirationTimeMS,
|
||||
uint32_t aSurfaceCacheDiscardFactor,
|
||||
uint32_t aSurfaceCacheSize)
|
||||
: mExpirationTracker(this, aSurfaceCacheExpirationTimeMS)
|
||||
: mExpirationTracker(aSurfaceCacheExpirationTimeMS)
|
||||
, mMemoryPressureObserver(new MemoryPressureObserver)
|
||||
, mMutex("SurfaceCache")
|
||||
, mDiscardFactor(aSurfaceCacheDiscardFactor)
|
||||
|
@ -742,6 +742,8 @@ public:
|
|||
nsISupports* aData,
|
||||
bool aAnonymize) MOZ_OVERRIDE
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
// We have explicit memory reporting for the surface cache which is more
|
||||
// accurate than the cost metrics we report here, but these metrics are
|
||||
// still useful to report, since they control the cache's behavior.
|
||||
|
@ -809,21 +811,18 @@ private:
|
|||
|
||||
struct SurfaceTracker : public nsExpirationTracker<CachedSurface, 2>
|
||||
{
|
||||
SurfaceTracker(SurfaceCacheImpl* aCache, uint32_t aSurfaceCacheExpirationTimeMS)
|
||||
SurfaceTracker(uint32_t aSurfaceCacheExpirationTimeMS)
|
||||
: nsExpirationTracker<CachedSurface, 2>(aSurfaceCacheExpirationTimeMS)
|
||||
, mCache(aCache)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual void NotifyExpired(CachedSurface* aSurface) MOZ_OVERRIDE
|
||||
{
|
||||
if (mCache) {
|
||||
mCache->Remove(aSurface);
|
||||
if (sInstance) {
|
||||
MutexAutoLock lock(sInstance->GetMutex());
|
||||
sInstance->Remove(aSurface);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SurfaceCacheImpl* const mCache; // Weak pointer to owner.
|
||||
};
|
||||
|
||||
struct MemoryPressureObserver : public nsIObserver
|
||||
|
@ -835,6 +834,7 @@ private:
|
|||
const char16_t*) MOZ_OVERRIDE
|
||||
{
|
||||
if (sInstance && strcmp(aTopic, "memory-pressure") == 0) {
|
||||
MutexAutoLock lock(sInstance->GetMutex());
|
||||
sInstance->DiscardForMemoryPressure();
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче