From 7686899ef4dc246158ee12967814e8cd23921524 Mon Sep 17 00:00:00 2001 From: dOn'tReallycAre Date: Fri, 21 Apr 2017 01:46:12 +0900 Subject: [PATCH] Bug 1357155 - Convert PRCList usage in nsStandardURL to LinkedList. r=erahm --- netwerk/base/nsStandardURL.cpp | 24 +++++------------------- netwerk/base/nsStandardURL.h | 6 ++++-- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 4feabf84c8f7..7025ec1943dd 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -283,7 +283,7 @@ nsSegmentEncoder::InitUnicodeEncoder() //---------------------------------------------------------------------------- #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN -static PRCList gAllURLs; +static LinkedList gAllURLs; #endif nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL) @@ -307,12 +307,9 @@ nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL) mParser = net_GetStdURLParser(); #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN - memset(&mDebugCList, 0, sizeof(mDebugCList)); if (NS_IsMainThread()) { if (aTrackURL) { - PR_APPEND_LINK(&mDebugCList, &gAllURLs); - } else { - PR_INIT_CLIST(&mDebugCList); + gAllURLs.insertBack(this); } } #endif @@ -331,13 +328,6 @@ nsStandardURL::~nsStandardURL() if (mHostA) { free(mHostA); } -#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN - if (NS_IsMainThread()) { - if (!PR_CLIST_IS_EMPTY(&mDebugCList)) { - PR_REMOVE_LINK(&mDebugCList); - } - } -#endif } #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN @@ -349,12 +339,12 @@ struct DumpLeakedURLs { DumpLeakedURLs::~DumpLeakedURLs() { MOZ_ASSERT(NS_IsMainThread()); - if (!PR_CLIST_IS_EMPTY(&gAllURLs)) { + if (!gAllURLs.isEmpty()) { printf("Leaked URLs:\n"); - for (PRCList *l = PR_LIST_HEAD(&gAllURLs); l != &gAllURLs; l = PR_NEXT_LINK(l)) { - nsStandardURL *url = reinterpret_cast(reinterpret_cast(l) - offsetof(nsStandardURL, mDebugCList)); + for (auto url : gAllURLs) { url->PrintSpec(); } + gAllURLs.clear(); } } #endif @@ -370,10 +360,6 @@ nsStandardURL::InitGlobalObjects() #endif PrefsChanged(prefBranch, nullptr); } - -#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN - PR_INIT_CLIST(&gAllURLs); -#endif } void diff --git a/netwerk/base/nsStandardURL.h b/netwerk/base/nsStandardURL.h index 3c06e0cc0137..c8dd819685a2 100644 --- a/netwerk/base/nsStandardURL.h +++ b/netwerk/base/nsStandardURL.h @@ -16,8 +16,8 @@ #include "nsURLHelper.h" #include "nsIClassInfo.h" #include "nsISizeOf.h" -#include "prclist.h" #include "mozilla/Attributes.h" +#include "mozilla/LinkedList.h" #include "mozilla/MemoryReporting.h" #include "nsIIPCSerializableURI.h" #include "nsISensitiveInfoHiddenURI.h" @@ -48,6 +48,9 @@ class nsStandardURL : public nsIFileURL , public nsISizeOf , public nsIIPCSerializableURI , public nsISensitiveInfoHiddenURI +#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN + , public LinkedListElement +#endif { protected: virtual ~nsStandardURL(); @@ -304,7 +307,6 @@ private: public: #ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN - PRCList mDebugCList; void PrintSpec() const { printf(" %s\n", mSpec.get()); } #endif