зеркало из https://github.com/mozilla/pjs.git
when determining progress for a cache entry, use the content length
for the cache entry as the total max progress. This change gives us more accurate progress for loading entries from the cache for http.
This commit is contained in:
Родитель
6efdc1c5cb
Коммит
199d1c9074
|
@ -136,7 +136,11 @@ nsHTTPCacheListener::OnStartRequest(nsIChannel *aChannel,
|
|||
nsISupports *aContext)
|
||||
{
|
||||
PR_LOG (gHTTPLog, PR_LOG_DEBUG, ("nsHTTPCacheListener::OnStartRequest [this=%x]\n", this));
|
||||
|
||||
mBodyBytesReceived = 0;
|
||||
|
||||
// get and store the content length which will be used in ODA for computing
|
||||
// progress information.
|
||||
aChannel->GetContentLength(&mContentLength);
|
||||
return mResponseDataListener->OnStartRequest(mChannel, aContext);
|
||||
}
|
||||
|
||||
|
@ -183,13 +187,16 @@ nsHTTPCacheListener::OnDataAvailable(nsIChannel *aChannel,
|
|||
aCount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
mBodyBytesReceived += aCount;
|
||||
|
||||
// Report progress
|
||||
if (mChannel->mProgressEventSink) {
|
||||
rv = mChannel->mProgressEventSink->OnProgress(mChannel,
|
||||
mChannel->mResponseContext,
|
||||
aSourceOffset, aCount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mBodyBytesReceived, mContentLength);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,9 @@ public:
|
|||
virtual nsresult FireSingleOnData(nsIStreamListener *aListener,
|
||||
nsISupports *aContext);
|
||||
virtual nsresult Abort();
|
||||
protected:
|
||||
PRInt32 mBodyBytesReceived;
|
||||
PRInt32 mContentLength;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче