зеркало из https://github.com/mozilla/pjs.git
The file channel needs to implement nsIProgressEventSink, so the channel parameter is *not* the file transport. Doing this means that the FileChannel also needs to implement nsIInterfaceRequestor...
This commit is contained in:
Родитель
08dc824141
Коммит
74ac421980
|
@ -83,12 +83,14 @@ nsFileChannel::~nsFileChannel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsFileChannel,
|
NS_IMPL_THREADSAFE_ISUPPORTS7(nsFileChannel,
|
||||||
nsIFileChannel,
|
nsIFileChannel,
|
||||||
nsIChannel,
|
nsIChannel,
|
||||||
nsIRequest,
|
nsIRequest,
|
||||||
nsIStreamListener,
|
nsIStreamListener,
|
||||||
nsIStreamObserver)
|
nsIStreamObserver,
|
||||||
|
nsIProgressEventSink,
|
||||||
|
nsIInterfaceRequestor)
|
||||||
|
|
||||||
NS_METHOD
|
NS_METHOD
|
||||||
nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||||
|
@ -222,7 +224,7 @@ nsFileChannel::EnsureTransport()
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
if (mCallbacks) {
|
if (mCallbacks) {
|
||||||
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
|
rv = mFileTransport->SetNotificationCallbacks(this);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
if (mTransferOffset) {
|
if (mTransferOffset) {
|
||||||
|
@ -586,6 +588,13 @@ NS_IMETHODIMP
|
||||||
nsFileChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
nsFileChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
||||||
{
|
{
|
||||||
mCallbacks = aNotificationCallbacks;
|
mCallbacks = aNotificationCallbacks;
|
||||||
|
|
||||||
|
// Cache the new nsIProgressEventSink instance...
|
||||||
|
if (mCallbacks) {
|
||||||
|
(void)mCallbacks->GetInterface(NS_GET_IID(nsIProgressEventSink),
|
||||||
|
getter_AddRefs(mProgress));
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,6 +670,57 @@ nsFileChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* contex
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// From nsIInterfaceRequestor
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsFileChannel::GetInterface(const nsIID &anIID, void **aResult )
|
||||||
|
{
|
||||||
|
// capture the progress event sink stuff. pass the rest through.
|
||||||
|
if (anIID.Equals(NS_GET_IID(nsIProgressEventSink))) {
|
||||||
|
*aResult = NS_STATIC_CAST(nsIProgressEventSink*, this);
|
||||||
|
NS_ADDREF(this);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
else if (mCallbacks) {
|
||||||
|
return mCallbacks->GetInterface(anIID, aResult);
|
||||||
|
}
|
||||||
|
return NS_ERROR_NO_INTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// From nsIProgressEventSink
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsFileChannel::OnStatus(nsIChannel *aChannel,
|
||||||
|
nsISupports *aContext,
|
||||||
|
const PRUnichar *aMsg)
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
if (mProgress) {
|
||||||
|
mProgress->OnStatus(this, aContext, aMsg);
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsFileChannel::OnProgress(nsIChannel* aChannel,
|
||||||
|
nsISupports* aContext,
|
||||||
|
PRUint32 aProgress,
|
||||||
|
PRUint32 aProgressMax)
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
if (mProgress) {
|
||||||
|
rv = mProgress->OnProgress(this, aContext, aProgress, aProgressMax);
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// From nsIFileChannel
|
// From nsIFileChannel
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
#include "nsILoadGroup.h"
|
#include "nsILoadGroup.h"
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
#include "nsIChannel.h"
|
|
||||||
#include "nsFileSpec.h"
|
#include "nsFileSpec.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
@ -36,21 +35,24 @@
|
||||||
#include "prlock.h"
|
#include "prlock.h"
|
||||||
#include "nsIEventQueueService.h"
|
#include "nsIEventQueueService.h"
|
||||||
#include "nsIPipe.h"
|
#include "nsIPipe.h"
|
||||||
#include "nsILoadGroup.h"
|
|
||||||
#include "nsIStreamListener.h"
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIFile.h" /* Solaris/gcc needed this here. */
|
#include "nsIFile.h" /* Solaris/gcc needed this here. */
|
||||||
|
#include "nsIProgressEventSink.h"
|
||||||
|
|
||||||
class nsFileChannel : public nsIFileChannel,
|
class nsFileChannel : public nsIFileChannel,
|
||||||
public nsIStreamListener
|
public nsIInterfaceRequestor,
|
||||||
|
public nsIStreamListener,
|
||||||
|
public nsIProgressEventSink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIREQUEST
|
NS_DECL_NSIREQUEST
|
||||||
NS_DECL_NSICHANNEL
|
NS_DECL_NSICHANNEL
|
||||||
NS_DECL_NSIFILECHANNEL
|
NS_DECL_NSIFILECHANNEL
|
||||||
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
NS_DECL_NSISTREAMOBSERVER
|
NS_DECL_NSISTREAMOBSERVER
|
||||||
NS_DECL_NSISTREAMLISTENER
|
NS_DECL_NSISTREAMLISTENER
|
||||||
|
NS_DECL_NSIPROGRESSEVENTSINK
|
||||||
|
|
||||||
nsFileChannel();
|
nsFileChannel();
|
||||||
// Always make the destructor virtual:
|
// Always make the destructor virtual:
|
||||||
|
@ -81,6 +83,7 @@ protected:
|
||||||
PRUint32 mBufferSegmentSize;
|
PRUint32 mBufferSegmentSize;
|
||||||
PRUint32 mBufferMaxSize;
|
PRUint32 mBufferMaxSize;
|
||||||
nsresult mStatus;
|
nsresult mStatus;
|
||||||
|
nsCOMPtr<nsIProgressEventSink> mProgress;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
PRThread* mInitiator;
|
PRThread* mInitiator;
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче