mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 800187 (part 1) - Add memory reporter for the nsStyleSheetService. r=bz.
--HG-- extra : rebase_source : fc5c04daa0fd919f11470b090e38e9e8a5f19db6
This commit is contained in:
parent
e37c1e657a
commit
8653ecbff2
@ -19,6 +19,24 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(LayoutStyleSheetServiceMallocSizeOf,
|
||||
"layout/style-sheet-service")
|
||||
|
||||
static int64_t
|
||||
GetStyleSheetServiceSize()
|
||||
{
|
||||
return nsStyleSheetService::SizeOfIncludingThis(
|
||||
LayoutStyleSheetServiceMallocSizeOf);
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(StyleSheetService,
|
||||
"explicit/layout/style-sheet-service",
|
||||
KIND_HEAP,
|
||||
nsIMemoryReporter::UNITS_BYTES,
|
||||
GetStyleSheetServiceSize,
|
||||
"Memory used for style sheets held by the style sheet service.")
|
||||
|
||||
nsStyleSheetService *nsStyleSheetService::gInstance = nullptr;
|
||||
|
||||
@ -28,12 +46,18 @@ nsStyleSheetService::nsStyleSheetService()
|
||||
NS_ASSERTION(!gInstance, "Someone is using CreateInstance instead of GetService");
|
||||
gInstance = this;
|
||||
nsLayoutStatics::AddRef();
|
||||
|
||||
mReporter = new NS_MEMORY_REPORTER_NAME(StyleSheetService);
|
||||
(void)::NS_RegisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
nsStyleSheetService::~nsStyleSheetService()
|
||||
{
|
||||
gInstance = nullptr;
|
||||
nsLayoutStatics::Release();
|
||||
|
||||
(void)::NS_UnregisterMemoryReporter(mReporter);
|
||||
mReporter = nullptr;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsStyleSheetService, nsIStyleSheetService)
|
||||
@ -183,3 +207,34 @@ nsStyleSheetService::UnregisterSheet(nsIURI *sheetURI, uint32_t aSheetType)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsStyleSheetService::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
if (!nsStyleSheetService::gInstance) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return nsStyleSheetService::gInstance->
|
||||
SizeOfIncludingThisHelper(aMallocSizeOf);
|
||||
}
|
||||
|
||||
static size_t
|
||||
SizeOfElementIncludingThis(nsIStyleSheet* aElement,
|
||||
nsMallocSizeOfFun aMallocSizeOf, void *aData)
|
||||
{
|
||||
return aElement->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsStyleSheetService::SizeOfIncludingThisHelper(nsMallocSizeOfFun aMallocSizeOf) const
|
||||
{
|
||||
size_t n = aMallocSizeOf(this);
|
||||
n += mSheets[AGENT_SHEET].SizeOfExcludingThis(SizeOfElementIncludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mSheets[USER_SHEET].SizeOfExcludingThis(SizeOfElementIncludingThis,
|
||||
aMallocSizeOf);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,8 @@ class nsICategoryManager;
|
||||
#define NS_STYLESHEETSERVICE_CONTRACTID \
|
||||
"@mozilla.org/content/style-sheet-service;1"
|
||||
|
||||
class nsIMemoryReporter;
|
||||
|
||||
class nsStyleSheetService MOZ_FINAL : public nsIStyleSheetService
|
||||
{
|
||||
public:
|
||||
@ -36,6 +38,8 @@ class nsStyleSheetService MOZ_FINAL : public nsIStyleSheetService
|
||||
nsCOMArray<nsIStyleSheet>* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
|
||||
nsCOMArray<nsIStyleSheet>* UserStyleSheets() { return &mSheets[USER_SHEET]; }
|
||||
|
||||
static size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
||||
|
||||
static nsStyleSheetService *gInstance;
|
||||
|
||||
private:
|
||||
@ -53,7 +57,11 @@ class nsStyleSheetService MOZ_FINAL : public nsIStyleSheetService
|
||||
NS_HIDDEN_(nsresult) LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
||||
uint32_t aSheetType);
|
||||
|
||||
size_t SizeOfIncludingThisHelper(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||
|
||||
nsCOMArray<nsIStyleSheet> mSheets[2];
|
||||
|
||||
nsIMemoryReporter* mReporter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@ GetStylesheetCacheSize()
|
||||
LayoutStyleSheetCacheMallocSizeOf);
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(Sheets,
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(StyleSheetCache,
|
||||
"explicit/layout/style-sheet-cache",
|
||||
KIND_HEAP,
|
||||
nsIMemoryReporter::UNITS_BYTES,
|
||||
@ -161,11 +161,12 @@ nsLayoutStylesheetCache::Shutdown()
|
||||
size_t
|
||||
nsLayoutStylesheetCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
if (nsLayoutStylesheetCache::gStyleCache) {
|
||||
if (!nsLayoutStylesheetCache::gStyleCache) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return nsLayoutStylesheetCache::gStyleCache->
|
||||
SizeOfIncludingThisHelper(aMallocSizeOf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -226,14 +227,14 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache()
|
||||
}
|
||||
NS_ASSERTION(mFullScreenOverrideSheet, "Could not load full-screen-override.css");
|
||||
|
||||
mSheetsReporter = new NS_MEMORY_REPORTER_NAME(Sheets);
|
||||
(void)::NS_RegisterMemoryReporter(mSheetsReporter);
|
||||
mReporter = new NS_MEMORY_REPORTER_NAME(StyleSheetCache);
|
||||
(void)::NS_RegisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
nsLayoutStylesheetCache::~nsLayoutStylesheetCache()
|
||||
{
|
||||
(void)::NS_UnregisterMemoryReporter(mSheetsReporter);
|
||||
mSheetsReporter = nullptr;
|
||||
(void)::NS_UnregisterMemoryReporter(mReporter);
|
||||
mReporter = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
nsRefPtr<nsCSSStyleSheet> mQuirkSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mFullScreenOverrideSheet;
|
||||
|
||||
nsIMemoryReporter* mSheetsReporter;
|
||||
nsIMemoryReporter* mReporter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user