зеркало из https://github.com/mozilla/gecko-dev.git
Bug 831193 (part 7) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in toolkit/components/. r=nfroyd.
--HG-- extra : rebase_source : c65c466f03dca5174f3ccb4f103740cd7c642c99
This commit is contained in:
Родитель
a7c43d2502
Коммит
cf7dfb2973
|
@ -1,6 +1,6 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- 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/. */
|
||||
|
||||
|
@ -1909,22 +1909,22 @@ StoreAndNotifyEmbedVisit(VisitData& aPlace,
|
|||
(void)NS_DispatchToMainThread(event);
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(HistoryLinksHashtableMallocSizeOf)
|
||||
|
||||
int64_t GetHistoryObserversSize()
|
||||
class HistoryLinksHashtableReporter MOZ_FINAL : public MemoryReporterBase
|
||||
{
|
||||
History* history = History::GetService();
|
||||
return history ?
|
||||
history->SizeOfIncludingThis(HistoryLinksHashtableMallocSizeOf) : 0;
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(HistoryService,
|
||||
"explicit/history-links-hashtable",
|
||||
KIND_HEAP,
|
||||
UNITS_BYTES,
|
||||
GetHistoryObserversSize,
|
||||
"Memory used by the hashtable of observers Places uses to notify objects of "
|
||||
"changes to links' visited state.")
|
||||
public:
|
||||
HistoryLinksHashtableReporter()
|
||||
: MemoryReporterBase("explicit/history-links-hashtable",
|
||||
KIND_HEAP, UNITS_BYTES,
|
||||
"Memory used by the hashtable that records changes to the visited state of "
|
||||
"links.")
|
||||
{}
|
||||
private:
|
||||
int64_t Amount() MOZ_OVERRIDE
|
||||
{
|
||||
History* history = History::GetService();
|
||||
return history ? history->SizeOfIncludingThis(MallocSizeOf) : 0;
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
@ -1947,12 +1947,15 @@ History::History()
|
|||
(void)os->AddObserver(this, TOPIC_PLACES_SHUTDOWN, false);
|
||||
}
|
||||
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(HistoryService));
|
||||
mReporter = new HistoryLinksHashtableReporter();
|
||||
NS_RegisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
History::~History()
|
||||
{
|
||||
gService = NULL;
|
||||
NS_UnregisterMemoryReporter(mReporter);
|
||||
|
||||
gService = nullptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mObservers.IsInitialized()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- 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/. */
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "mozIStorageConnection.h"
|
||||
|
||||
class nsIMemoryReporter;
|
||||
|
||||
namespace mozilla {
|
||||
namespace places {
|
||||
|
||||
|
@ -208,6 +210,8 @@ private:
|
|||
RecentlyVisitedArray::index_type mRecentlyVisitedURIsNextIndex;
|
||||
|
||||
bool IsRecentlyVisitedURI(nsIURI* aURI);
|
||||
|
||||
nsCOMPtr<nsIMemoryReporter> mReporter;
|
||||
};
|
||||
|
||||
} // namespace places
|
||||
|
|
|
@ -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/. */
|
||||
|
@ -254,8 +255,7 @@ public:
|
|||
Telemetry::ProcessedStack &aStack);
|
||||
#endif
|
||||
static nsresult GetHistogramEnumId(const char *name, Telemetry::ID *id);
|
||||
static int64_t GetTelemetryMemoryUsed();
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
|
||||
static int64_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
|
||||
struct Stat {
|
||||
uint32_t hitCount;
|
||||
uint32_t totalTime;
|
||||
|
@ -267,16 +267,7 @@ public:
|
|||
typedef nsBaseHashtableET<nsCStringHashKey, StmtStats> SlowSQLEntryType;
|
||||
|
||||
private:
|
||||
// We don't need to poke inside any of our hashtables for more
|
||||
// information, so we just have One Function To Size Them All.
|
||||
template<typename EntryType>
|
||||
struct impl {
|
||||
static size_t SizeOfEntryExcludingThis(EntryType *,
|
||||
mozilla::MallocSizeOf,
|
||||
void *) {
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
size_t SizeOfIncludingThisHelper(mozilla::MallocSizeOf aMallocSizeOf);
|
||||
|
||||
static nsCString SanitizeSQL(const nsACString& sql);
|
||||
|
||||
|
@ -335,7 +326,7 @@ private:
|
|||
Mutex mHashMutex;
|
||||
HangReports mHangReports;
|
||||
Mutex mHangReportsMutex;
|
||||
nsIMemoryReporter *mMemoryReporter;
|
||||
nsCOMPtr<nsIMemoryReporter> mReporter;
|
||||
|
||||
CombinedStacks mLateWritesStacks; // This is collected out of the main thread.
|
||||
bool mCachedTelemetryData;
|
||||
|
@ -347,34 +338,26 @@ private:
|
|||
|
||||
TelemetryImpl* TelemetryImpl::sTelemetry = NULL;
|
||||
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(TelemetryMallocSizeOf)
|
||||
|
||||
size_t
|
||||
TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
TelemetryImpl::SizeOfIncludingThisHelper(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
size_t n = 0;
|
||||
n += aMallocSizeOf(this);
|
||||
size_t n = aMallocSizeOf(this);
|
||||
// Ignore the hashtables in mAddonMap; they are not significant.
|
||||
n += mAddonMap.SizeOfExcludingThis(impl<AddonEntryType>::SizeOfEntryExcludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mHistogramMap.SizeOfExcludingThis(impl<CharPtrEntryType>::SizeOfEntryExcludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mPrivateSQL.SizeOfExcludingThis(impl<SlowSQLEntryType>::SizeOfEntryExcludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mSanitizedSQL.SizeOfExcludingThis(impl<SlowSQLEntryType>::SizeOfEntryExcludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mTrackedDBs.SizeOfExcludingThis(impl<nsCStringHashKey>::SizeOfEntryExcludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mAddonMap.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
n += mHistogramMap.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
n += mPrivateSQL.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
n += mSanitizedSQL.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
n += mTrackedDBs.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
n += mHangReports.SizeOfExcludingThis();
|
||||
return n;
|
||||
}
|
||||
|
||||
int64_t
|
||||
TelemetryImpl::GetTelemetryMemoryUsed()
|
||||
TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
int64_t n = 0;
|
||||
if (sTelemetry) {
|
||||
n += sTelemetry->SizeOfIncludingThis(TelemetryMallocSizeOf);
|
||||
n += sTelemetry->SizeOfIncludingThisHelper(aMallocSizeOf);
|
||||
}
|
||||
|
||||
StatisticsRecorder::Histograms hs;
|
||||
|
@ -382,17 +365,24 @@ TelemetryImpl::GetTelemetryMemoryUsed()
|
|||
|
||||
for (HistogramIterator it = hs.begin(); it != hs.end(); ++it) {
|
||||
Histogram *h = *it;
|
||||
n += h->SizeOfIncludingThis(TelemetryMallocSizeOf);
|
||||
n += h->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(Telemetry,
|
||||
"explicit/telemetry",
|
||||
KIND_HEAP,
|
||||
UNITS_BYTES,
|
||||
TelemetryImpl::GetTelemetryMemoryUsed,
|
||||
"Memory used by the telemetry system.")
|
||||
class TelemetryReporter MOZ_FINAL : public MemoryReporterBase
|
||||
{
|
||||
public:
|
||||
TelemetryReporter()
|
||||
: MemoryReporterBase("explicit/telemetry", KIND_HEAP, UNITS_BYTES,
|
||||
"Memory used by the telemetry system.")
|
||||
{}
|
||||
private:
|
||||
int64_t Amount() MOZ_OVERRIDE
|
||||
{
|
||||
return TelemetryImpl::SizeOfIncludingThis(MallocSizeOf);
|
||||
}
|
||||
};
|
||||
|
||||
// A initializer to initialize histogram collection
|
||||
StatisticsRecorder gStatisticsRecorder;
|
||||
|
@ -978,13 +968,12 @@ mFailedLockCount(0)
|
|||
// Mark immutable to prevent asserts on simultaneous access from multiple threads
|
||||
mTrackedDBs.MarkImmutable();
|
||||
#endif
|
||||
mMemoryReporter = new NS_MEMORY_REPORTER_NAME(Telemetry);
|
||||
NS_RegisterMemoryReporter(mMemoryReporter);
|
||||
mReporter = new TelemetryReporter();
|
||||
NS_RegisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
TelemetryImpl::~TelemetryImpl() {
|
||||
NS_UnregisterMemoryReporter(mMemoryReporter);
|
||||
mMemoryReporter = nullptr;
|
||||
NS_UnregisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1859,7 +1848,7 @@ already_AddRefed<nsITelemetry>
|
|||
TelemetryImpl::CreateTelemetryInstance()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(sTelemetry == NULL, "CreateTelemetryInstance may only be called once, via GetService()");
|
||||
sTelemetry = new TelemetryImpl();
|
||||
sTelemetry = new TelemetryImpl();
|
||||
// AddRef for the local reference
|
||||
NS_ADDREF(sTelemetry);
|
||||
// AddRef for the caller
|
||||
|
|
Загрузка…
Ссылка в новой задаче