Fixes for the 'timing' problem, where load time is reported incorrectly. Things seem to work now, except the very first load.

This commit is contained in:
warren%netscape.com 1999-07-30 07:50:35 +00:00
parent 558cdd62be
commit abb94bdcc3
4 changed files with 74 additions and 54 deletions

View File

@ -1329,10 +1329,12 @@ nsWebShell::GetObserver(nsIStreamObserver*& aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsWebShell::SetDocLoaderObserver(nsIDocumentLoaderObserver* anObserver) nsWebShell::SetDocLoaderObserver(nsIDocumentLoaderObserver* anObserver)
{ {
// if (anObserver != nsnull) {
NS_IF_RELEASE(mDocLoaderObserver); NS_IF_RELEASE(mDocLoaderObserver);
mDocLoaderObserver = anObserver; mDocLoaderObserver = anObserver;
NS_IF_ADDREF(mDocLoaderObserver); NS_IF_ADDREF(mDocLoaderObserver);
// }
return NS_OK; return NS_OK;
} }

View File

@ -267,6 +267,9 @@ public:
nsIURI* aURL, nsIURI* aURL,
const char* aCommand); const char* aCommand);
void FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator, void FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus); PRInt32 aStatus);
@ -312,9 +315,7 @@ public:
nsresult LoadURLComplete(nsIURI* aURL, nsISupports* aLoader, PRInt32 aStatus); nsresult LoadURLComplete(nsIURI* aURL, nsISupports* aLoader, PRInt32 aStatus);
#endif #endif
void SetParent(nsDocLoaderImpl* aParent); void SetParent(nsDocLoaderImpl* aParent);
#ifdef NECKO #ifndef NECKO
void SetDocumentChannel(nsIChannel* channel);
#else
void SetDocumentUrl(nsIURI* aUrl); void SetDocumentUrl(nsIURI* aUrl);
#endif #endif
@ -344,6 +345,9 @@ protected:
void ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild, void ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild,
nsIDocumentLoader* aLoadInitiator, nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus); PRInt32 aStatus);
#ifndef NECKO #ifndef NECKO
@ -361,9 +365,7 @@ protected:
// (ie, non owning) references. If you add any members to this // (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc). // class, please make the ownership explicit (pinkerton, scc).
#ifdef NECKO #ifndef NECKO
nsIChannel* mDocumentChannel; // [OWNER] ???compare with document
#else
nsIURI* mDocumentUrl; // [OWNER] ???compare with document nsIURI* mDocumentUrl; // [OWNER] ???compare with document
nsVoidArray mChildGroupList; nsVoidArray mChildGroupList;
nsCOMPtr<nsILoadAttribs> m_LoadAttrib; nsCOMPtr<nsILoadAttribs> m_LoadAttrib;
@ -405,9 +407,7 @@ nsDocLoaderImpl::nsDocLoaderImpl()
} }
#endif /* DEBUG || FORCE_PR_LOG */ #endif /* DEBUG || FORCE_PR_LOG */
#ifdef NECKO #ifndef NECKO
mDocumentChannel = nsnull;
#else
mDocumentUrl = nsnull; mDocumentUrl = nsnull;
mForegroundURLs = 0; mForegroundURLs = 0;
mTotalURLs = 0; mTotalURLs = 0;
@ -457,9 +457,7 @@ nsDocLoaderImpl::~nsDocLoaderImpl()
NS_RELEASE(mParent); NS_RELEASE(mParent);
} }
#ifdef NECKO #ifndef NECKO
NS_IF_RELEASE(mDocumentChannel);
#else
NS_IF_RELEASE(mDocumentUrl); NS_IF_RELEASE(mDocumentUrl);
#endif #endif
@ -1021,7 +1019,7 @@ NS_IMETHODIMP
nsDocLoaderImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsDocLoaderImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
nsresult status, const PRUnichar *errorMsg) nsresult status, const PRUnichar *errorMsg)
{ {
FireOnEndDocumentLoad(this, status); FireOnEndDocumentLoad(this, channel, status);
return NS_OK; return NS_OK;
} }
#endif #endif
@ -1078,6 +1076,9 @@ void nsDocLoaderImpl::FireOnStartDocumentLoad(nsIDocumentLoader* aLoadInitiator,
} }
void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator, void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus) PRInt32 aStatus)
{ {
@ -1092,7 +1093,7 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
mDocObservers.ElementAt(index); mDocObservers.ElementAt(index);
observer->OnEndDocumentLoad(aLoadInitiator, observer->OnEndDocumentLoad(aLoadInitiator,
#ifdef NECKO #ifdef NECKO
mDocumentChannel, channel,
#else #else
mDocumentUrl, mDocumentUrl,
#endif #endif
@ -1103,13 +1104,20 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
* Finally notify the parent... * Finally notify the parent...
*/ */
if (nsnull != mParent) { if (nsnull != mParent) {
mParent->ChildDocLoaderFiredEndDocumentLoad(this, aLoadInitiator, aStatus); mParent->ChildDocLoaderFiredEndDocumentLoad(this, aLoadInitiator,
#ifdef NECKO
channel,
#endif
aStatus);
} }
} }
void void
nsDocLoaderImpl::ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild, nsDocLoaderImpl::ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild,
nsIDocumentLoader* aLoadInitiator, nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus) PRInt32 aStatus)
{ {
PRBool busy; PRBool busy;
@ -1118,7 +1126,11 @@ nsDocLoaderImpl::ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild,
// If the parent is no longer busy because a child document // If the parent is no longer busy because a child document
// loader finished, then its time for the parent to fire its // loader finished, then its time for the parent to fire its
// on-end-document-load notification. // on-end-document-load notification.
FireOnEndDocumentLoad(aLoadInitiator, aStatus); FireOnEndDocumentLoad(aLoadInitiator,
#ifdef NECKO
channel,
#endif
aStatus);
} }
} }
@ -1357,7 +1369,11 @@ nsresult nsDocLoaderImpl::LoadURLComplete(nsIURI* aURL, nsISupports* aBindInfo,
this, buffer)); this, buffer));
#endif /* DEBUG */ #endif /* DEBUG */
FireOnEndDocumentLoad((nsIDocumentLoader *) this, aStatus); FireOnEndDocumentLoad((nsIDocumentLoader *) this,
#ifdef NECKO
channel,
#endif
aStatus);
} }
return NS_OK; return NS_OK;
#endif #endif
@ -1370,14 +1386,7 @@ void nsDocLoaderImpl::SetParent(nsDocLoaderImpl* aParent)
NS_IF_ADDREF(mParent); NS_IF_ADDREF(mParent);
} }
#ifdef NECKO #ifndef NECKO
void nsDocLoaderImpl::SetDocumentChannel(nsIChannel* channel)
{
NS_IF_RELEASE(mDocumentChannel);
mDocumentChannel = channel;
NS_IF_ADDREF(mDocumentChannel);
}
#else
void nsDocLoaderImpl::SetDocumentUrl(nsIURI* aUrl) void nsDocLoaderImpl::SetDocumentUrl(nsIURI* aUrl)
{ {
NS_IF_RELEASE(mDocumentUrl); NS_IF_RELEASE(mDocumentUrl);
@ -1587,6 +1596,7 @@ nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec,
#ifndef NECKO #ifndef NECKO
m_DocLoader->SetDocumentUrl(url); m_DocLoader->SetDocumentUrl(url);
#endif #endif
/* /*
* Fire the OnStarDocumentLoad interfaces * Fire the OnStarDocumentLoad interfaces
*/ */
@ -1655,8 +1665,6 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener)
rv = NS_OpenURI(getter_AddRefs(channel), aURL); rv = NS_OpenURI(getter_AddRefs(channel), aURL);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
m_DocLoader->SetDocumentChannel(channel);
rv = loadGroup->AddChannel(channel, nsnull); rv = loadGroup->AddChannel(channel, nsnull);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = channel->AsyncRead(0, -1, nsnull, this); rv = channel->AsyncRead(0, -1, nsnull, this);

View File

@ -267,6 +267,9 @@ public:
nsIURI* aURL, nsIURI* aURL,
const char* aCommand); const char* aCommand);
void FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator, void FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus); PRInt32 aStatus);
@ -312,9 +315,7 @@ public:
nsresult LoadURLComplete(nsIURI* aURL, nsISupports* aLoader, PRInt32 aStatus); nsresult LoadURLComplete(nsIURI* aURL, nsISupports* aLoader, PRInt32 aStatus);
#endif #endif
void SetParent(nsDocLoaderImpl* aParent); void SetParent(nsDocLoaderImpl* aParent);
#ifdef NECKO #ifndef NECKO
void SetDocumentChannel(nsIChannel* channel);
#else
void SetDocumentUrl(nsIURI* aUrl); void SetDocumentUrl(nsIURI* aUrl);
#endif #endif
@ -344,6 +345,9 @@ protected:
void ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild, void ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild,
nsIDocumentLoader* aLoadInitiator, nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus); PRInt32 aStatus);
#ifndef NECKO #ifndef NECKO
@ -361,9 +365,7 @@ protected:
// (ie, non owning) references. If you add any members to this // (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc). // class, please make the ownership explicit (pinkerton, scc).
#ifdef NECKO #ifndef NECKO
nsIChannel* mDocumentChannel; // [OWNER] ???compare with document
#else
nsIURI* mDocumentUrl; // [OWNER] ???compare with document nsIURI* mDocumentUrl; // [OWNER] ???compare with document
nsVoidArray mChildGroupList; nsVoidArray mChildGroupList;
nsCOMPtr<nsILoadAttribs> m_LoadAttrib; nsCOMPtr<nsILoadAttribs> m_LoadAttrib;
@ -405,9 +407,7 @@ nsDocLoaderImpl::nsDocLoaderImpl()
} }
#endif /* DEBUG || FORCE_PR_LOG */ #endif /* DEBUG || FORCE_PR_LOG */
#ifdef NECKO #ifndef NECKO
mDocumentChannel = nsnull;
#else
mDocumentUrl = nsnull; mDocumentUrl = nsnull;
mForegroundURLs = 0; mForegroundURLs = 0;
mTotalURLs = 0; mTotalURLs = 0;
@ -457,9 +457,7 @@ nsDocLoaderImpl::~nsDocLoaderImpl()
NS_RELEASE(mParent); NS_RELEASE(mParent);
} }
#ifdef NECKO #ifndef NECKO
NS_IF_RELEASE(mDocumentChannel);
#else
NS_IF_RELEASE(mDocumentUrl); NS_IF_RELEASE(mDocumentUrl);
#endif #endif
@ -1021,7 +1019,7 @@ NS_IMETHODIMP
nsDocLoaderImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsDocLoaderImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
nsresult status, const PRUnichar *errorMsg) nsresult status, const PRUnichar *errorMsg)
{ {
FireOnEndDocumentLoad(this, status); FireOnEndDocumentLoad(this, channel, status);
return NS_OK; return NS_OK;
} }
#endif #endif
@ -1078,6 +1076,9 @@ void nsDocLoaderImpl::FireOnStartDocumentLoad(nsIDocumentLoader* aLoadInitiator,
} }
void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator, void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus) PRInt32 aStatus)
{ {
@ -1092,7 +1093,7 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
mDocObservers.ElementAt(index); mDocObservers.ElementAt(index);
observer->OnEndDocumentLoad(aLoadInitiator, observer->OnEndDocumentLoad(aLoadInitiator,
#ifdef NECKO #ifdef NECKO
mDocumentChannel, channel,
#else #else
mDocumentUrl, mDocumentUrl,
#endif #endif
@ -1103,13 +1104,20 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsIDocumentLoader* aLoadInitiator,
* Finally notify the parent... * Finally notify the parent...
*/ */
if (nsnull != mParent) { if (nsnull != mParent) {
mParent->ChildDocLoaderFiredEndDocumentLoad(this, aLoadInitiator, aStatus); mParent->ChildDocLoaderFiredEndDocumentLoad(this, aLoadInitiator,
#ifdef NECKO
channel,
#endif
aStatus);
} }
} }
void void
nsDocLoaderImpl::ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild, nsDocLoaderImpl::ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild,
nsIDocumentLoader* aLoadInitiator, nsIDocumentLoader* aLoadInitiator,
#ifdef NECKO
nsIChannel* channel,
#endif
PRInt32 aStatus) PRInt32 aStatus)
{ {
PRBool busy; PRBool busy;
@ -1118,7 +1126,11 @@ nsDocLoaderImpl::ChildDocLoaderFiredEndDocumentLoad(nsDocLoaderImpl* aChild,
// If the parent is no longer busy because a child document // If the parent is no longer busy because a child document
// loader finished, then its time for the parent to fire its // loader finished, then its time for the parent to fire its
// on-end-document-load notification. // on-end-document-load notification.
FireOnEndDocumentLoad(aLoadInitiator, aStatus); FireOnEndDocumentLoad(aLoadInitiator,
#ifdef NECKO
channel,
#endif
aStatus);
} }
} }
@ -1357,7 +1369,11 @@ nsresult nsDocLoaderImpl::LoadURLComplete(nsIURI* aURL, nsISupports* aBindInfo,
this, buffer)); this, buffer));
#endif /* DEBUG */ #endif /* DEBUG */
FireOnEndDocumentLoad((nsIDocumentLoader *) this, aStatus); FireOnEndDocumentLoad((nsIDocumentLoader *) this,
#ifdef NECKO
channel,
#endif
aStatus);
} }
return NS_OK; return NS_OK;
#endif #endif
@ -1370,14 +1386,7 @@ void nsDocLoaderImpl::SetParent(nsDocLoaderImpl* aParent)
NS_IF_ADDREF(mParent); NS_IF_ADDREF(mParent);
} }
#ifdef NECKO #ifndef NECKO
void nsDocLoaderImpl::SetDocumentChannel(nsIChannel* channel)
{
NS_IF_RELEASE(mDocumentChannel);
mDocumentChannel = channel;
NS_IF_ADDREF(mDocumentChannel);
}
#else
void nsDocLoaderImpl::SetDocumentUrl(nsIURI* aUrl) void nsDocLoaderImpl::SetDocumentUrl(nsIURI* aUrl)
{ {
NS_IF_RELEASE(mDocumentUrl); NS_IF_RELEASE(mDocumentUrl);
@ -1587,6 +1596,7 @@ nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec,
#ifndef NECKO #ifndef NECKO
m_DocLoader->SetDocumentUrl(url); m_DocLoader->SetDocumentUrl(url);
#endif #endif
/* /*
* Fire the OnStarDocumentLoad interfaces * Fire the OnStarDocumentLoad interfaces
*/ */
@ -1655,8 +1665,6 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener)
rv = NS_OpenURI(getter_AddRefs(channel), aURL); rv = NS_OpenURI(getter_AddRefs(channel), aURL);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
m_DocLoader->SetDocumentChannel(channel);
rv = loadGroup->AddChannel(channel, nsnull); rv = loadGroup->AddChannel(channel, nsnull);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = channel->AsyncRead(0, -1, nsnull, this); rv = channel->AsyncRead(0, -1, nsnull, this);

View File

@ -1329,10 +1329,12 @@ nsWebShell::GetObserver(nsIStreamObserver*& aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsWebShell::SetDocLoaderObserver(nsIDocumentLoaderObserver* anObserver) nsWebShell::SetDocLoaderObserver(nsIDocumentLoaderObserver* anObserver)
{ {
// if (anObserver != nsnull) {
NS_IF_RELEASE(mDocLoaderObserver); NS_IF_RELEASE(mDocLoaderObserver);
mDocLoaderObserver = anObserver; mDocLoaderObserver = anObserver;
NS_IF_ADDREF(mDocLoaderObserver); NS_IF_ADDREF(mDocLoaderObserver);
// }
return NS_OK; return NS_OK;
} }