Bug 1346703 - Replace PR_LogPrint with MOZ_LOG, remove unnecessary checks and add a nullptr check. r=ehsan

This commit is contained in:
Samael Wang 2017-03-14 16:58:45 +08:00
Родитель 12090b6df9
Коммит 2cd1696dc6
3 изменённых файлов: 36 добавлений и 56 удалений

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

@ -876,9 +876,7 @@ nsDocShell::~nsDocShell()
NS_IF_RELEASE(sURIFixup);
}
if (gDocShellLeakLog) {
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p destroyed\n", this));
}
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p destroyed\n", this));
#ifdef DEBUG
// We're counting the number of |nsDocShells| to help find leaks
@ -1322,15 +1320,9 @@ nsDocShell::LoadURI(nsIURI* aURI,
aLoadInfo->GetBaseURI(getter_AddRefs(baseURI));
}
#if defined(DEBUG)
if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
nsAutoCString uristr;
aURI->GetAsciiSpec(uristr);
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]: loading %s with flags 0x%08x",
this, uristr.get(), aLoadFlags));
}
#endif
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug,
("nsDocShell[%p]: loading %s with flags 0x%08x",
this, aURI->GetSpecOrDefault().get(), aLoadFlags));
if (!shEntry &&
!LOAD_TYPE_HAS_FLAGS(loadType, LOAD_FLAGS_REPLACE_HISTORY)) {
@ -1980,10 +1972,9 @@ bool
nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
bool aFireOnLocationChange, uint32_t aLocationFlags)
{
if (gDocShellLeakLog && MOZ_LOG_TEST(gDocShellLeakLog, LogLevel::Debug)) {
PR_LogPrint("DOCSHELL %p SetCurrentURI %s\n",
this, aURI ? aURI->GetSpecOrDefault().get() : "");
}
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug,
("DOCSHELL %p SetCurrentURI %s\n",
this, aURI ? aURI->GetSpecOrDefault().get() : ""));
// We don't want to send a location change when we're displaying an error
// page, and we don't want to change our idea of "current URI" either
@ -5343,7 +5334,8 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]::LoadErrorPage(\"%s\", \"%s\", {...}, [%s])\n", this,
aURI->GetSpecOrDefault().get(), NS_ConvertUTF16toUTF8(aURL).get(),
aURI ? aURI->GetSpecOrDefault().get() : "",
NS_ConvertUTF16toUTF8(aURL).get(),
chanName.get()));
}
#endif
@ -9809,10 +9801,9 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsresult rv = NS_OK;
mOriginalUriString.Truncate();
if (gDocShellLeakLog && MOZ_LOG_TEST(gDocShellLeakLog, LogLevel::Debug)) {
PR_LogPrint("DOCSHELL %p InternalLoad %s\n",
this, aURI ? aURI->GetSpecOrDefault().get() : "");
}
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug,
("DOCSHELL %p InternalLoad %s\n",
this, aURI ? aURI->GetSpecOrDefault().get() : ""));
// Initialize aDocShell/aRequest
if (aDocShell) {
*aDocShell = nullptr;

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

@ -1429,9 +1429,7 @@ nsDocument::nsDocument(const char* aContentType)
{
SetContentTypeInternal(nsDependentCString(aContentType));
if (gDocumentLeakPRLog)
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p created", this));
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug, ("DOCUMENT %p created", this));
// Start out mLastStyleSheetSet as null, per spec
SetDOMStringToNull(mLastStyleSheetSet);
@ -1488,9 +1486,7 @@ nsDocument::IsAboutPage() const
nsDocument::~nsDocument()
{
if (gDocumentLeakPRLog)
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p destroyed", this));
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug, ("DOCUMENT %p destroyed", this));
NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document");
@ -2112,10 +2108,8 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
{
NS_PRECONDITION(aURI, "Null URI passed to ResetToURI");
if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) {
PR_LogPrint("DOCUMENT %p ResetToURI %s", this,
aURI->GetSpecOrDefault().get());
}
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p ResetToURI %s", this, aURI->GetSpecOrDefault().get()));
mSecurityInfo = nullptr;
@ -2435,11 +2429,12 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsIStreamListener **aDocListener,
bool aReset, nsIContentSink* aSink)
{
if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) {
if (MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) {
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
PR_LogPrint("DOCUMENT %p StartDocumentLoad %s",
this, uri ? uri->GetSpecOrDefault().get() : "");
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p StartDocumentLoad %s",
this, uri ? uri->GetSpecOrDefault().get() : ""));
}
MOZ_ASSERT(NodePrincipal()->GetAppId() != nsIScriptSecurityManager::UNKNOWN_APP_ID,

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

@ -1568,9 +1568,8 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
}
#endif
if (gDOMLeakPRLog)
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("DOMWINDOW %p created outer=%p", this, aOuterWindow));
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("DOMWINDOW %p created outer=%p", this, aOuterWindow));
NS_ASSERTION(sWindowsById, "Windows hash table must be created!");
NS_ASSERTION(!sWindowsById->Get(mWindowID),
@ -1643,9 +1642,7 @@ nsGlobalWindow::~nsGlobalWindow()
}
#endif
if (gDOMLeakPRLog)
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("DOMWINDOW %p destroyed", this));
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug, ("DOMWINDOW %p destroyed", this));
if (IsOuterWindow()) {
JSObject *proxy = GetWrapperPreserveColor();
@ -3304,10 +3301,11 @@ nsGlobalWindow::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
NS_PRECONDITION(IsInnerWindow(), "Must only be called on inner windows");
MOZ_ASSERT(aDocument);
if (gDOMLeakPRLog && MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
nsIURI *uri = aDocument->GetDocumentURI();
PR_LogPrint("DOMWINDOW %p SetNewDocument %s",
this, uri ? uri->GetSpecOrDefault().get() : "");
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("DOMWINDOW %p SetNewDocument %s",
this, uri ? uri->GetSpecOrDefault().get() : ""));
}
mDoc = aDocument;
@ -10996,9 +10994,8 @@ nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
}
if (mSessionStorage) {
if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
PR_LogPrint("nsGlobalWindow %p has %p sessionStorage", this, mSessionStorage.get());
}
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("nsGlobalWindow %p has %p sessionStorage", this, mSessionStorage.get()));
bool canAccess = mSessionStorage->CanAccess(principal);
NS_ASSERTION(canAccess,
"This window owned sessionStorage "
@ -11048,9 +11045,8 @@ nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
mSessionStorage = static_cast<Storage*>(storage.get());
MOZ_ASSERT(mSessionStorage);
if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
PR_LogPrint("nsGlobalWindow %p tried to get a new sessionStorage %p", this, mSessionStorage.get());
}
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("nsGlobalWindow %p tried to get a new sessionStorage %p", this, mSessionStorage.get()));
if (!mSessionStorage) {
aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
@ -11058,9 +11054,8 @@ nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
}
}
if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
PR_LogPrint("nsGlobalWindow %p returns %p sessionStorage", this, mSessionStorage.get());
}
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("nsGlobalWindow %p returns %p sessionStorage", this, mSessionStorage.get()));
return mSessionStorage;
}
@ -11998,10 +11993,9 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
PR_LogPrint("nsGlobalWindow %p with sessionStorage %p passing event from %p",
this, mSessionStorage.get(), changingStorage.get());
}
MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
("nsGlobalWindow %p with sessionStorage %p passing event from %p",
this, mSessionStorage.get(), changingStorage.get()));
fireMozStorageChanged = mSessionStorage == changingStorage;
if (fireMozStorageChanged) {