mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Bug 802894 - Add a memory reporter for nsEffectiveTLDService. r=jduell.
--HG-- extra : rebase_source : 32cdfbf060c963d6a16875af406949b8eef50453
This commit is contained in:
parent
9d66fb2eae
commit
7d3defab82
@ -305,10 +305,6 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb,
|
||||
ghostWindows.Init();
|
||||
CheckForGhostWindows(&ghostWindows);
|
||||
|
||||
nsCOMPtr<nsIEffectiveTLDService> tldService = do_GetService(
|
||||
NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
||||
NS_ENSURE_STATE(tldService);
|
||||
|
||||
WindowPaths windowPaths;
|
||||
windowPaths.Init();
|
||||
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
#include "nsEffectiveTLDService.h"
|
||||
#include "nsIIDNService.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsEffectiveTLDService, nsIEffectiveTLDService)
|
||||
@ -57,6 +57,25 @@ nsDomainEntry::FuncForStaticAsserts(void)
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static nsEffectiveTLDService *gService = nullptr;
|
||||
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(EffectiveTLDServiceMallocSizeOf,
|
||||
"effective-tld-service")
|
||||
|
||||
static int64_t
|
||||
GetEffectiveTLDSize()
|
||||
{
|
||||
return gService->SizeOfIncludingThis(EffectiveTLDServiceMallocSizeOf);
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(
|
||||
EffectiveTLDService,
|
||||
"explicit/xpcom/effective-TLD-service",
|
||||
KIND_HEAP,
|
||||
nsIMemoryReporter::UNITS_BYTES,
|
||||
GetEffectiveTLDSize,
|
||||
"Memory used by the effective TLD service.")
|
||||
|
||||
nsresult
|
||||
nsEffectiveTLDService::Init()
|
||||
{
|
||||
@ -86,9 +105,36 @@ nsEffectiveTLDService::Init()
|
||||
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
|
||||
entry->SetData(&entries[i]);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!gService);
|
||||
gService = this;
|
||||
mReporter = new NS_MEMORY_REPORTER_NAME(EffectiveTLDService);
|
||||
(void)::NS_RegisterMemoryReporter(mReporter);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEffectiveTLDService::~nsEffectiveTLDService()
|
||||
{
|
||||
(void)::NS_UnregisterMemoryReporter(mReporter);
|
||||
mReporter = nullptr;
|
||||
gService = nullptr;
|
||||
}
|
||||
|
||||
size_t
|
||||
nsEffectiveTLDService::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
size_t n = aMallocSizeOf(this);
|
||||
n += mHash.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
|
||||
// Measurement of the following members may be added later if DMD finds it is
|
||||
// worthwhile:
|
||||
// - mReporter
|
||||
// - mIDNService
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// External function for dealing with URI's correctly.
|
||||
// Pulls out the host portion from an nsIURI, and calls through to
|
||||
// GetPublicSuffixFromHost().
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIIDNService;
|
||||
class nsIMemoryReporter;
|
||||
|
||||
#define ETLD_ENTRY_N_INDEX_BITS 30
|
||||
|
||||
@ -109,11 +110,14 @@ public:
|
||||
nsEffectiveTLDService() { }
|
||||
nsresult Init();
|
||||
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
||||
|
||||
private:
|
||||
nsresult GetBaseDomainInternal(nsCString &aHostname, uint32_t aAdditionalParts, nsACString &aBaseDomain);
|
||||
nsresult NormalizeHostname(nsCString &aHostname);
|
||||
~nsEffectiveTLDService() { }
|
||||
~nsEffectiveTLDService();
|
||||
|
||||
nsIMemoryReporter* mReporter;
|
||||
nsTHashtable<nsDomainEntry> mHash;
|
||||
nsCOMPtr<nsIIDNService> mIDNService;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user