зеркало из https://github.com/mozilla/pjs.git
Fixed progress notifications to respect the nsIChannel::LOAD_BACKGROUND flag
This commit is contained in:
Родитель
6ff3742e4c
Коммит
a8446af14b
|
@ -776,7 +776,12 @@ nsHTTPChannel::OnStatus(nsIChannel *aChannel,
|
|||
NS_IMETHODIMP
|
||||
nsHTTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext,
|
||||
PRUint32 aProgress, PRUint32 aProgressMax) {
|
||||
// These progreess notifications are coming from the raw socket and are not
|
||||
// as interesting as the progress of HTTP channel (pushing the real data
|
||||
// to the consumer)...
|
||||
//
|
||||
// HTTP pushes out progress via the response listener.
|
||||
// See ReportProgress(...)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1409,6 +1414,23 @@ nsHTTPChannel::getChannelState()
|
|||
}
|
||||
|
||||
|
||||
nsresult nsHTTPChannel::ReportProgress(PRUint32 aProgress,
|
||||
PRUint32 aProgressMax)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
/*
|
||||
* Only fire progress notifications if the URI is being loaded in
|
||||
* the forground...
|
||||
*/
|
||||
if (!(nsIChannel::LOAD_BACKGROUND & mLoadAttributes) && mProgressEventSink) {
|
||||
rv = mProgressEventSink->OnProgress(this, mResponseContext,
|
||||
aProgress, aProgressMax);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsHTTPChannel::Redirect(const char *aNewLocation,
|
||||
nsIChannel **aResult)
|
||||
{
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
|
||||
PRUint32 getChannelState ();
|
||||
|
||||
nsresult ReportProgress(PRUint32 aProgress,
|
||||
PRUint32 aProgressMax);
|
||||
protected:
|
||||
nsresult CheckCache();
|
||||
nsresult ReadFromCache();
|
||||
|
|
|
@ -195,11 +195,7 @@ nsHTTPCacheListener::OnDataAvailable(nsIChannel *aChannel,
|
|||
mBodyBytesReceived += aCount;
|
||||
|
||||
// Report progress
|
||||
if (mChannel->mProgressEventSink) {
|
||||
rv = mChannel->mProgressEventSink->OnProgress(mChannel,
|
||||
mChannel->mResponseContext,
|
||||
mBodyBytesReceived, mContentLength);
|
||||
}
|
||||
rv = mChannel->ReportProgress(mBodyBytesReceived, mContentLength);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -549,12 +545,8 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel,
|
|||
mBodyBytesReceived += i_Length;
|
||||
|
||||
// Report progress
|
||||
if (mChannel->mProgressEventSink) {
|
||||
rv = mChannel->mProgressEventSink->OnProgress(mChannel,
|
||||
mChannel->mResponseContext,
|
||||
mBodyBytesReceived, cl);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mChannel->ReportProgress(mBodyBytesReceived, cl);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool eof = mChunkHeaderCtx.GetEOF ();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче