From 35f51267b9c6526c7b03efd3060a0a664177b330 Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Fri, 30 Jul 1999 04:20:34 +0000 Subject: [PATCH] Clean up of nsDocumentBindInfo::OnStopRequest. Debug error messages for necko failure. git-svn-id: svn://10.0.0.236/trunk@41584 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 16 ++- mozilla/uriloader/base/nsDocLoader.cpp | 132 +++++++++++++------------ mozilla/webshell/src/nsDocLoader.cpp | 132 +++++++++++++------------ mozilla/webshell/src/nsThrobber.cpp | 2 +- mozilla/webshell/src/nsWebShell.cpp | 16 ++- 5 files changed, 173 insertions(+), 125 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index d12116bb6e0..4397abed7ae 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -27,6 +27,8 @@ #ifdef NECKO #include "nsIPrompt.h" #include "nsNeckoUtil.h" +#include "nsIProtocolHandler.h" +#include "nsIDNSService.h" #else #include "nsINetSupport.h" #include "nsIRefreshUrl.h" @@ -1866,6 +1868,18 @@ nsWebShell::DoLoadURL(const nsString& aUrlSpec, rv = NS_NewURL(getter_AddRefs(url), aUrlSpec); #else rv = NS_NewURI(getter_AddRefs(url), aUrlSpec); +#ifdef DEBUG + char* urlStr = aUrlSpec.ToNewCString(); + if (rv == NS_ERROR_UNKNOWN_PROTOCOL) + printf("Error: Unknown protocol: %s\n", urlStr); + else if (rv == NS_ERROR_UNKNOWN_HOST) + printf("Error: Unknown host: %s\n", urlStr); + else if (rv == NS_ERROR_MALFORMED_URI) + printf("Error: Malformed URI: %s\n", urlStr); + else if (NS_FAILED(rv)) + printf("Error: Can't load: %s (%x)\n", urlStr, rv); + nsCRT::free(urlStr); +#endif #endif // NECKO if (NS_FAILED(rv)) return rv; if (url && docURL && EqualBaseURLs(docURL, url)) { @@ -2695,7 +2709,7 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, { nsIWebShell* shell = GetTarget(target.GetUnicode()); if (nsnull != shell) { - shell->LoadURL(aURLSpec, aPostData); + (void)shell->LoadURL(aURLSpec, aPostData); NS_RELEASE(shell); } } diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 0b840179c71..b827ec5bee1 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -43,7 +43,7 @@ //#include "nsILoadGroupObserver.h" #include "nsNeckoUtil.h" #include "nsIURL.h" - +#include "nsIDNSService.h" #include "nsIChannel.h" #include "nsIProgressEventSink.h" #endif // NECKO @@ -2063,12 +2063,73 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons #ifdef NECKO nsCRT::free(spec); #endif +#endif // DEBUG +#ifdef DEBUG if (NS_FAILED(aStatus)) { #ifdef NECKO -#if 0 // XXX can only turn this on once we can identify dns failures. + char *url; + if (NS_SUCCEEDED(rv)) + aURL->GetSpec(&url); + else + url = nsCRT::strdup(""); +#else + const char *url; + if (nsnull != aURL) + aURL->GetSpec(&url); + else + url = ""; +#endif // NECKO +#ifdef DEBUG_pnunn + cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: " + << NS_ERROR_GET_CODE(aStatus) << "\n"; +#endif + +#ifdef NECKO + if (aStatus == NS_ERROR_UNKNOWN_HOST) + printf("Error: Unknown host: %s\n", url); + else if (aStatus == NS_ERROR_MALFORMED_URI) + printf("Error: Malformed URI: %s\n", url); + else if (NS_FAILED(rv)) + printf("Error: Can't load: %s (%x)\n", url, aStatus); + nsCRT::free(url); +#endif + } +#endif /* DEBUG */ + + if (nsnull != m_NextStream) { +#ifdef NECKO + rv = m_NextStream->OnStopRequest(channel, ctxt, aStatus, aMsg); +#else + rv = m_NextStream->OnStopRequest(aURL, aStatus, aMsg); +#endif + } + + /* Pass the notification out to the Observer... */ + if (nsnull != m_Observer) { + /* XXX: Should we ignore the return value? */ +#ifdef NECKO + (void) m_Observer->OnStopRequest(channel, ctxt, aStatus, aMsg); +#else + (void) m_Observer->OnStopRequest(aURL, aStatus, aMsg); +#endif + } + + /* + * The stream is complete... Tell the DocumentLoader to release us... + */ +#ifdef NECKO + rv = m_DocLoader->LoadURLComplete(channel, ctxt, (nsIStreamListener *)this, + aStatus, aMsg); +#else + rv = m_DocLoader->LoadURLComplete(aURL, (nsIStreamListener *)this, aStatus); +#endif + NS_IF_RELEASE(m_NextStream); + +#ifdef NECKO + if (aStatus == NS_ERROR_UNKNOWN_HOST) { // We need to check for a dns failure in aStatus, but dns failure codes // aren't proliferated yet. This checks for failure for a host lacking // "www." and/or ".com" and munges the url acordingly, then fires off @@ -2109,68 +2170,17 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons nsString2 newURL(aSpec); return m_DocLoader->LoadDocument(newURL, - m_Command, - m_Container, - nsnull, // XXX need to pass post data along - m_ExtraInfo, - m_Observer, - nsIChannel::LOAD_NORMAL, - 0); + m_Command, + m_Container, + nsnull, // XXX need to pass post data along + m_ExtraInfo, + m_Observer, + nsIChannel::LOAD_NORMAL, + 0); } -#endif // 0 - char *url; - if (NS_SUCCEEDED(rv)) - aURL->GetSpec(&url); - else - url = nsCRT::strdup(""); -#else - const char *url; - if (nsnull != aURL) - aURL->GetSpec(&url); - else - url = ""; + } #endif // NECKO -#ifdef DEBUG_pnunn - cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: " - << NS_ERROR_GET_CODE(aStatus) << "\n"; -#endif - -#ifdef NECKO - nsCRT::free(url); -#endif - } -#endif /* DEBUG */ - - if (nsnull != m_NextStream) { -#ifdef NECKO - rv = m_NextStream->OnStopRequest(channel, ctxt, aStatus, aMsg); -#else - rv = m_NextStream->OnStopRequest(aURL, aStatus, aMsg); -#endif - } - - /* Pass the notification out to the Observer... */ - if (nsnull != m_Observer) { - /* XXX: Should we ignore the return value? */ -#ifdef NECKO - (void) m_Observer->OnStopRequest(channel, ctxt, aStatus, aMsg); -#else - (void) m_Observer->OnStopRequest(aURL, aStatus, aMsg); -#endif - } - - /* - * The stream is complete... Tell the DocumentLoader to release us... - */ -#ifdef NECKO - rv = m_DocLoader->LoadURLComplete(channel, ctxt, (nsIStreamListener *)this, - aStatus, aMsg); -#else - rv = m_DocLoader->LoadURLComplete(aURL, (nsIStreamListener *)this, aStatus); -#endif - NS_IF_RELEASE(m_NextStream); - return rv; } diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index 0b840179c71..b827ec5bee1 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -43,7 +43,7 @@ //#include "nsILoadGroupObserver.h" #include "nsNeckoUtil.h" #include "nsIURL.h" - +#include "nsIDNSService.h" #include "nsIChannel.h" #include "nsIProgressEventSink.h" #endif // NECKO @@ -2063,12 +2063,73 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons #ifdef NECKO nsCRT::free(spec); #endif +#endif // DEBUG +#ifdef DEBUG if (NS_FAILED(aStatus)) { #ifdef NECKO -#if 0 // XXX can only turn this on once we can identify dns failures. + char *url; + if (NS_SUCCEEDED(rv)) + aURL->GetSpec(&url); + else + url = nsCRT::strdup(""); +#else + const char *url; + if (nsnull != aURL) + aURL->GetSpec(&url); + else + url = ""; +#endif // NECKO +#ifdef DEBUG_pnunn + cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: " + << NS_ERROR_GET_CODE(aStatus) << "\n"; +#endif + +#ifdef NECKO + if (aStatus == NS_ERROR_UNKNOWN_HOST) + printf("Error: Unknown host: %s\n", url); + else if (aStatus == NS_ERROR_MALFORMED_URI) + printf("Error: Malformed URI: %s\n", url); + else if (NS_FAILED(rv)) + printf("Error: Can't load: %s (%x)\n", url, aStatus); + nsCRT::free(url); +#endif + } +#endif /* DEBUG */ + + if (nsnull != m_NextStream) { +#ifdef NECKO + rv = m_NextStream->OnStopRequest(channel, ctxt, aStatus, aMsg); +#else + rv = m_NextStream->OnStopRequest(aURL, aStatus, aMsg); +#endif + } + + /* Pass the notification out to the Observer... */ + if (nsnull != m_Observer) { + /* XXX: Should we ignore the return value? */ +#ifdef NECKO + (void) m_Observer->OnStopRequest(channel, ctxt, aStatus, aMsg); +#else + (void) m_Observer->OnStopRequest(aURL, aStatus, aMsg); +#endif + } + + /* + * The stream is complete... Tell the DocumentLoader to release us... + */ +#ifdef NECKO + rv = m_DocLoader->LoadURLComplete(channel, ctxt, (nsIStreamListener *)this, + aStatus, aMsg); +#else + rv = m_DocLoader->LoadURLComplete(aURL, (nsIStreamListener *)this, aStatus); +#endif + NS_IF_RELEASE(m_NextStream); + +#ifdef NECKO + if (aStatus == NS_ERROR_UNKNOWN_HOST) { // We need to check for a dns failure in aStatus, but dns failure codes // aren't proliferated yet. This checks for failure for a host lacking // "www." and/or ".com" and munges the url acordingly, then fires off @@ -2109,68 +2170,17 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons nsString2 newURL(aSpec); return m_DocLoader->LoadDocument(newURL, - m_Command, - m_Container, - nsnull, // XXX need to pass post data along - m_ExtraInfo, - m_Observer, - nsIChannel::LOAD_NORMAL, - 0); + m_Command, + m_Container, + nsnull, // XXX need to pass post data along + m_ExtraInfo, + m_Observer, + nsIChannel::LOAD_NORMAL, + 0); } -#endif // 0 - char *url; - if (NS_SUCCEEDED(rv)) - aURL->GetSpec(&url); - else - url = nsCRT::strdup(""); -#else - const char *url; - if (nsnull != aURL) - aURL->GetSpec(&url); - else - url = ""; + } #endif // NECKO -#ifdef DEBUG_pnunn - cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: " - << NS_ERROR_GET_CODE(aStatus) << "\n"; -#endif - -#ifdef NECKO - nsCRT::free(url); -#endif - } -#endif /* DEBUG */ - - if (nsnull != m_NextStream) { -#ifdef NECKO - rv = m_NextStream->OnStopRequest(channel, ctxt, aStatus, aMsg); -#else - rv = m_NextStream->OnStopRequest(aURL, aStatus, aMsg); -#endif - } - - /* Pass the notification out to the Observer... */ - if (nsnull != m_Observer) { - /* XXX: Should we ignore the return value? */ -#ifdef NECKO - (void) m_Observer->OnStopRequest(channel, ctxt, aStatus, aMsg); -#else - (void) m_Observer->OnStopRequest(aURL, aStatus, aMsg); -#endif - } - - /* - * The stream is complete... Tell the DocumentLoader to release us... - */ -#ifdef NECKO - rv = m_DocLoader->LoadURLComplete(channel, ctxt, (nsIStreamListener *)this, - aStatus, aMsg); -#else - rv = m_DocLoader->LoadURLComplete(aURL, (nsIStreamListener *)this, aStatus); -#endif - NS_IF_RELEASE(m_NextStream); - return rv; } diff --git a/mozilla/webshell/src/nsThrobber.cpp b/mozilla/webshell/src/nsThrobber.cpp index ccb47476ef7..5910ee83603 100644 --- a/mozilla/webshell/src/nsThrobber.cpp +++ b/mozilla/webshell/src/nsThrobber.cpp @@ -471,7 +471,7 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages } if (nsnull != mask) - delete [] mask; + nsAllocator::Free(mask); mWidget->Invalidate(PR_TRUE); diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index d12116bb6e0..4397abed7ae 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -27,6 +27,8 @@ #ifdef NECKO #include "nsIPrompt.h" #include "nsNeckoUtil.h" +#include "nsIProtocolHandler.h" +#include "nsIDNSService.h" #else #include "nsINetSupport.h" #include "nsIRefreshUrl.h" @@ -1866,6 +1868,18 @@ nsWebShell::DoLoadURL(const nsString& aUrlSpec, rv = NS_NewURL(getter_AddRefs(url), aUrlSpec); #else rv = NS_NewURI(getter_AddRefs(url), aUrlSpec); +#ifdef DEBUG + char* urlStr = aUrlSpec.ToNewCString(); + if (rv == NS_ERROR_UNKNOWN_PROTOCOL) + printf("Error: Unknown protocol: %s\n", urlStr); + else if (rv == NS_ERROR_UNKNOWN_HOST) + printf("Error: Unknown host: %s\n", urlStr); + else if (rv == NS_ERROR_MALFORMED_URI) + printf("Error: Malformed URI: %s\n", urlStr); + else if (NS_FAILED(rv)) + printf("Error: Can't load: %s (%x)\n", urlStr, rv); + nsCRT::free(urlStr); +#endif #endif // NECKO if (NS_FAILED(rv)) return rv; if (url && docURL && EqualBaseURLs(docURL, url)) { @@ -2695,7 +2709,7 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, { nsIWebShell* shell = GetTarget(target.GetUnicode()); if (nsnull != shell) { - shell->LoadURL(aURLSpec, aPostData); + (void)shell->LoadURL(aURLSpec, aPostData); NS_RELEASE(shell); } }