diff --git a/netwerk/protocol/file/src/nsFileChannel.cpp b/netwerk/protocol/file/src/nsFileChannel.cpp index 3e380d35ec5..3b8c178d362 100644 --- a/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/netwerk/protocol/file/src/nsFileChannel.cpp @@ -83,12 +83,14 @@ nsFileChannel::~nsFileChannel() { } -NS_IMPL_THREADSAFE_ISUPPORTS5(nsFileChannel, +NS_IMPL_THREADSAFE_ISUPPORTS7(nsFileChannel, nsIFileChannel, nsIChannel, nsIRequest, nsIStreamListener, - nsIStreamObserver) + nsIStreamObserver, + nsIProgressEventSink, + nsIInterfaceRequestor) NS_METHOD nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) @@ -222,7 +224,7 @@ nsFileChannel::EnsureTransport() if (NS_FAILED(rv)) return rv; } if (mCallbacks) { - rv = mFileTransport->SetNotificationCallbacks(mCallbacks); + rv = mFileTransport->SetNotificationCallbacks(this); if (NS_FAILED(rv)) return rv; } if (mTransferOffset) { @@ -586,6 +588,13 @@ NS_IMETHODIMP nsFileChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) { mCallbacks = aNotificationCallbacks; + + // Cache the new nsIProgressEventSink instance... + if (mCallbacks) { + (void)mCallbacks->GetInterface(NS_GET_IID(nsIProgressEventSink), + getter_AddRefs(mProgress)); + } + return NS_OK; } @@ -661,6 +670,57 @@ nsFileChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* contex 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 //////////////////////////////////////////////////////////////////////////////// diff --git a/netwerk/protocol/file/src/nsFileChannel.h b/netwerk/protocol/file/src/nsFileChannel.h index 911ab189dc9..f4a82c91f19 100644 --- a/netwerk/protocol/file/src/nsFileChannel.h +++ b/netwerk/protocol/file/src/nsFileChannel.h @@ -27,7 +27,6 @@ #include "nsIInterfaceRequestor.h" #include "nsILoadGroup.h" #include "nsIStreamListener.h" -#include "nsIChannel.h" #include "nsFileSpec.h" #include "nsIURI.h" #include "nsCOMPtr.h" @@ -36,21 +35,24 @@ #include "prlock.h" #include "nsIEventQueueService.h" #include "nsIPipe.h" -#include "nsILoadGroup.h" -#include "nsIStreamListener.h" #include "nsCOMPtr.h" #include "nsIFile.h" /* Solaris/gcc needed this here. */ +#include "nsIProgressEventSink.h" class nsFileChannel : public nsIFileChannel, - public nsIStreamListener + public nsIInterfaceRequestor, + public nsIStreamListener, + public nsIProgressEventSink { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST NS_DECL_NSICHANNEL NS_DECL_NSIFILECHANNEL + NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSISTREAMOBSERVER NS_DECL_NSISTREAMLISTENER + NS_DECL_NSIPROGRESSEVENTSINK nsFileChannel(); // Always make the destructor virtual: @@ -81,6 +83,7 @@ protected: PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; nsresult mStatus; + nsCOMPtr mProgress; #ifdef DEBUG PRThread* mInitiator; #endif