Backed out changeset dcd8195681d7 (bug 1513542) for browser-chrome failures at build/src/xpcom/base/nsTraceRefcnt.cpp

This commit is contained in:
Coroiu Cristina 2018-12-19 05:36:59 +02:00
Родитель 107d291d65
Коммит ac74e72736
1 изменённых файлов: 38 добавлений и 39 удалений

Просмотреть файл

@ -191,43 +191,8 @@ const nsACString &nsStandardURL::nsSegmentEncoder::EncodeSegment(
//----------------------------------------------------------------------------
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
class DumpLeakedURLs {
public:
DumpLeakedURLs() : mMutex("DumpLeakedURLs::mMutex") {}
~DumpLeakedURLs();
void add(nsStandardURL *aUrl) {
OffTheBooksMutexAutoLock lock(mMutex);
mURLs.insertBack(aUrl);
}
void remove(nsStandardURL *aUrl) {
OffTheBooksMutexAutoLock lock(mMutex);
if (aUrl->isInList()) {
aUrl->remove();
}
}
private:
OffTheBooksMutex mMutex;
LinkedList<nsStandardURL> mURLs;
};
DumpLeakedURLs::~DumpLeakedURLs() {
MOZ_ASSERT(NS_IsMainThread());
OffTheBooksMutexAutoLock lock(mMutex);
if (!mURLs.isEmpty()) {
printf("Leaked URLs:\n");
for (auto url : mURLs) {
url->PrintSpec();
}
mURLs.clear();
}
}
static DumpLeakedURLs gLeakedURLDumper;
static StaticMutex gAllURLsMutex;
static LinkedList<nsStandardURL> gAllURLs;
#endif
nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL)
@ -250,7 +215,8 @@ nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL)
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
if (NS_IsMainThread()) {
if (aTrackURL) {
gLeakedURLDumper.add(this);
StaticMutexAutoLock lock(gAllURLsMutex);
gAllURLs.insertBack(this);
}
}
#endif
@ -260,10 +226,34 @@ nsStandardURL::~nsStandardURL() {
LOG(("Destroying nsStandardURL @%p\n", this));
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
gLeakedURLDumper.remove(this);
{
StaticMutexAutoLock lock(gAllURLsMutex);
if (isInList()) {
remove();
}
}
#endif
}
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
struct DumpLeakedURLs {
DumpLeakedURLs() = default;
~DumpLeakedURLs();
};
DumpLeakedURLs::~DumpLeakedURLs() {
MOZ_ASSERT(NS_IsMainThread());
StaticMutexAutoLock lock(gAllURLsMutex);
if (!gAllURLs.isEmpty()) {
printf("Leaked URLs:\n");
for (auto url : gAllURLs) {
url->PrintSpec();
}
gAllURLs.clear();
}
}
#endif
void nsStandardURL::InitGlobalObjects() {
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
@ -290,6 +280,15 @@ void nsStandardURL::InitGlobalObjects() {
void nsStandardURL::ShutdownGlobalObjects() {
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
NS_IF_RELEASE(gIDN);
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
if (gInitialized) {
// This instanciates a dummy class, and will trigger the class
// destructor when libxul is unloaded. This is equivalent to atexit(),
// but gracefully handles dlclose().
static DumpLeakedURLs d;
}
#endif
}
//----------------------------------------------------------------------------