зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
733367d8b8
Коммит
7b882ed807
|
@ -715,7 +715,7 @@ nsFileTransport::Process(void)
|
||||||
LOG(("nsFileTransport: READING [this=%x %s] transferAmt=%u mBufferMaxSize=%u\n",
|
LOG(("nsFileTransport: READING [this=%x %s] transferAmt=%u mBufferMaxSize=%u\n",
|
||||||
this, mStreamName.get(), transferAmt, mBufferMaxSize));
|
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
|
// Give the listener a chance to read at most transferAmt bytes from
|
||||||
// the source input stream.
|
// the source input stream.
|
||||||
|
@ -762,7 +762,7 @@ nsFileTransport::Process(void)
|
||||||
mStatus = status;
|
mStatus = status;
|
||||||
mXferState = END_READ;
|
mXferState = END_READ;
|
||||||
}
|
}
|
||||||
else {
|
if (total) {
|
||||||
// something was read...
|
// something was read...
|
||||||
offset += total;
|
offset += total;
|
||||||
mOffset += total;
|
mOffset += total;
|
||||||
|
|
|
@ -197,6 +197,15 @@ nsStorageTransport::Available(PRUint32 aStartingFrom, PRUint32 *aCount)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsStorageTransport::FireOnProgress(nsIRequest *aRequest,
|
||||||
|
nsISupports *aContext,
|
||||||
|
PRUint32 aByteOffset)
|
||||||
|
{
|
||||||
|
if (mProgressSink)
|
||||||
|
mProgressSink->OnProgress(aRequest, aContext, aByteOffset, mWriteCursor);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsStorageTransport::AddWriteSegment()
|
nsStorageTransport::AddWriteSegment()
|
||||||
{
|
{
|
||||||
|
@ -285,7 +294,9 @@ NS_IMETHODIMP
|
||||||
nsStorageTransport::GetNotificationCallbacks(nsIInterfaceRequestor** aCallbacks)
|
nsStorageTransport::GetNotificationCallbacks(nsIInterfaceRequestor** aCallbacks)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCallbacks);
|
NS_ENSURE_ARG_POINTER(aCallbacks);
|
||||||
*aCallbacks = nsnull;
|
*aCallbacks = mCallbacks;
|
||||||
|
|
||||||
|
NS_IF_ADDREF(*aCallbacks);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +304,14 @@ NS_IMETHODIMP
|
||||||
nsStorageTransport::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks,
|
nsStorageTransport::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks,
|
||||||
PRUint32 flags)
|
PRUint32 flags)
|
||||||
{
|
{
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
mCallbacks = aCallbacks;
|
||||||
|
|
||||||
|
if (mCallbacks)
|
||||||
|
mProgressSink = do_QueryInterface(mCallbacks);
|
||||||
|
else
|
||||||
|
mProgressSink = 0;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -466,6 +484,8 @@ nsStorageTransport::nsReadRequest::Process()
|
||||||
this,
|
this,
|
||||||
mTransferOffset,
|
mTransferOffset,
|
||||||
count);
|
count);
|
||||||
|
// Fire the progress notification...
|
||||||
|
mTransport->FireOnProgress(this, mListenerContext, mTransferOffset);
|
||||||
}
|
}
|
||||||
else if ((mTransferCount == 0) || !mTransport->HasWriter()) {
|
else if ((mTransferCount == 0) || !mTransport->HasWriter()) {
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
#include "prclist.h"
|
#include "prclist.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
|
#include "nsIInterfaceRequestor.h"
|
||||||
|
#include "nsIProgressEventSink.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each "stream-based" memory cache entry has one transport
|
* Each "stream-based" memory cache entry has one transport
|
||||||
* associated with it. The transport supports multiple
|
* associated with it. The transport supports multiple
|
||||||
|
@ -155,6 +158,10 @@ public: /* internal */
|
||||||
|
|
||||||
PRBool HasWriter() { return (mOutputStream != nsnull); }
|
PRBool HasWriter() { return (mOutputStream != nsnull); }
|
||||||
|
|
||||||
|
void FireOnProgress(nsIRequest *aRequest,
|
||||||
|
nsISupports *aContext,
|
||||||
|
PRUint32 aOffset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,6 +199,9 @@ private:
|
||||||
|
|
||||||
nsSegment *mWriteSegment;
|
nsSegment *mWriteSegment;
|
||||||
PRUint32 mWriteCursor;
|
PRUint32 mWriteCursor;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||||
|
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -434,6 +434,10 @@ nsTransportWrapper::EnsureTransportWithAccess(nsCacheAccessMode mode)
|
||||||
descriptor->mAccessGranted,
|
descriptor->mAccessGranted,
|
||||||
getter_AddRefs(mTransport));
|
getter_AddRefs(mTransport));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (mCallbacks) {
|
||||||
|
mTransport->SetNotificationCallbacks(mCallbacks, mCallbackFlags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -468,9 +472,11 @@ NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||||
nsTransportWrapper::GetNotificationCallbacks(nsIInterfaceRequestor **result)
|
nsTransportWrapper::GetNotificationCallbacks(nsIInterfaceRequestor **result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(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,
|
nsTransportWrapper::SetNotificationCallbacks(nsIInterfaceRequestor *requestor,
|
||||||
PRUint32 flags)
|
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;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "nsCacheEntry.h"
|
#include "nsCacheEntry.h"
|
||||||
#include "nsIOutputStream.h"
|
#include "nsIOutputStream.h"
|
||||||
#include "nsITransport.h"
|
#include "nsITransport.h"
|
||||||
|
#include "nsIInterfaceRequestor.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* nsCacheEntryDescriptor
|
* nsCacheEntryDescriptor
|
||||||
|
@ -76,12 +77,15 @@ private:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
NS_DECL_NSITRANSPORT
|
NS_DECL_NSITRANSPORT
|
||||||
|
|
||||||
nsTransportWrapper() : mTransport(nsnull) {}
|
nsTransportWrapper() : mCallbackFlags(0) {}
|
||||||
virtual ~nsTransportWrapper() {}
|
virtual ~nsTransportWrapper() {}
|
||||||
|
|
||||||
nsresult EnsureTransportWithAccess(nsCacheAccessMode mode);
|
nsresult EnsureTransportWithAccess(nsCacheAccessMode mode);
|
||||||
|
|
||||||
|
PRUint32 mCallbackFlags;
|
||||||
|
|
||||||
nsCOMPtr<nsITransport> mTransport;
|
nsCOMPtr<nsITransport> mTransport;
|
||||||
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||||
}; // end of class nsTransportWrapper
|
}; // end of class nsTransportWrapper
|
||||||
friend class nsTransportWrapper;
|
friend class nsTransportWrapper;
|
||||||
|
|
||||||
|
|
|
@ -906,6 +906,12 @@ nsHttpChannel::ReadFromCache()
|
||||||
nsresult rv = mCacheEntry->GetTransport(getter_AddRefs(mCacheTransport));
|
nsresult rv = mCacheEntry->GetTransport(getter_AddRefs(mCacheTransport));
|
||||||
if (NS_FAILED(rv)) return rv;
|
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
|
// Pump the cache data downstream
|
||||||
return mCacheTransport->AsyncRead(this, mListenerContext,
|
return mCacheTransport->AsyncRead(this, mListenerContext,
|
||||||
0, PRUint32(-1), 0,
|
0, PRUint32(-1), 0,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче