Clean up of nsDocumentBindInfo::OnStopRequest. Debug error messages for necko failure.

This commit is contained in:
warren%netscape.com 1999-07-30 04:20:34 +00:00
parent ec14999c47
commit 4863d69146
5 changed files with 173 additions and 125 deletions

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -471,7 +471,7 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages
}
if (nsnull != mask)
delete [] mask;
nsAllocator::Free(mask);
mWidget->Invalidate(PR_TRUE);

View File

@ -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);
}
}