bug #82458 (r=jst, sr=darin, a=blizzard). THis patch causes STATE_TRANSFERRING notifications to fire when URLs are loaded out of the disk cache or memory cache...

This commit is contained in:
rpotts%netscape.com 2001-06-25 06:22:44 +00:00
Родитель 733367d8b8
Коммит 7b882ed807
6 изменённых файлов: 61 добавлений и 10 удалений

Просмотреть файл

@ -715,7 +715,7 @@ nsFileTransport::Process(void)
LOG(("nsFileTransport: READING [this=%x %s] transferAmt=%u mBufferMaxSize=%u\n",
this, mStreamName.get(), transferAmt, mBufferMaxSize));
PRUint32 total, offset = mSourceWrapper->GetBytesRead();
PRUint32 total = 0, offset = mSourceWrapper->GetBytesRead();
// Give the listener a chance to read at most transferAmt bytes from
// the source input stream.
@ -762,7 +762,7 @@ nsFileTransport::Process(void)
mStatus = status;
mXferState = END_READ;
}
else {
if (total) {
// something was read...
offset += total;
mOffset += total;

Просмотреть файл

@ -197,6 +197,15 @@ nsStorageTransport::Available(PRUint32 aStartingFrom, PRUint32 *aCount)
return NS_OK;
}
void
nsStorageTransport::FireOnProgress(nsIRequest *aRequest,
nsISupports *aContext,
PRUint32 aByteOffset)
{
if (mProgressSink)
mProgressSink->OnProgress(aRequest, aContext, aByteOffset, mWriteCursor);
}
nsresult
nsStorageTransport::AddWriteSegment()
{
@ -285,7 +294,9 @@ NS_IMETHODIMP
nsStorageTransport::GetNotificationCallbacks(nsIInterfaceRequestor** aCallbacks)
{
NS_ENSURE_ARG_POINTER(aCallbacks);
*aCallbacks = nsnull;
*aCallbacks = mCallbacks;
NS_IF_ADDREF(*aCallbacks);
return NS_OK;
}
@ -293,7 +304,14 @@ NS_IMETHODIMP
nsStorageTransport::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks,
PRUint32 flags)
{
return NS_ERROR_NOT_IMPLEMENTED;
mCallbacks = aCallbacks;
if (mCallbacks)
mProgressSink = do_QueryInterface(mCallbacks);
else
mProgressSink = 0;
return NS_OK;
}
NS_IMETHODIMP
@ -466,6 +484,8 @@ nsStorageTransport::nsReadRequest::Process()
this,
mTransferOffset,
count);
// Fire the progress notification...
mTransport->FireOnProgress(this, mListenerContext, mTransferOffset);
}
else if ((mTransferCount == 0) || !mTransport->HasWriter()) {

Просмотреть файл

@ -31,6 +31,9 @@
#include "prclist.h"
#include "nsCOMPtr.h"
#include "nsIInterfaceRequestor.h"
#include "nsIProgressEventSink.h"
/**
* Each "stream-based" memory cache entry has one transport
* associated with it. The transport supports multiple
@ -155,6 +158,10 @@ public: /* internal */
PRBool HasWriter() { return (mOutputStream != nsnull); }
void FireOnProgress(nsIRequest *aRequest,
nsISupports *aContext,
PRUint32 aOffset);
private:
/**
@ -192,6 +199,9 @@ private:
nsSegment *mWriteSegment;
PRUint32 mWriteCursor;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIProgressEventSink> mProgressSink;
};
#endif

19
netwerk/cache/src/nsCacheEntryDescriptor.cpp поставляемый
Просмотреть файл

@ -434,6 +434,10 @@ nsTransportWrapper::EnsureTransportWithAccess(nsCacheAccessMode mode)
descriptor->mAccessGranted,
getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;
if (mCallbacks) {
mTransport->SetNotificationCallbacks(mCallbacks, mCallbackFlags);
}
}
return NS_OK;
}
@ -468,9 +472,11 @@ NS_IMETHODIMP nsCacheEntryDescriptor::
nsTransportWrapper::GetNotificationCallbacks(nsIInterfaceRequestor **result)
{
NS_ENSURE_ARG_POINTER(result);
// if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
return NS_ERROR_NOT_IMPLEMENTED;
*result = mCallbacks;
NS_IF_ADDREF(*result);
return NS_OK;
}
@ -478,9 +484,14 @@ NS_IMETHODIMP nsCacheEntryDescriptor::
nsTransportWrapper::SetNotificationCallbacks(nsIInterfaceRequestor *requestor,
PRUint32 flags)
{
// if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
if (mTransport) {
mTransport->SetNotificationCallbacks(requestor, flags);
}
return NS_ERROR_NOT_IMPLEMENTED;
mCallbacks = requestor;
mCallbackFlags = flags;
return NS_OK;;
}

8
netwerk/cache/src/nsCacheEntryDescriptor.h поставляемый
Просмотреть файл

@ -29,6 +29,7 @@
#include "nsCacheEntry.h"
#include "nsIOutputStream.h"
#include "nsITransport.h"
#include "nsIInterfaceRequestor.h"
/******************************************************************************
* nsCacheEntryDescriptor
@ -76,12 +77,15 @@ private:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSITRANSPORT
nsTransportWrapper() : mTransport(nsnull) {}
nsTransportWrapper() : mCallbackFlags(0) {}
virtual ~nsTransportWrapper() {}
nsresult EnsureTransportWithAccess(nsCacheAccessMode mode);
nsCOMPtr<nsITransport> mTransport;
PRUint32 mCallbackFlags;
nsCOMPtr<nsITransport> mTransport;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
}; // end of class nsTransportWrapper
friend class nsTransportWrapper;

Просмотреть файл

@ -906,6 +906,12 @@ nsHttpChannel::ReadFromCache()
nsresult rv = mCacheEntry->GetTransport(getter_AddRefs(mCacheTransport));
if (NS_FAILED(rv)) return rv;
// Hookup the notification callbacks interface to the new transport...
mCacheTransport->SetNotificationCallbacks(this,
((mLoadFlags & nsIRequest::LOAD_BACKGROUND)
? nsITransport::DONT_REPORT_PROGRESS
: 0));
// Pump the cache data downstream
return mCacheTransport->AsyncRead(this, mListenerContext,
0, PRUint32(-1), 0,