diff --git a/netwerk/dns/nsEffectiveTLDService.cpp b/netwerk/dns/nsEffectiveTLDService.cpp index 037ac17af55..71dd332ba73 100644 --- a/netwerk/dns/nsEffectiveTLDService.cpp +++ b/netwerk/dns/nsEffectiveTLDService.cpp @@ -1,4 +1,5 @@ -//* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -60,21 +61,21 @@ nsDomainEntry::FuncForStaticAsserts(void) static nsEffectiveTLDService *gService = nullptr; -NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(EffectiveTLDServiceMallocSizeOf) - -static int64_t -GetEffectiveTLDSize() +class EffectiveTLDServiceReporter MOZ_FINAL : public MemoryReporterBase { - return gService->SizeOfIncludingThis(EffectiveTLDServiceMallocSizeOf); -} +public: + EffectiveTLDServiceReporter() + : MemoryReporterBase("explicit/xpcom/effective-TLD-service", + KIND_HEAP, UNITS_BYTES, + "Memory used by the effective TLD service.") + {} -NS_MEMORY_REPORTER_IMPLEMENT( - EffectiveTLDService, - "explicit/xpcom/effective-TLD-service", - KIND_HEAP, - nsIMemoryReporter::UNITS_BYTES, - GetEffectiveTLDSize, - "Memory used by the effective TLD service.") +private: + int64_t Amount() MOZ_OVERRIDE + { + return gService ? gService->SizeOfIncludingThis(MallocSizeOf) : 0; + } +}; nsresult nsEffectiveTLDService::Init() @@ -108,16 +109,15 @@ nsEffectiveTLDService::Init() MOZ_ASSERT(!gService); gService = this; - mReporter = new NS_MEMORY_REPORTER_NAME(EffectiveTLDService); - (void)::NS_RegisterMemoryReporter(mReporter); + mReporter = new EffectiveTLDServiceReporter(); + NS_RegisterMemoryReporter(mReporter); return NS_OK; } nsEffectiveTLDService::~nsEffectiveTLDService() { - (void)::NS_UnregisterMemoryReporter(mReporter); - mReporter = nullptr; + NS_UnregisterMemoryReporter(mReporter); gService = nullptr; } diff --git a/netwerk/dns/nsEffectiveTLDService.h b/netwerk/dns/nsEffectiveTLDService.h index edd38159ac1..e211b7a50d6 100644 --- a/netwerk/dns/nsEffectiveTLDService.h +++ b/netwerk/dns/nsEffectiveTLDService.h @@ -5,6 +5,7 @@ #include "nsIEffectiveTLDService.h" +#include "nsIMemoryReporter.h" #include "nsTHashtable.h" #include "nsString.h" #include "nsCOMPtr.h" @@ -12,7 +13,6 @@ #include "mozilla/MemoryReporting.h" class nsIIDNService; -class nsIMemoryReporter; #define ETLD_ENTRY_N_INDEX_BITS 30 @@ -118,7 +118,7 @@ private: nsresult NormalizeHostname(nsCString &aHostname); ~nsEffectiveTLDService(); - nsIMemoryReporter* mReporter; + nsCOMPtr mReporter; nsTHashtable mHash; nsCOMPtr mIDNService; };