зеркало из https://github.com/mozilla/gecko-dev.git
Bug 831193 (part 9) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in Preferences.cpp. r=nfroyd.
--HG-- extra : rebase_source : 409040de983b253f22df67fd3847806b4c6c55ec
This commit is contained in:
Родитель
5d24bdca75
Коммит
096351ca03
|
@ -17,6 +17,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsCString;
|
||||
|
@ -348,7 +349,7 @@ public:
|
|||
static void GetPreference(PrefSetting* aPref);
|
||||
static void SetPreference(const PrefSetting& aPref);
|
||||
|
||||
static int64_t GetPreferencesMemoryUsed();
|
||||
static int64_t SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeOf);
|
||||
static nsresult SetFloat(const char* aPref, float aValue);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -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/. */
|
||||
|
@ -160,8 +161,6 @@ static nsTArray<nsAutoPtr<CacheData> >* gCacheData = nullptr;
|
|||
static nsRefPtrHashtable<ValueObserverHashKey,
|
||||
ValueObserver>* gObserverTable = nullptr;
|
||||
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(PreferencesMallocSizeOf)
|
||||
|
||||
static size_t
|
||||
SizeOfObserverEntryExcludingThis(ValueObserverHashKey* aKey,
|
||||
const nsRefPtr<ValueObserver>& aData,
|
||||
|
@ -174,52 +173,56 @@ SizeOfObserverEntryExcludingThis(ValueObserverHashKey* aKey,
|
|||
return n;
|
||||
}
|
||||
|
||||
// static
|
||||
int64_t
|
||||
Preferences::GetPreferencesMemoryUsed()
|
||||
// Although this is a member of Preferences, it measures sPreferences and
|
||||
// several other global structures.
|
||||
/* static */ int64_t
|
||||
Preferences::SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
NS_ENSURE_TRUE(InitStaticMembers(), 0);
|
||||
|
||||
size_t n = 0;
|
||||
n += PreferencesMallocSizeOf(sPreferences);
|
||||
size_t n = aMallocSizeOf(sPreferences);
|
||||
if (gHashTable.ops) {
|
||||
// pref keys are allocated in a private arena, which we count elsewhere.
|
||||
// pref stringvals are allocated out of the same private arena.
|
||||
n += PL_DHashTableSizeOfExcludingThis(&gHashTable, nullptr,
|
||||
PreferencesMallocSizeOf);
|
||||
n += PL_DHashTableSizeOfExcludingThis(&gHashTable, nullptr, aMallocSizeOf);
|
||||
}
|
||||
if (gCacheData) {
|
||||
n += gCacheData->SizeOfIncludingThis(PreferencesMallocSizeOf);
|
||||
n += gCacheData->SizeOfIncludingThis(aMallocSizeOf);
|
||||
for (uint32_t i = 0, count = gCacheData->Length(); i < count; ++i) {
|
||||
n += PreferencesMallocSizeOf((*gCacheData)[i]);
|
||||
n += aMallocSizeOf((*gCacheData)[i]);
|
||||
}
|
||||
}
|
||||
if (gObserverTable) {
|
||||
n += PreferencesMallocSizeOf(gObserverTable);
|
||||
n += aMallocSizeOf(gObserverTable);
|
||||
n += gObserverTable->SizeOfExcludingThis(SizeOfObserverEntryExcludingThis,
|
||||
PreferencesMallocSizeOf);
|
||||
aMallocSizeOf);
|
||||
}
|
||||
// We don't measure sRootBranch and sDefaultRootBranch here because
|
||||
// DMD indicates they are not significant.
|
||||
n += pref_SizeOfPrivateData(PreferencesMallocSizeOf);
|
||||
n += pref_SizeOfPrivateData(aMallocSizeOf);
|
||||
return n;
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(Preferences,
|
||||
"explicit/preferences",
|
||||
KIND_HEAP,
|
||||
UNITS_BYTES,
|
||||
Preferences::GetPreferencesMemoryUsed,
|
||||
"Memory used by the preferences system.")
|
||||
class PreferencesReporter MOZ_FINAL : public MemoryReporterBase
|
||||
{
|
||||
public:
|
||||
PreferencesReporter()
|
||||
: MemoryReporterBase("explicit/preferences", KIND_HEAP, UNITS_BYTES,
|
||||
"Memory used by the preferences system.")
|
||||
{}
|
||||
private:
|
||||
int64_t Amount() MOZ_OVERRIDE
|
||||
{
|
||||
return Preferences::SizeOfIncludingThisAndOtherStuff(MallocSizeOf);
|
||||
}
|
||||
};
|
||||
|
||||
namespace {
|
||||
class AddPreferencesMemoryReporterRunnable : public nsRunnable
|
||||
{
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsCOMPtr<nsIMemoryReporter> reporter =
|
||||
new NS_MEMORY_REPORTER_NAME(Preferences);
|
||||
return NS_RegisterMemoryReporter(reporter);
|
||||
return NS_RegisterMemoryReporter(new PreferencesReporter());
|
||||
}
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
|
Загрузка…
Ссылка в новой задаче