Bug 1275464 - Part 1. Unregister from handling image memory reports when shutting down. r=njn

This commit is contained in:
Andrew Osmond 2016-09-19 13:29:59 -04:00
parent 6713249398
commit 31ad519348
4 changed files with 13 additions and 2 deletions

View File

@ -1217,6 +1217,12 @@ void imgLoader::GlobalInit()
imgMemoryReporter::ImagesContentUsedUncompressedDistinguishedAmount);
}
void imgLoader::ShutdownMemoryReporter()
{
UnregisterImagesContentUsedUncompressedDistinguishedAmount();
UnregisterStrongMemoryReporter(sMemReporter);
}
nsresult
imgLoader::InitCache()
{
@ -1281,9 +1287,11 @@ imgLoader::Observe(nsISupports* aSubject, const char* aTopic,
ClearImageCache();
ClearChromeImageCache();
}
} else if (strcmp(aTopic, "profile-before-change") == 0 ||
strcmp(aTopic, "xpcom-shutdown") == 0) {
} else if (strcmp(aTopic, "profile-before-change") == 0) {
mCacheTracker = nullptr;
} else if (strcmp(aTopic, "xpcom-shutdown") == 0) {
mCacheTracker = nullptr;
ShutdownMemoryReporter();
} else {
// (Nothing else should bring us here)

View File

@ -332,6 +332,7 @@ public:
static void GlobalInit(); // for use by the factory
static void Shutdown(); // for use by the factory
static void ShutdownMemoryReporter();
nsresult ClearChromeImageCache();
nsresult ClearImageCache();

View File

@ -489,6 +489,7 @@ DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsSystem)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsUser)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, ImagesContentUsedUncompressed)
DECL_UNREGISTER_DISTINGUISHED_AMOUNT(ImagesContentUsedUncompressed)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, StorageSQLite)
DECL_UNREGISTER_DISTINGUISHED_AMOUNT(StorageSQLite)

View File

@ -2685,6 +2685,7 @@ DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsSystem
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsUser)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, ImagesContentUsedUncompressed)
DEFINE_UNREGISTER_DISTINGUISHED_AMOUNT(ImagesContentUsedUncompressed)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, StorageSQLite)
DEFINE_UNREGISTER_DISTINGUISHED_AMOUNT(StorageSQLite)