diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index 9855b24b36c..d1806eb89c9 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -133,9 +133,7 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER #else NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 Progress, PRUint32 ProgressMax) { return NS_OK; } NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg) { return NS_OK; } @@ -144,6 +142,13 @@ public: #endif }; +#ifdef NECKO +NS_IMETHODIMP CStreamListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +{ + return NS_OK; +} +#endif + #ifdef NECKO NS_IMETHODIMP CStreamListener::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index dca2ac96da7..135477578ff 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -73,9 +73,7 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER #else // nsIStreamObserver NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType); diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index dca2ac96da7..135477578ff 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -73,9 +73,7 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER #else // nsIStreamObserver NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType); diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h index f753fee6b11..c4e281c4637 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h @@ -65,9 +65,7 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER #else // nsIStreamObserver NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType); diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.h b/mozilla/mailnews/compose/src/nsMsgCompose.h index f0e25adbcf2..9024f72c8ae 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.h +++ b/mozilla/mailnews/compose/src/nsMsgCompose.h @@ -149,21 +149,13 @@ public: QuotingOutputStreamListener(const PRUnichar *originalMsgURI, PRBool quoteHeaders); virtual ~QuotingOutputStreamListener(void); - // nsISupports interface NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER - // nsIStreamListener interface - NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, - nsISupports *ctxt, - nsIInputStream *inStr, - PRUint32 sourceOffset, - PRUint32 count); - NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); - - NS_IMETHOD SetComposeObj(nsMsgCompose *obj); - NS_IMETHOD ConvertToPlainText(); - NS_IMETHOD SetMimeHeaders(nsIMimeHeaders * headers); + NS_IMETHOD SetComposeObj(nsMsgCompose *obj); + NS_IMETHOD ConvertToPlainText(); + NS_IMETHOD SetMimeHeaders(nsIMimeHeaders * headers); private: nsMsgCompose * mComposeObj; diff --git a/mozilla/mailnews/imap/src/nsImapProtocol.h b/mozilla/mailnews/imap/src/nsImapProtocol.h index 2f5153fc99c..1f1de577c8b 100644 --- a/mozilla/mailnews/imap/src/nsImapProtocol.h +++ b/mozilla/mailnews/imap/src/nsImapProtocol.h @@ -93,11 +93,9 @@ public: // Whenever data arrives from the connection, core netlib notifies the protocol by calling // OnDataAvailable. We then read and process the incoming data from the input stream. - NS_IMETHOD OnDataAvailable(nsIChannel * aChannel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count); - NS_IMETHOD OnStartRequest(nsIChannel * aChannel,nsISupports *ctxt); // stop binding is a "notification" informing us that the stream associated with aURL is going away. - - NS_IMETHOD OnStopRequest(nsIChannel * aChannel,nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg); + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER // This is evil, I guess, but this is used by libmsg to tell a running imap url // about headers it should download to update a local database. diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 9f6e471e254..43d9fe10c7d 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -481,15 +481,8 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, - const PRUnichar *errorMsg); - - // nsIStreamListener methods: - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, - PRUint32 sourceOffset, PRUint32 count); - + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER #else //nsIStreamObserver interface diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 9f6e471e254..43d9fe10c7d 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -481,15 +481,8 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, - const PRUnichar *errorMsg); - - // nsIStreamListener methods: - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, - PRUint32 sourceOffset, PRUint32 count); - + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER #else //nsIStreamObserver interface diff --git a/mozilla/netwerk/base/public/MANIFEST b/mozilla/netwerk/base/public/MANIFEST index 8aa2acaad4f..65e2550b23f 100644 --- a/mozilla/netwerk/base/public/MANIFEST +++ b/mozilla/netwerk/base/public/MANIFEST @@ -4,4 +4,3 @@ netCore.h nsIProxy.h -nsISocketTransportService.h diff --git a/mozilla/netwerk/base/public/MANIFEST_IDL b/mozilla/netwerk/base/public/MANIFEST_IDL index 3ab48b1ac3a..52b2cc8fb3b 100644 --- a/mozilla/netwerk/base/public/MANIFEST_IDL +++ b/mozilla/netwerk/base/public/MANIFEST_IDL @@ -9,3 +9,5 @@ nsIURI.idl nsIURL.idl nsIChannel.idl nsIRequest.idl +nsISocketTransportService.idl +nsIFileTransportService.idl diff --git a/mozilla/netwerk/base/public/Makefile.in b/mozilla/netwerk/base/public/Makefile.in index f3bb001944d..5baba14e38c 100644 --- a/mozilla/netwerk/base/public/Makefile.in +++ b/mozilla/netwerk/base/public/Makefile.in @@ -42,12 +42,12 @@ XPIDLSRCS = \ nsINetNotify.idl \ nsILoadGroup.idl \ nsIStreamConverter2.idl \ + nsIFileTransportService.idl \ + nsISocketTransportService.idl \ $(NULL) EXPORTS = \ netCore.h \ - nsIFileTransportService.h \ - nsISocketTransportService.h \ nsIProxy.h \ $(NULL) diff --git a/mozilla/netwerk/base/public/makefile.win b/mozilla/netwerk/base/public/makefile.win index 74e77ea7f92..41ed1e664af 100644 --- a/mozilla/netwerk/base/public/makefile.win +++ b/mozilla/netwerk/base/public/makefile.win @@ -22,28 +22,28 @@ include <$(DEPTH)/config/config.mak> EXPORTS = \ netCore.h \ - nsIFileTransportService.h \ - nsISocketTransportService.h \ nsIProxy.h \ $(NULL) -XPIDLSRCS = \ - .\nsIRequest.idl \ - .\nsIChannel.idl \ - .\nsIURI.idl \ - .\nsIURL.idl \ - .\nsIStreamObserver.idl \ - .\nsIStreamListener.idl \ - .\nsIIOService.idl \ - .\nsIEventSinkGetter.idl \ - .\nsIPrompt.idl \ - .\nsIProtocolHandler.idl \ - .\nsIProgressEventSink.idl \ - .\nsINetModRegEntry.idl \ - .\nsINetModuleMgr.idl \ - .\nsINetNotify.idl \ - .\nsILoadGroup.idl \ - .\nsIStreamConverter2.idl \ +XPIDLSRCS = \ + .\nsIRequest.idl \ + .\nsIChannel.idl \ + .\nsIURI.idl \ + .\nsIURL.idl \ + .\nsIStreamObserver.idl \ + .\nsIStreamListener.idl \ + .\nsIIOService.idl \ + .\nsIEventSinkGetter.idl \ + .\nsIPrompt.idl \ + .\nsIProtocolHandler.idl \ + .\nsIProgressEventSink.idl \ + .\nsINetModRegEntry.idl \ + .\nsINetModuleMgr.idl \ + .\nsINetNotify.idl \ + .\nsILoadGroup.idl \ + .\nsIStreamConverter2.idl \ + .\nsISocketTransportService.idl \ + .\nsIFileTransportService.idl \ $(NULL) include <$(DEPTH)/config/rules.mak> diff --git a/mozilla/netwerk/base/public/nsIEventSinkGetter.idl b/mozilla/netwerk/base/public/nsIEventSinkGetter.idl index ae7b45a2a0c..d8c80f82b26 100644 --- a/mozilla/netwerk/base/public/nsIEventSinkGetter.idl +++ b/mozilla/netwerk/base/public/nsIEventSinkGetter.idl @@ -21,6 +21,6 @@ [scriptable, uuid(fb65fd70-1881-11d3-9337-00104ba0fd40)] interface nsIEventSinkGetter : nsISupports { - nsISupports GetEventSink(in string verb, in nsIIDRef eventSinkIID); + nsISupports GetEventSink(in string command, in nsIIDRef eventSinkIID); }; diff --git a/mozilla/netwerk/base/src/Makefile.in b/mozilla/netwerk/base/src/Makefile.in index 6301c3717f4..f477dbbb4d3 100644 --- a/mozilla/netwerk/base/src/Makefile.in +++ b/mozilla/netwerk/base/src/Makefile.in @@ -31,12 +31,15 @@ CPPSRCS = \ nsIOService.cpp \ nsSocketTransport.cpp \ nsSocketTransportService.cpp \ + nsFileTransport.cpp \ + nsFileTransportService.cpp \ nsStdURL.cpp \ nsSimpleURI.cpp \ nsNetModuleMgr.cpp \ nsNetModRegEntry.cpp \ nsLoadGroup.cpp \ nsInputStreamChannel.cpp \ + nsDirectoryIndexStream.cpp \ $(NULL) # we don't want the shared lib, but we want to force the creation of a diff --git a/mozilla/netwerk/base/src/makefile.win b/mozilla/netwerk/base/src/makefile.win index 782a4e09ee4..a6d7030f974 100644 --- a/mozilla/netwerk/base/src/makefile.win +++ b/mozilla/netwerk/base/src/makefile.win @@ -28,12 +28,15 @@ CPP_OBJS = \ .\$(OBJDIR)\nsIOService.obj \ .\$(OBJDIR)\nsSocketTransport.obj \ .\$(OBJDIR)\nsSocketTransportService.obj \ - .\$(OBJDIR)\nsStdURL.obj \ + .\$(OBJDIR)\nsFileTransport.obj \ + .\$(OBJDIR)\nsFileTransportService.obj \ + .\$(OBJDIR)\nsStdURL.obj \ .\$(OBJDIR)\nsSimpleURI.obj \ .\$(OBJDIR)\nsNetModuleMgr.obj \ .\$(OBJDIR)\nsNetModRegEntry.obj \ .\$(OBJDIR)\nsLoadGroup.obj \ .\$(OBJDIR)\nsInputStreamChannel.obj \ + .\$(OBJDIR)\nsDirectoryIndexStream.obj \ $(NULL) INCS = $(INCS) \ diff --git a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp index 5bd337a9128..28780ccadfa 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp @@ -17,14 +17,15 @@ */ #include "nsInputStreamChannel.h" -#include "nsIStreamListener.h" #include "nsCOMPtr.h" #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsIMIMEService.h" +#include "nsIFileTransportService.h" + static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); - +static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// // nsInputStreamChannel methods: @@ -67,7 +68,11 @@ nsInputStreamChannel::Init(nsIURI* uri, const char* contentType, return NS_OK; } -NS_IMPL_ISUPPORTS(nsInputStreamChannel, NS_GET_IID(nsIChannel)); +NS_IMPL_ISUPPORTS4(nsInputStreamChannel, + nsIChannel, + nsIRequest, + nsIStreamObserver, + nsIStreamListener); //////////////////////////////////////////////////////////////////////////////// // nsIRequest methods: @@ -75,6 +80,8 @@ NS_IMPL_ISUPPORTS(nsInputStreamChannel, NS_GET_IID(nsIChannel)); NS_IMETHODIMP nsInputStreamChannel::IsPending(PRBool *result) { + if (mFileTransport) + return mFileTransport->IsPending(result); *result = PR_FALSE; return NS_OK; } @@ -82,18 +89,24 @@ nsInputStreamChannel::IsPending(PRBool *result) NS_IMETHODIMP nsInputStreamChannel::Cancel(void) { + if (mFileTransport) + return mFileTransport->Cancel(); return NS_OK; } NS_IMETHODIMP nsInputStreamChannel::Suspend(void) { + if (mFileTransport) + return mFileTransport->Suspend(); return NS_OK; } NS_IMETHODIMP nsInputStreamChannel::Resume(void) { + if (mFileTransport) + return mFileTransport->Resume(); return NS_OK; } @@ -130,6 +143,7 @@ NS_IMETHODIMP nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener) { +#if 0 // currently this happens before AsyncRead returns -- hope that's ok nsresult rv; @@ -154,12 +168,45 @@ nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, rv = listener->OnStopRequest(this, ctxt, rv, nsnull); // XXX error message return rv; +#else + nsresult rv; + + mRealListener = listener; + + if (mLoadGroup) { + nsCOMPtr factory; + // + // Create a load group "proxy" listener... + // + rv = mLoadGroup->GetGroupListenerFactory(getter_AddRefs(factory)); + if (factory) { + nsIStreamListener *newListener; + rv = factory->CreateLoadGroupListener(mRealListener, &newListener); + if (NS_SUCCEEDED(rv)) { + mRealListener = newListener; + NS_RELEASE(newListener); + } + } + + rv = mLoadGroup->AddChannel(this, nsnull); + if (NS_FAILED(rv)) return rv; + } + + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = fts->CreateTransportFromStream(mInputStream, "load", nsnull, + getter_AddRefs(mFileTransport)); + if (NS_FAILED(rv)) return rv; + + return mFileTransport->AsyncRead(startPosition, readCount, ctxt, this); +#endif } NS_IMETHODIMP nsInputStreamChannel::AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition, - PRInt32 writeCount, nsISupports *ctxt, - nsIStreamObserver *observer) + PRInt32 writeCount, nsISupports *ctxt, + nsIStreamObserver *observer) { // we don't do output return NS_ERROR_FAILURE; @@ -212,8 +259,8 @@ nsInputStreamChannel::GetContentType(char * *aContentType) } // if all else fails treat it as text/html? - if (!*aContentType) - *aContentType = nsCRT::strdup(DUMMY_TYPE); + if (!*aContentType) + *aContentType = nsCRT::strdup(DUMMY_TYPE); if (!*aContentType) { rv = NS_ERROR_OUT_OF_MEMORY; } else { @@ -255,3 +302,43 @@ nsInputStreamChannel::SetOwner(nsISupports * aOwner) } //////////////////////////////////////////////////////////////////////////////// +// nsIStreamListener methods: +//////////////////////////////////////////////////////////////////////////////// + +NS_IMETHODIMP +nsInputStreamChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) +{ + NS_ASSERTION(mRealListener, "No listener..."); + return mRealListener->OnStartRequest(this, context); +} + +NS_IMETHODIMP +nsInputStreamChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, + nsresult aStatus, const PRUnichar* aMsg) +{ + nsresult rv; + + rv = mRealListener->OnStopRequest(this, context, aStatus, aMsg); + + if (mLoadGroup) { + if (NS_SUCCEEDED(rv)) { + mLoadGroup->RemoveChannel(this, context, aStatus, aMsg); + } + } + + // Release the reference to the consumer stream listener... + mRealListener = null_nsCOMPtr(); + mFileTransport = null_nsCOMPtr(); + return rv; +} + +NS_IMETHODIMP +nsInputStreamChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, + nsIInputStream *aIStream, PRUint32 aSourceOffset, + PRUint32 aLength) +{ + return mRealListener->OnDataAvailable(this, context, aIStream, + aSourceOffset, aLength); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/base/src/nsInputStreamChannel.h b/mozilla/netwerk/base/src/nsInputStreamChannel.h index 86c9c569f58..425c4bd2817 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.h +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.h @@ -24,20 +24,19 @@ #include "nsIURI.h" #include "nsCRT.h" #include "nsILoadGroup.h" +#include "nsIStreamListener.h" #include "nsCOMPtr.h" -class nsInputStreamChannel : public nsIChannel +class nsInputStreamChannel : public nsIChannel, + public nsIStreamListener { public: NS_DECL_ISUPPORTS - - // nsIRequest methods: NS_DECL_NSIREQUEST - - // nsIChannel methods: NS_DECL_NSICHANNEL + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER - // nsInputStreamChannel methods: nsInputStreamChannel(); virtual ~nsInputStreamChannel(); @@ -52,6 +51,8 @@ protected: nsCOMPtr mInputStream; nsCOMPtr mLoadGroup; nsCOMPtr mOwner; + nsCOMPtr mFileTransport; + nsCOMPtr mRealListener; }; #define NS_INPUTSTREAMCHANNEL_CID \ diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index f20347f4262..eb3b7bd6f5f 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -1143,6 +1143,7 @@ nsSocketTransport::QueryInterface(const nsIID& aIID, void* *aInstancePtr) return NS_ERROR_NULL_POINTER; } if (aIID.Equals(NS_GET_IID(nsIChannel)) || + aIID.Equals(NS_GET_IID(nsIRequest)) || aIID.Equals(NS_GET_IID(nsISupports))) { *aInstancePtr = NS_STATIC_CAST(nsIChannel*, this); NS_ADDREF_THIS(); diff --git a/mozilla/netwerk/base/src/nsSocketTransport.h b/mozilla/netwerk/base/src/nsSocketTransport.h index 5cfa456880a..a9fdda3f67a 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.h +++ b/mozilla/netwerk/base/src/nsSocketTransport.h @@ -123,13 +123,8 @@ class nsSocketTransport : public nsIChannel, #endif { public: - // nsISupports methods: NS_DECL_ISUPPORTS - - // nsIRequest methods: NS_DECL_NSIREQUEST - - // nsIChannel methods: NS_DECL_NSICHANNEL #ifndef NSPIPE2 @@ -239,9 +234,7 @@ protected: nsCOMPtr mWritePipeIn; nsCOMPtr mWritePipeOut; #endif - PRUint32 mSourceOffset; - nsSocketTransportService* mService; PRUint32 mLoadAttributes; diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.cpp b/mozilla/netwerk/base/src/nsSocketTransportService.cpp index a8e73ad6b08..bef92a59aaa 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransportService.cpp @@ -1,3 +1,4 @@ + /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License @@ -485,14 +486,14 @@ nsSocketTransportService::CreateTransport(const char* aHost, PRInt32 aPort, nsIChannel** aResult) { - return CreateTransport(aHost, aPort, nsnull, aResult); + return CreateTransportOfType(nsnull, aHost, aPort, aResult); } NS_IMETHODIMP -nsSocketTransportService::CreateTransport(const char* aHost, - PRInt32 aPort, - const char* aSocketType, - nsIChannel** aResult) +nsSocketTransportService::CreateTransportOfType(const char* aSocketType, + const char* aHost, + PRInt32 aPort, + nsIChannel** aResult) { nsresult rv = NS_OK; nsSocketTransport* transport = nsnull; diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.h b/mozilla/netwerk/base/src/nsSocketTransportService.h index 3081bc958bb..11ef48c7166 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.h +++ b/mozilla/netwerk/base/src/nsSocketTransportService.h @@ -42,21 +42,8 @@ class nsSocketTransportService : public nsISocketTransportService, { public: NS_DECL_ISUPPORTS - - // nsISocketTransportService methods: - NS_IMETHOD CreateTransport(const char* aHost, - PRInt32 aPort, - nsIChannel** aResult); - - NS_IMETHOD CreateTransport(const char* aHost, - PRInt32 aPort, - const char* aSocketType, - nsIChannel** aResult); - - NS_IMETHOD Shutdown(void); - - // nsIRunnable methods: - NS_IMETHOD Run(void); + NS_DECL_NSISOCKETTRANSPORTSERVICE + NS_DECL_NSIRUNNABLE // nsSocketTransportService methods: nsSocketTransportService(); diff --git a/mozilla/netwerk/build/nsNetFactory.cpp b/mozilla/netwerk/build/nsNetFactory.cpp index 039e4ab134e..f3e53c6239d 100644 --- a/mozilla/netwerk/build/nsNetFactory.cpp +++ b/mozilla/netwerk/build/nsNetFactory.cpp @@ -21,7 +21,7 @@ #include "nsIServiceManager.h" #include "nsIOService.h" #include "nsNetModuleMgr.h" -//#include "nsFileTransportService.h" +#include "nsFileTransportService.h" #include "nsSocketTransportService.h" #include "nsSocketProviderService.h" #include "nscore.h" @@ -33,7 +33,7 @@ static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); -//static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); +static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -60,11 +60,9 @@ NSGetFactory(nsISupports* aServMgr, if (aClass.Equals(kIOServiceCID)) { rv = NS_NewGenericFactory(&fact, nsIOService::Create); } -#if 0 else if (aClass.Equals(kFileTransportServiceCID)) { rv = NS_NewGenericFactory(&fact, nsFileTransportService::Create); } -#endif else if (aClass.Equals(kSocketTransportServiceCID)) { rv = NS_NewGenericFactory(&fact, nsSocketTransportService::Create); } @@ -114,13 +112,13 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath) "component://netscape/network/net-service", aPath, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; -#if 0 + rv = compMgr->RegisterComponent(kFileTransportServiceCID, "File Transport Service", "component://netscape/network/file-transport-service", aPath, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; -#endif + rv = compMgr->RegisterComponent(kSocketTransportServiceCID, "Socket Transport Service", "component://netscape/network/socket-transport-service", @@ -174,10 +172,10 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath) rv = compMgr->UnregisterComponent(kIOServiceCID, aPath); if (NS_FAILED(rv)) return rv; -#if 0 + rv = compMgr->UnregisterComponent(kFileTransportServiceCID, aPath); if (NS_FAILED(rv)) return rv; -#endif + rv = compMgr->UnregisterComponent(kSocketTransportServiceCID, aPath); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/netwerk/protocol/data/src/nsDataChannel.h b/mozilla/netwerk/protocol/data/src/nsDataChannel.h index 9799dd43e27..568dc4aa6d2 100644 --- a/mozilla/netwerk/protocol/data/src/nsDataChannel.h +++ b/mozilla/netwerk/protocol/data/src/nsDataChannel.h @@ -37,14 +37,8 @@ class nsIProgressEventSink; class nsDataChannel : public nsIDataChannel { public: NS_DECL_ISUPPORTS - - // nsIRequest methods: NS_DECL_NSIREQUEST - - // nsIChannel methods: NS_DECL_NSICHANNEL - - // nsIDataChannel methods: NS_DECL_NSIDATACHANNEL // nsFTPChannel methods: diff --git a/mozilla/netwerk/protocol/file/src/Makefile.in b/mozilla/netwerk/protocol/file/src/Makefile.in index 0cd6c44121d..8dcf50807ca 100644 --- a/mozilla/netwerk/protocol/file/src/Makefile.in +++ b/mozilla/netwerk/protocol/file/src/Makefile.in @@ -29,7 +29,6 @@ IS_COMPONENT = 1 REQUIRES = xpcom necko raptor CPPSRCS = \ - nsDirectoryIndexStream.cpp \ nsFileChannel.cpp \ nsFileProtocolHandler.cpp \ nsFileProtocolFactory.cpp \ diff --git a/mozilla/netwerk/protocol/file/src/makefile.win b/mozilla/netwerk/protocol/file/src/makefile.win index 91daecf3643..14dc525f574 100644 --- a/mozilla/netwerk/protocol/file/src/makefile.win +++ b/mozilla/netwerk/protocol/file/src/makefile.win @@ -30,7 +30,6 @@ LLIBS= $(LLIBS) \ $(NULL) CPP_OBJS= \ - .\$(OBJDIR)\nsDirectoryIndexStream.obj \ .\$(OBJDIR)\nsFileChannel.obj \ .\$(OBJDIR)\nsFileProtocolHandler.obj \ .\$(OBJDIR)\nsFileProtocolFactory.obj \ diff --git a/mozilla/netwerk/protocol/file/src/nsDirectoryIndexStream.cpp b/mozilla/netwerk/protocol/file/src/nsDirectoryIndexStream.cpp deleted file mode 100644 index 4ebdae6e4d5..00000000000 --- a/mozilla/netwerk/protocol/file/src/nsDirectoryIndexStream.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - - -/* - - The converts a filesystem directory into an "HTTP index" stream. - - */ - -#include "nsEscape.h" -#include "nsDirectoryIndexStream.h" -#include "prio.h" - - -nsDirectoryIndexStream::nsDirectoryIndexStream() - : mOffset(0), - mIter(nsnull) -{ - NS_INIT_REFCNT(); -} - - -nsresult -nsDirectoryIndexStream::Init(const nsFileSpec& aDir) -{ - NS_PRECONDITION(aDir.IsDirectory(), "not a directory"); - if (! aDir.IsDirectory()) - return NS_ERROR_ILLEGAL_VALUE; - - mDir = aDir; - - // Sigh. We have to allocate on the heap because there are no - // assignment operators defined. - mIter = new nsDirectoryIterator(mDir, PR_FALSE); // rjc: don't resolve aliases - if (! mIter) - return NS_ERROR_OUT_OF_MEMORY; - - mBuf = "200: filename content-length last-modified file-type\n"; - return NS_OK; -} - - -nsDirectoryIndexStream::~nsDirectoryIndexStream() -{ - delete mIter; -} - - - -nsresult -nsDirectoryIndexStream::Create(const nsFileSpec& aDir, nsISupports** aResult) -{ - nsDirectoryIndexStream* result = new nsDirectoryIndexStream(); - if (! result) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv; - rv = result->Init(aDir); - if (NS_FAILED(rv)) { - delete result; - return rv; - } - - *aResult = result; - NS_ADDREF(*aResult); - return NS_OK; -} - -NS_IMPL_ADDREF(nsDirectoryIndexStream); -NS_IMPL_RELEASE(nsDirectoryIndexStream); - -NS_IMETHODIMP -nsDirectoryIndexStream::QueryInterface(REFNSIID aIID, void** aResult) -{ - NS_PRECONDITION(aResult != nsnull, "null ptr"); - if (! aResult) - return NS_ERROR_NULL_POINTER; - - if (aIID.Equals(NS_GET_IID(nsIInputStream)) || - aIID.Equals(NS_GET_IID(nsIBaseStream)) || - aIID.Equals(NS_GET_IID(nsISupports))) { - *aResult = NS_STATIC_CAST(nsIInputStream*, this); - NS_ADDREF(this); - return NS_OK; - } - else { - *aResult = nsnull; - return NS_NOINTERFACE; - } -} - - -NS_IMETHODIMP -nsDirectoryIndexStream::Close() -{ - return NS_OK; -} - - - -NS_IMETHODIMP -nsDirectoryIndexStream::Available(PRUint32* aLength) -{ - // Lie, and tell the caller that the stream is endless (until we - // actually don't have anything left). - if (mIter->Exists()) { - *aLength = PRUint32(-1); - return NS_OK; - } - else { - *aLength = 0; - return NS_OK; - } -} - - -NS_IMETHODIMP -nsDirectoryIndexStream::Read(char* aBuf, PRUint32 aCount, PRUint32* aReadCount) -{ - PRUint32 nread = 0; - - // If anything is enqueued (or left-over) in mBuf, then feed it to - // the reader first. - while (mOffset < mBuf.Length() && aCount != 0) { - *(aBuf++) = char(mBuf.CharAt(mOffset++)); - --aCount; - ++nread; - } - - // Room left? - if (aCount > 0) { - mOffset = 0; - mBuf.Truncate(); - - // Okay, now we'll suck stuff off of our iterator into the mBuf... - while (PRUint32(mBuf.Length()) < aCount && mIter->Exists()) { - nsFileSpec current = mIter->Spec(); - ++(*mIter); - - // rjc: don't return hidden files/directories! - if (current.IsHidden()) continue; - - PRFileInfo fileinfo; - PRStatus status = PR_GetFileInfo(nsNSPRPath(current), &fileinfo); - if (status != PR_SUCCESS) - continue; - - mBuf += "201: "; - - // The "filename" field - { - char* leafname = current.GetLeafName(); - if (leafname) { - char* escaped = nsEscape(leafname, url_Path); - if (escaped) { - mBuf += escaped; - mBuf.Append(' '); - nsCRT::free(escaped); - } - nsCRT::free(leafname); - } - } - - // The "content-length" field - mBuf.Append(fileinfo.size, 10); - mBuf.Append(' '); - - // The "last-modified" field - PRExplodedTime tm; - PR_ExplodeTime(fileinfo.modifyTime, PR_GMTParameters, &tm); - { - char buf[64]; - PR_FormatTimeUSEnglish(buf, sizeof(buf), "%a,%%20%d%%20%b%%20%Y%%20%H:%M:%S%%20GMT ", &tm); - mBuf.Append(buf); - } - - // The "file-type" field - if (current.IsFile()) { - mBuf += "FILE "; - } - else if (current.IsDirectory()) { - mBuf += "DIRECTORY "; - } - else if (current.IsSymlink()) { - mBuf += "SYMBOLIC-LINK "; - } - - mBuf.Append('\n'); - } - - // ...and once we've either run out of directory entries, or - // filled up the buffer, then we'll push it to the reader. - while (mOffset < mBuf.Length() && aCount != 0) { - *(aBuf++) = char(mBuf.CharAt(mOffset++)); - --aCount; - ++nread; - } - } - - *aReadCount = nread; - return NS_OK; -} diff --git a/mozilla/netwerk/protocol/file/src/nsDirectoryIndexStream.h b/mozilla/netwerk/protocol/file/src/nsDirectoryIndexStream.h deleted file mode 100644 index 55b4cbcef4a..00000000000 --- a/mozilla/netwerk/protocol/file/src/nsDirectoryIndexStream.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ - -#ifndef nsDirectoryIndexStream_h__ -#define nsDirectoryIndexStream_h__ - - -#include "nsFileSpec.h" -#include "nsString.h" -#include "nsIInputStream.h" - -class nsDirectoryIndexStream : public nsIInputStream -{ -protected: - nsCAutoString mBuf; - PRInt32 mOffset; - - nsFileSpec mDir; - nsDirectoryIterator* mIter; - - nsDirectoryIndexStream(); - nsresult Init(const nsFileSpec& aDir); - virtual ~nsDirectoryIndexStream(); - -public: - static nsresult - Create(const nsFileSpec& aDir, nsISupports** aStreamResult); - - // nsISupportsInterface - NS_DECL_ISUPPORTS - - // nsIBaseStream interface - NS_DECL_NSIBASESTREAM - - // nsIInputStream interface - NS_DECL_NSIINPUTSTREAM -}; - -#endif // nsDirectoryIndexStream_h__ - diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index ca959037c88..e7bf284b1eb 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -41,94 +41,52 @@ #include "nsDirectoryIndexStream.h" #include "nsEscape.h" #include "nsIMIMEService.h" -#include "prlog.h" +#include "nsIEventQueueService.h" +#include "nsIEventQueue.h" +#include "nsIFileTransportService.h" static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); - static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); -NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); +static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); #ifdef STREAM_CONVERTER_HACK #include "nsIStreamConverter.h" #include "nsIAllocator.h" #endif -#if defined(PR_LOGGING) -// -// Log module for SocketTransport logging... -// -// To enable logging (see prlog.h for full details): -// -// set NSPR_LOG_MODULES=nsFileTransport:5 -// set NSPR_LOG_FILE=nspr.log -// -// this enables PR_LOG_DEBUG level information and places all output in -// the file nspr.log -// -PRLogModuleInfo* gFileTransportLog = nsnull; - -#endif /* PR_LOGGING */ - //////////////////////////////////////////////////////////////////////////////// nsFileChannel::nsFileChannel() - : mURI(nsnull), mGetter(nsnull), mListener(nsnull), mEventQueue(nsnull), - mContext(nsnull), mHandler(nsnull), mState(QUIESCENT), - mSuspended(PR_FALSE), mFileStream(nsnull), - mBufferInputStream(nsnull), mBufferOutputStream(nsnull), - mStatus(NS_OK), mSourceOffset(0), mReadFixedAmount(PR_FALSE), - mLoadAttributes(LOAD_NORMAL), - mLoadGroup(nsnull), + : mLoadAttributes(LOAD_NORMAL), mRealListener(nsnull) { NS_INIT_REFCNT(); -#if defined(PR_LOGGING) - // - // Initialize the global PRLogModule for socket transport logging - // if necessary... - // - if (nsnull == gFileTransportLog) { - gFileTransportLog = PR_NewLogModule("nsFileTransport"); - } -#endif /* PR_LOGGING */ } nsresult -nsFileChannel::Init(nsFileProtocolHandler* handler, - const char* verb, nsIURI* uri, nsILoadGroup *aGroup, - nsIEventSinkGetter* getter) +nsFileChannel::Init(nsIFileProtocolHandler* handler, const char* command, nsIURI* uri, + nsILoadGroup *aGroup, nsIEventSinkGetter* getter) { nsresult rv; - mHandler = handler; - NS_ADDREF(mHandler); - mGetter = getter; - NS_IF_ADDREF(mGetter); - - mMonitor = nsAutoMonitor::NewMonitor("FileChannel"); - if (mMonitor == nsnull) + mHandler = handler; + mURI = uri; + mCommand = nsCRT::strdup(command); + if (mCommand == nsnull) return NS_ERROR_OUT_OF_MEMORY; - if (getter) { - (void)getter->GetEventSink(verb, NS_GET_IID(nsIStreamListener), (nsISupports**)&mListener); - // ignore the failure -- we can live without having an event sink - } - - mURI = uri; - NS_ADDREF(mURI); - mLoadGroup = aGroup; - NS_IF_ADDREF(mLoadGroup); if (mLoadGroup) { - mLoadGroup->GetDefaultLoadAttributes(&mLoadAttributes); + rv = mLoadGroup->GetDefaultLoadAttributes(&mLoadAttributes); + if (NS_FAILED(rv)) return rv; } // if we support the nsIURL interface then use it to get just // the file path with no other garbage! nsCOMPtr aUrl = do_QueryInterface(mURI, &rv); - if (NS_SUCCEEDED(rv) && aUrl) // does it support the url interface? - { + if (NS_SUCCEEDED(rv) && aUrl) { // does it support the url interface? nsXPIDLCString fileString; aUrl->DirFile(getter_Copies(fileString)); // to be mac friendly you need to convert a file path to a nsFilePath before @@ -152,8 +110,7 @@ nsFileChannel::Init(nsFileProtocolHandler* handler, mSpec = filePath; #endif } - else - { + else { // otherwise do the best we can by using the spec for the uri.... // XXX temporary, until we integrate more thoroughly with nsFileSpec char* url; @@ -164,23 +121,11 @@ nsFileChannel::Init(nsFileProtocolHandler* handler, mSpec = fileURL; } - return NS_OK; + return rv; } nsFileChannel::~nsFileChannel() { - NS_IF_RELEASE(mURI); - NS_IF_RELEASE(mGetter); - NS_IF_RELEASE(mListener); - NS_IF_RELEASE(mEventQueue); - NS_IF_RELEASE(mContext); - NS_IF_RELEASE(mHandler); - NS_ASSERTION(mFileStream == nsnull, "channel not closed"); - NS_ASSERTION(mBufferInputStream == nsnull, "channel not closed"); - NS_ASSERTION(mBufferOutputStream == nsnull, "channel not closed"); - if (mMonitor) - nsAutoMonitor::DestroyMonitor(mMonitor); - NS_IF_RELEASE(mLoadGroup); } NS_IMETHODIMP @@ -189,11 +134,18 @@ nsFileChannel::QueryInterface(const nsIID& aIID, void** aInstancePtr) NS_ASSERTION(aInstancePtr, "no instance pointer"); if (aIID.Equals(NS_GET_IID(nsIFileChannel)) || aIID.Equals(NS_GET_IID(nsIChannel)) || + aIID.Equals(NS_GET_IID(nsIRequest)) || aIID.Equals(NS_GET_IID(nsISupports))) { *aInstancePtr = NS_STATIC_CAST(nsIFileChannel*, this); NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(NS_GET_IID(nsIStreamListener)) || + aIID.Equals(NS_GET_IID(nsIStreamObserver))) { + *aInstancePtr = NS_STATIC_CAST(nsIStreamListener*, this); + NS_ADDREF_THIS(); + return NS_OK; + } return NS_NOINTERFACE; } @@ -219,59 +171,34 @@ nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) NS_IMETHODIMP nsFileChannel::IsPending(PRBool *result) { - *result = mState != QUIESCENT; + if (mFileTransport) + return mFileTransport->IsPending(result); + *result = PR_FALSE; return NS_OK; } NS_IMETHODIMP nsFileChannel::Cancel() { - nsAutoMonitor mon(mMonitor); - - nsresult rv = NS_OK; - mStatus = NS_BINDING_ABORTED; - if (mSuspended) { - Resume(); - } - mState = ENDING; - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: Cancel [this=%x %s]", - this, (const char*)mSpec)); - return rv; + if (mFileTransport) + return mFileTransport->Cancel(); + return NS_OK; } NS_IMETHODIMP nsFileChannel::Suspend() { - nsAutoMonitor mon(mMonitor); - - nsresult rv = NS_OK; - if (!mSuspended) { - // XXX close the stream here? - mStatus = mHandler->Suspend(this); - mSuspended = PR_TRUE; - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: Suspend [this=%x %s]", - this, (const char*)mSpec)); - } - return rv; + if (mFileTransport) + return mFileTransport->Suspend(); + return NS_OK; } NS_IMETHODIMP nsFileChannel::Resume() { - nsAutoMonitor mon(mMonitor); - - nsresult rv = NS_OK; - if (mSuspended) { - // XXX re-open the stream and seek here? - mSuspended = PR_FALSE; // set this first before resuming! - mStatus = mHandler->Resume(this); - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: Resume [this=%x %s] status=%x", - this, (const char*)mSpec, mStatus)); - } - return rv; + if (mFileTransport) + return mFileTransport->Resume(); + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -282,7 +209,7 @@ NS_IMETHODIMP nsFileChannel::GetURI(nsIURI * *aURI) { *aURI = mURI; - NS_ADDREF(mURI); + NS_ADDREF(*aURI); return NS_OK; } @@ -290,71 +217,37 @@ NS_IMETHODIMP nsFileChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount, nsIInputStream **result) { - nsAutoMonitor mon(mMonitor); - nsresult rv; - if (mState != QUIESCENT) + if (mFileTransport) return NS_ERROR_IN_PROGRESS; - PRBool exists; - rv = Exists(&exists); - if (NS_FAILED(rv)) return rv; - if (!exists) - return NS_ERROR_FAILURE; // XXX probably need NS_BASE_STREAM_FILE_NOT_FOUND or something - - rv = NS_NewPipe(&mBufferInputStream, &mBufferOutputStream, - this, // nsIPipeObserver - NS_FILE_TRANSPORT_SEGMENT_SIZE, - NS_FILE_TRANSPORT_BUFFER_SIZE); - if (NS_FAILED(rv)) return rv; -#if 0 - NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv); + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = serv->NewSyncStreamListener(&mBufferInputStream, &mBufferOutputStream, &mListener); - if (NS_FAILED(rv)) return rv; -#endif - - rv = mBufferOutputStream->SetNonBlocking(PR_TRUE); + rv = fts->CreateTransport(mSpec, mCommand, mGetter, + getter_AddRefs(mFileTransport)); if (NS_FAILED(rv)) return rv; - mState = START_READ; - mSourceOffset = startPosition; - mAmount = readCount; - mListener = nsnull; - - rv = mHandler->DispatchRequest(this); - if (NS_FAILED(rv)) return rv; - - *result = mBufferInputStream; - NS_ADDREF(*result); - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: OpenInputStream [this=%x %s]", - this, (const char*)mSpec)); - return NS_OK; + return mFileTransport->OpenInputStream(startPosition, readCount, result); } NS_IMETHODIMP nsFileChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **result) { - nsAutoMonitor mon(mMonitor); - nsresult rv; - if (mState != QUIESCENT) + if (mFileTransport) return NS_ERROR_IN_PROGRESS; - NS_ASSERTION(startPosition == 0, "implement startPosition"); - nsISupports* str; - rv = NS_NewTypicalOutputFileStream(&str, mSpec); + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = str->QueryInterface(NS_GET_IID(nsIOutputStream), (void**)result); - NS_RELEASE(str); - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: OpenOutputStream [this=%x %s]", - this, (const char*)mSpec)); - return rv; + + rv = fts->CreateTransport(mSpec, mCommand, mGetter, + getter_AddRefs(mFileTransport)); + if (NS_FAILED(rv)) return rv; + + return mFileTransport->OpenOutputStream(startPosition, result); } NS_IMETHODIMP @@ -362,19 +255,10 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener) { - nsAutoMonitor mon(mMonitor); + nsresult rv; - nsresult rv = NS_OK; - - NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv); - if (NS_FAILED(rv)) return rv; - - if (!mEventQueue) { - NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueService, &rv); - if (NS_FAILED(rv)) return rv; - rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &mEventQueue); - if (NS_FAILED(rv)) return rv; - } + if (mFileTransport) + return NS_ERROR_IN_PROGRESS; // mscott -- this is just one temporary hack until we have a legit stream converter // story going....if the file we are opening is an rfc822 file then we want to @@ -383,11 +267,12 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, // the file channel stream of incoming data and the consumer at the other end of the // AsyncRead call... mRealListener = listener; + nsCOMPtr tempListener; #ifdef STREAM_CONVERTER_HACK nsXPIDLCString aContentType; rv = GetContentType(getter_Copies(aContentType)); - if (NS_SUCCEEDED(rv) && PL_strcasecmp("message/rfc822", aContentType) == 0) + if (NS_SUCCEEDED(rv) && nsCRT::strcasecmp("message/rfc822", aContentType) == 0) { // okay we are an rfc822 message... // (0) Create an instance of an RFC-822 stream converter... @@ -396,69 +281,30 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, // (1) create a proxied stream listener for the caller of this method // (2) set this proxied listener as the listener on the output stream // (3) create a proxied stream listener for the converter - // (4) set mListener to be the stream converter's listener. + // (4) set tempListener to be the stream converter's listener. // (0) create a stream converter - nsCOMPtr mimeParser; // mscott - we could generalize this hack to work with other stream converters by simply // using the content type of the file to generate a progid for a stream converter and use // that instead of a class id... - - nsIComponentManager *comMgr; - rv = NS_GetGlobalComponentManager(&comMgr); - if (!mStreamConverter) { - rv = comMgr->CreateInstanceByProgID(NS_ISTREAMCONVERTER_KEY - "?from=message/rfc822?to=text/xul", - NULL, NS_GET_IID(nsIStreamConverter), - (void **) getter_AddRefs(mStreamConverter)); + rv = nsComponentManager::CreateInstance(NS_ISTREAMCONVERTER_KEY "?from=message/rfc822?to=text/xul", + NULL, NS_GET_IID(nsIStreamConverter), + (void **) getter_AddRefs(mStreamConverter)); + if (NS_FAILED(rv)) return rv; } - if (NS_FAILED(rv)) return rv; - - // (1) and (2) - nsCOMPtr proxiedConsumerListener; - rv = serv->NewAsyncStreamListener(this, mEventQueue, getter_AddRefs(proxiedConsumerListener)); - if (NS_FAILED(rv)) return rv; // (3) set the stream converter as the listener on the channel - mListener = mStreamConverter; - NS_IF_ADDREF(mListener); // mListener is NOT a com ptr... + tempListener = mStreamConverter; - mStreamConverter->AsyncConvertData(nsnull, nsnull, proxiedConsumerListener, (nsIChannel *) this); + mStreamConverter->AsyncConvertData(nsnull, nsnull, this, (nsIChannel *) this); mStreamConverterOutType = "text/xul"; } else - rv = serv->NewAsyncStreamListener(this, mEventQueue, &mListener); + tempListener = this; #else - rv = serv->NewAsyncStreamListener(this, mEventQueue, &mListener); + tempListener = this; #endif - if (NS_FAILED(rv)) return rv; - - rv = NS_NewPipe(&mBufferInputStream, &mBufferOutputStream, - this, // nsIPipeObserver - NS_FILE_TRANSPORT_SEGMENT_SIZE, - NS_FILE_TRANSPORT_BUFFER_SIZE); - if (NS_FAILED(rv)) return rv; - - rv = mBufferOutputStream->SetNonBlocking(PR_TRUE); - if (NS_FAILED(rv)) return rv; - - NS_ASSERTION(mContext == nsnull, "context not released"); - mContext = ctxt; - NS_IF_ADDREF(mContext); - - mState = START_READ; - mSourceOffset = startPosition; - - // did the user request a specific number of bytes to read? - // if they passed in -1 then they want all bytes to be read.f - if (readCount > 0) // did the user pass in - { - mReadFixedAmount = PR_TRUE; - mAmount = (PRUint32) readCount; // mscott - this is a safe cast! - } - else - mAmount = 0; // don't worry we'll ignore this parameter from here on out because mReadFixedAmount is false if (mLoadGroup) { nsCOMPtr factory; @@ -467,25 +313,26 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, // rv = mLoadGroup->GetGroupListenerFactory(getter_AddRefs(factory)); if (factory) { - nsIStreamListener *newListener; - rv = factory->CreateLoadGroupListener(mRealListener, &newListener); - if (NS_SUCCEEDED(rv)) { - mRealListener = newListener; - NS_RELEASE(newListener); - } + nsIStreamListener *newListener; + rv = factory->CreateLoadGroupListener(mRealListener, &newListener); + if (NS_SUCCEEDED(rv)) { + mRealListener = newListener; + NS_RELEASE(newListener); + } } rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: AsyncRead [this=%x %s]", - this, (const char*)mSpec)); - rv = mHandler->DispatchRequest(this); + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - return NS_OK; + rv = fts->CreateTransport(mSpec, mCommand, mGetter, + getter_AddRefs(mFileTransport)); + if (NS_FAILED(rv)) return rv; + + return mFileTransport->AsyncRead(startPosition, readCount, ctxt, tempListener); } NS_IMETHODIMP @@ -494,12 +341,19 @@ nsFileChannel::AsyncWrite(nsIInputStream *fromStream, nsISupports *ctxt, nsIStreamObserver *observer) { - nsAutoMonitor mon(mMonitor); + nsresult rv; - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: AsyncWrite [this=%x %s]", - this, (const char*)mSpec)); - return NS_ERROR_NOT_IMPLEMENTED; + if (mFileTransport) + return NS_ERROR_IN_PROGRESS; + + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = fts->CreateTransport(mSpec, mCommand, mGetter, + getter_AddRefs(mFileTransport)); + if (NS_FAILED(rv)) return rv; + + return mFileTransport->AsyncWrite(fromStream, startPosition, writeCount, ctxt, observer); } NS_IMETHODIMP @@ -592,253 +446,46 @@ nsFileChannel::SetOwner(nsISupports * aOwner) return NS_OK; } -//////////////////////////////////////////////////////////////////////////////// -// nsIRunnable methods: -//////////////////////////////////////////////////////////////////////////////// - -NS_IMETHODIMP -nsFileChannel::Run(void) -{ - while (mState != QUIESCENT && !mSuspended) { - Process(); - } - return NS_OK; -} - -static NS_METHOD -nsWriteToFile(void* closure, - const char* fromRawSegment, - PRUint32 toOffset, - PRUint32 count, - PRUint32 *writeCount) -{ - nsIOutputStream* outStr = (nsIOutputStream*)closure; - nsresult rv = outStr->Write(fromRawSegment, count, writeCount); - return rv; -} - -void -nsFileChannel::Process(void) -{ - nsAutoMonitor mon(mMonitor); - - switch (mState) { - case START_READ: { - nsISupports* fs; - - if (mListener) { - mStatus = mListener->OnStartRequest(this, mContext); // always send the start notification - if (NS_FAILED(mStatus)) goto error; - } - - if (mSpec.IsDirectory()) { - mStatus = nsDirectoryIndexStream::Create(mSpec, &fs); - } - else { - mStatus = NS_NewTypicalInputFileStream(&fs, mSpec); - } - if (NS_FAILED(mStatus)) goto error; - - if (mSourceOffset > 0) // if we need to set a starting offset, QI for the nsIRandomAccessStore and set it - { - nsCOMPtr inputStream; - inputStream = do_QueryInterface(fs, &mStatus); - if (NS_FAILED(mStatus)) goto error; - // for now, assume the offset is always relative to the start of the file (position 0) - // so use PR_SEEK_SET - inputStream->Seek(PR_SEEK_SET, mSourceOffset); - } - - mStatus = fs->QueryInterface(NS_GET_IID(nsIInputStream), (void**)&mFileStream); - NS_RELEASE(fs); - if (NS_FAILED(mStatus)) goto error; - - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: START_READ [this=%x %s]", - this, (const char*)mSpec)); - mState = READING; - break; - } - case READING: { - if (NS_FAILED(mStatus)) goto error; - - nsIInputStream* fileStr = NS_STATIC_CAST(nsIInputStream*, mFileStream); - - PRUint32 inLen; - mStatus = fileStr->Available(&inLen); - if (NS_FAILED(mStatus)) goto error; - - // mscott --> if the user wanted to only read a fixed number of bytes - // we need to honor that... - if (mReadFixedAmount && inLen > mAmount) - inLen = PR_MIN(inLen, mAmount); - - PRUint32 amt; - mStatus = mBufferOutputStream->WriteFrom(fileStr, inLen, &amt); - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: READING [this=%x %s] amt=%d status=%x", - this, (const char*)mSpec, amt, mStatus)); - if (mStatus == NS_BASE_STREAM_WOULD_BLOCK) { - mStatus = NS_OK; - return; - } - if (NS_FAILED(mStatus) || amt == 0) goto error; - if (mReadFixedAmount) - mAmount -= amt; // subtract off the amount we just read from mAmount. - - // and feed the buffer to the application via the buffer stream: - if (mListener) { - mStatus = mListener->OnDataAvailable(this, mContext, mBufferInputStream, mSourceOffset, amt); - if (NS_FAILED(mStatus)) goto error; - } - - if (mReadFixedAmount && mAmount == 0) - { - Cancel(); // stop reading data...we are done - return; - } - - mSourceOffset += amt; - - // stay in the READING state - break; - } - case START_WRITE: { - nsISupports* fs; - - if (mListener) { - mStatus = mListener->OnStartRequest(this, mContext); // always send the start notification - if (NS_FAILED(mStatus)) goto error; - } - - mStatus = NS_NewTypicalOutputFileStream(&fs, mSpec); - if (NS_FAILED(mStatus)) goto error; - - mStatus = fs->QueryInterface(NS_GET_IID(nsIOutputStream), (void**)&mFileStream); - NS_RELEASE(fs); - if (NS_FAILED(mStatus)) goto error; - - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: START_WRITE [this=%x %s]", - this, (const char*)mSpec)); - mState = WRITING; - break; - } - case WRITING: { - if (NS_FAILED(mStatus)) goto error; -#if 0 - PRUint32 amt; - mStatus = mBuffer->ReadSegments(nsWriteToFile, mFileStream, (PRUint32)-1, &amt); - if (NS_FAILED(mStatus)) goto error; - if (amt == 0) goto error; // EOF condition - - nsAutoCMonitor mon(mBuffer); - mon.Notify(); - - mSourceOffset += amt; -#endif - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: WRITING [this=%x %s]", - this, (const char*)mSpec)); - // stay in the WRITING state - break; - } - case ENDING: { - PR_LOG(gFileTransportLog, PR_LOG_DEBUG, - ("nsFileTransport: ENDING [this=%x %s] status=%x", - this, (const char*)mSpec, mStatus)); - mBufferOutputStream->Flush(); - if (mListener) { - // XXX where do we get the error message? - (void)mListener->OnStopRequest(this, mContext, mStatus, nsnull); - NS_RELEASE(mListener); - } - - NS_IF_RELEASE(mBufferOutputStream); - mBufferOutputStream = nsnull; - NS_IF_RELEASE(mBufferInputStream); - mBufferInputStream = nsnull; - NS_IF_RELEASE(mFileStream); - mFileStream = nsnull; - NS_IF_RELEASE(mContext); - mContext = nsnull; - - mState = QUIESCENT; - break; - } - case QUIESCENT: { - NS_NOTREACHED("trying to continue a quiescent file transfer"); - break; - } - } - return; - - error: - mState = ENDING; - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// nsIPipeObserver methods: -//////////////////////////////////////////////////////////////////////////////// - -NS_IMETHODIMP -nsFileChannel::OnFull(nsIPipe* pipe) -{ - return Suspend(); -} - -NS_IMETHODIMP -nsFileChannel::OnWrite(nsIPipe* pipe, PRUint32 aCount) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsFileChannel::OnEmpty(nsIPipe* pipe) -{ - return Resume(); -} - //////////////////////////////////////////////////////////////////////////////// // nsIStreamListener methods: //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileChannel::OnDataAvailable(nsIChannel* channel, nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength) -{ - return mRealListener->OnDataAvailable(channel, context, aIStream, - aSourceOffset, aLength); -} - -NS_IMETHODIMP -nsFileChannel::OnStartRequest(nsIChannel* channel, nsISupports* context) +nsFileChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) { NS_ASSERTION(mRealListener, "No listener..."); - return mRealListener->OnStartRequest(channel, context); + return mRealListener->OnStartRequest(this, context); } NS_IMETHODIMP -nsFileChannel::OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg) +nsFileChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, + nsresult aStatus, const PRUnichar* aMsg) { nsresult rv; - rv = mRealListener->OnStopRequest(channel, context, aStatus, aMsg); + rv = mRealListener->OnStopRequest(this, context, aStatus, aMsg); if (mLoadGroup) { - mLoadGroup->RemoveChannel(channel, context, aStatus, aMsg); + if (NS_SUCCEEDED(rv)) { + mLoadGroup->RemoveChannel(this, context, aStatus, aMsg); + } } // Release the reference to the consumer stream listener... mRealListener = null_nsCOMPtr(); + mFileTransport = null_nsCOMPtr(); return rv; } +NS_IMETHODIMP +nsFileChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, + nsIInputStream *aIStream, PRUint32 aSourceOffset, + PRUint32 aLength) +{ + return mRealListener->OnDataAvailable(this, context, aIStream, + aSourceOffset, aLength); +} + //////////////////////////////////////////////////////////////////////////////// // From nsIFileChannel //////////////////////////////////////////////////////////////////////////////// @@ -872,18 +519,16 @@ class nsDirEnumerator : public nsISimpleEnumerator public: NS_DECL_ISUPPORTS - nsDirEnumerator() : mHandler(nsnull), mDir(nsnull), mNext(nsnull) { + nsDirEnumerator() : mDir(nsnull) { NS_INIT_REFCNT(); } - nsresult Init(nsFileProtocolHandler* handler, nsFileSpec& spec) { + nsresult Init(nsIFileProtocolHandler* handler, nsFileSpec& spec) { const char* path = spec.GetNativePathCString(); mDir = PR_OpenDir(path); if (mDir == nsnull) // not a directory? return NS_ERROR_FAILURE; - mHandler = handler; - NS_ADDREF(mHandler); return NS_OK; } @@ -904,7 +549,7 @@ public: } const char* path = entry->name; - rv = mHandler->NewChannelFromNativePath(path, &mNext); + rv = mHandler->NewChannelFromNativePath(path, getter_AddRefs(mNext)); if (NS_FAILED(rv)) return rv; NS_ASSERTION(mNext, "NewChannel failed"); @@ -920,7 +565,7 @@ public: if (NS_FAILED(rv)) return rv; *result = mNext; // might return nsnull - mNext = nsnull; + mNext = null_nsCOMPtr(); return NS_OK; } @@ -929,14 +574,12 @@ public: PRStatus status = PR_CloseDir(mDir); NS_ASSERTION(status == PR_SUCCESS, "close failed"); } - NS_IF_RELEASE(mHandler); - NS_IF_RELEASE(mNext); } protected: - nsFileProtocolHandler* mHandler; - PRDir* mDir; - nsIFileChannel* mNext; + nsCOMPtr mHandler; + PRDir* mDir; + nsCOMPtr mNext; }; NS_IMPL_ISUPPORTS(nsDirEnumerator, NS_GET_IID(nsISimpleEnumerator)); @@ -1074,8 +717,7 @@ nsFileChannel::ResolveLink(nsIFileChannel **_retval) nsFileSpec tempSpec = mSpec; nsresult rv = tempSpec.ResolveSymlink(ignore); - if(NS_SUCCEEDED(rv)) - { + if (NS_SUCCEEDED(rv)) { return CreateFileChannelFromFileSpec(tempSpec, _retval); } @@ -1085,8 +727,7 @@ nsFileChannel::ResolveLink(nsIFileChannel **_retval) NS_IMETHODIMP nsFileChannel::MakeUnique(const char* baseName, nsIFileChannel **_retval) { - if (mSpec.IsDirectory()) - { + if (mSpec.IsDirectory()) { nsFileSpec tempSpec = mSpec; tempSpec.MakeUnique(baseName); @@ -1149,3 +790,4 @@ nsFileChannel::CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel ** return NS_OK; } +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.h b/mozilla/netwerk/protocol/file/src/nsFileChannel.h index 739b455c8f3..91056bebbb8 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.h +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.h @@ -19,6 +19,16 @@ #ifndef nsFileChannel_h__ #define nsFileChannel_h__ +#include "nsIFileChannel.h" +#include "nsIFileProtocolHandler.h" +#include "nsIEventSinkGetter.h" +#include "nsILoadGroup.h" +#include "nsIStreamListener.h" +#include "nsIChannel.h" +#include "nsFileSpec.h" +#include "nsIURI.h" +#include "nsCOMPtr.h" + // mscott -- this is just one temporary hack until we have a legit stream converter // story going....if the file we are opening is an rfc822 file then we want to // go out and convert the data into html before we try to load it. so I'm inserting @@ -44,16 +54,7 @@ #include "nsXPIDLString.h" #endif -class nsIEventSinkGetter; -class nsIStreamListener; -class nsFileProtocolHandler; -class nsIBaseStream; -class nsIBufferInputStream; -class nsIBufferOutputStream; - -class nsFileChannel : public nsIFileChannel, - public nsIRunnable, - public nsIPipeObserver, +class nsFileChannel : public nsIFileChannel, public nsIStreamListener { public: @@ -61,18 +62,9 @@ public: NS_DECL_NSIREQUEST NS_DECL_NSICHANNEL NS_DECL_NSIFILECHANNEL - NS_DECL_NSIPIPEOBSERVER NS_DECL_NSISTREAMOBSERVER NS_DECL_NSISTREAMLISTENER - //////////////////////////////////////////////////////////////////////////// - // nsIRunnable methods: - - NS_IMETHOD Run(void); - - //////////////////////////////////////////////////////////////////////////// - // nsFileChannel: - nsFileChannel(); // Always make the destructor virtual: virtual ~nsFileChannel(); @@ -81,60 +73,28 @@ public: static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); - nsresult Init(nsFileProtocolHandler* handler, - const char* verb, nsIURI* uri, nsILoadGroup *aGroup, - nsIEventSinkGetter* getter); - - void Process(void); - - enum State { - QUIESCENT, - START_READ, - READING, - START_WRITE, - WRITING, - ENDING - }; + nsresult Init(nsIFileProtocolHandler* handler, const char* verb, nsIURI* uri, + nsILoadGroup *aGroup, nsIEventSinkGetter* getter); protected: nsresult CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel** result); protected: - nsIURI* mURI; - nsIEventSinkGetter* mGetter; // XXX it seems wrong keeping this -- used by GetParent - nsIStreamListener* mListener; - nsIEventQueue* mEventQueue; - - nsFileSpec mSpec; - - nsISupports* mContext; - nsFileProtocolHandler* mHandler; - State mState; - PRBool mSuspended; - - // state variables: - nsIBaseStream* mFileStream; // cast to nsIInputStream/nsIOutputStream for reading/Writing - nsIBufferInputStream* mBufferInputStream; - nsIBufferOutputStream* mBufferOutputStream; - nsresult mStatus; - PRUint32 mSourceOffset; - PRUint32 mAmount; - PRBool mReadFixedAmount; // if user wants to only read a fixed number of bytes set this flag - - PRMonitor* mMonitor; - PRUint32 mLoadAttributes; - nsILoadGroup* mLoadGroup; - nsCOMPtr mOwner; - - nsCOMPtr mRealListener; + nsCOMPtr mURI; + nsCOMPtr mHandler; + nsCOMPtr mGetter; // XXX it seems wrong keeping this -- used by GetParent + char* mCommand; + nsFileSpec mSpec; + nsCOMPtr mFileTransport; + PRUint32 mLoadAttributes; + nsCOMPtr mLoadGroup; + nsCOMPtr mOwner; + nsCOMPtr mRealListener; #ifdef STREAM_CONVERTER_HACK - nsCOMPtr mStreamConverter; - nsCString mStreamConverterOutType; + nsCOMPtr mStreamConverter; + nsCString mStreamConverterOutType; #endif }; -#define NS_FILE_TRANSPORT_SEGMENT_SIZE (4*1024) -#define NS_FILE_TRANSPORT_BUFFER_SIZE (32*1024) - #endif // nsFileChannel_h__ diff --git a/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp b/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp index f4ab303642b..b8a86218902 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp @@ -30,7 +30,7 @@ #include "nsFileSpec.h" #include "nsAutoLock.h" -static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); +static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); //////////////////////////////////////////////////////////////////////////////// @@ -60,7 +60,9 @@ nsFileProtocolHandler::~nsFileProtocolHandler() NS_IF_RELEASE(mSuspended); } -NS_IMPL_ISUPPORTS(nsFileProtocolHandler, NS_GET_IID(nsIProtocolHandler)); +NS_IMPL_ISUPPORTS2(nsFileProtocolHandler, + nsIFileProtocolHandler, + nsIProtocolHandler); NS_METHOD nsFileProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) @@ -170,8 +172,6 @@ nsFileProtocolHandler::NewChannel(const char* verb, nsIURI* url, return NS_OK; } -//////////////////////////////////////////////////////////////////////////////// - NS_IMETHODIMP nsFileProtocolHandler::NewChannelFromNativePath(const char* nativePath, nsIFileChannel* *result) @@ -195,48 +195,3 @@ nsFileProtocolHandler::NewChannelFromNativePath(const char* nativePath, } //////////////////////////////////////////////////////////////////////////////// - -nsresult -nsFileProtocolHandler::ProcessPendingRequests(void) -{ - return mPool->ProcessPendingRequests(); -} - -nsresult -nsFileProtocolHandler::DispatchRequest(nsIRunnable* runnable) -{ - return mPool->DispatchRequest(runnable); -} - -//////////////////////////////////////////////////////////////////////////////// - -nsresult -nsFileProtocolHandler::Suspend(nsFileChannel* request) -{ - nsresult rv; - nsAutoCMonitor mon(this); // protect mSuspended - if (mSuspended == nsnull) { - rv = NS_NewISupportsArray(&mSuspended); - if (NS_FAILED(rv)) return rv; - } - return mSuspended->AppendElement(NS_STATIC_CAST(nsIChannel*, request)) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool -} - -nsresult -nsFileProtocolHandler::Resume(nsFileChannel* request) -{ - nsresult rv; - nsAutoCMonitor mon(this); // protect mSuspended - if (mSuspended == nsnull) - return NS_ERROR_FAILURE; - // XXX RemoveElement returns a bool instead of nsresult! - PRBool removed = mSuspended->RemoveElement(NS_STATIC_CAST(nsIChannel*, request)); - rv = removed ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - - // restart the request - rv = mPool->DispatchRequest(NS_STATIC_CAST(nsIRunnable*, request)); - return rv; -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.h b/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.h index 1bfaa038faa..9944159a82d 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.h +++ b/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.h @@ -56,10 +56,6 @@ public: Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); nsresult Init(); - nsresult DispatchRequest(nsIRunnable* runnable); - nsresult Suspend(nsFileChannel* request); - nsresult Resume(nsFileChannel* request); - nsresult ProcessPendingRequests(void); protected: nsIThreadPool* mPool; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h index dd05fcb8da4..2d2226987da 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -41,20 +41,10 @@ class nsFTPChannel : public nsIFTPChannel, public nsIStreamListener { public: NS_DECL_ISUPPORTS - - // nsIRequest methods: NS_DECL_NSIREQUEST - - // nsIChannel methods: NS_DECL_NSICHANNEL - - // nsIFTPChannel methods: NS_DECL_NSIFTPCHANNEL - - // nsIStreamObserver methods: NS_DECL_NSISTREAMOBSERVER - - // nsIStreamListener methods: NS_DECL_NSISTREAMLISTENER // nsFTPChannel methods: diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h index a2d6f4f4252..03d25fdae53 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -28,11 +28,9 @@ #include "nsIURI.h" #include "nsAutoLock.h" #include "prtime.h" - #include "nsString2.h" #include "nsIEventQueue.h" - // ftp server types #define FTP_GENERIC_TYPE 0 #define FTP_UNIX_TYPE 1 @@ -111,13 +109,11 @@ typedef enum _FTP_ACTION { class nsFtpConnectionThread : public nsIRunnable { public: NS_DECL_ISUPPORTS + NS_DECL_NSIRUNNABLE nsFtpConnectionThread(nsIEventQueue* aEventQ, nsIStreamListener *aListener, nsIChannel* channel, nsISupports* ctxt); virtual ~nsFtpConnectionThread(); - - // nsIRunnable method - NS_IMETHOD Run(); nsresult Init(nsIURI* aUrl); nsresult Process(); diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpStreamListenerEvent.h b/mozilla/netwerk/protocol/ftp/src/nsFtpStreamListenerEvent.h index aab0f425d0d..2c1c45d9881 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpStreamListenerEvent.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpStreamListenerEvent.h @@ -24,7 +24,6 @@ #include "nscore.h" #include "nsString.h" - class nsFtpStreamListenerEvent : public PLEvent { public: nsFtpStreamListenerEvent(nsIStreamListener* listener, diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h index 3fe7a1fdf28..6338d2ef76e 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h @@ -56,16 +56,9 @@ public: virtual ~nsHTTPChannel(); - // Functions from nsISupports NS_DECL_ISUPPORTS - - // nsIRequest methods: NS_DECL_NSIREQUEST - - // nsIChannel methods: NS_DECL_NSICHANNEL - - // nsIHTTPChannel methods: NS_DECL_NSIHTTPCHANNEL // nsHTTPChannel methods: diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h index d28ae619bc8..875ab48d302 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h @@ -122,8 +122,8 @@ public: create one. */ virtual nsresult RequestTransport(nsIURI *i_Uri, - nsHTTPChannel* i_Channel, - nsIChannel** o_pTrans); + nsHTTPChannel* i_Channel, + nsIChannel** o_pTrans); /* Remove this transport from the list. */ diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h index ebdc0031114..b44227e78ac 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h @@ -63,13 +63,8 @@ public: nsHTTPRequest(nsIURI* i_URL=0, HTTPMethod i_Method=HM_GET, nsIChannel* i_pTranport = nsnull); virtual ~nsHTTPRequest(); - // Methods from nsISupports NS_DECL_ISUPPORTS - - // nsIStreamObserver functions NS_DECL_NSISTREAMOBSERVER - - // nsIRequest methods: NS_DECL_NSIREQUEST // Finally our own methods... diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h index b077dcd5db7..fdc17f809c4 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.h @@ -58,21 +58,9 @@ public: nsHTTPResponseListener(nsHTTPChannel* aConnection); virtual ~nsHTTPResponseListener(); - // nsISupports functions NS_DECL_ISUPPORTS - - // nsIStreamListener functions - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength); - - - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); - - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg); + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER protected: // nsHTTPResponseListener methods... diff --git a/mozilla/netwerk/streamconv/test/Converters.h b/mozilla/netwerk/streamconv/test/Converters.h index 4fe11c59ffd..8c953619ca7 100644 --- a/mozilla/netwerk/streamconv/test/Converters.h +++ b/mozilla/netwerk/streamconv/test/Converters.h @@ -21,6 +21,8 @@ static NS_DEFINE_CID(kTestConverterCID, NS_TESTCONVERTER_CID); class TestConverter : public nsIStreamConverter { public: NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER TestConverter(); virtual ~TestConverter() {;}; @@ -33,15 +35,6 @@ public: NS_IMETHOD AsyncConvertData(const PRUnichar *aFromType, const PRUnichar *aToType, nsIStreamListener *aListener, nsISupports *ctxt); - // nsIStreamListener method - NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, - PRUint32 sourceOffset, PRUint32 count); - - // nsIStreamObserver methods - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt); - - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); - // member data nsIStreamListener *mListener; nsString2 fromType; diff --git a/mozilla/netwerk/test/TestFileInput.cpp b/mozilla/netwerk/test/TestFileInput.cpp index 704ffc3dfd5..60f65ff7305 100644 --- a/mozilla/netwerk/test/TestFileInput.cpp +++ b/mozilla/netwerk/test/TestFileInput.cpp @@ -361,7 +361,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts) NS_ASSERTION(listener, "QI failed"); nsIChannel* trans; - rv = fts->CreateTransport(spec, &trans); + rv = fts->CreateTransport(spec, "load", nsnull, &trans); NS_ASSERTION(NS_SUCCEEDED(rv), "create failed"); rv = trans->AsyncRead(0, -1, nsnull, listener); diff --git a/mozilla/netwerk/test/TestProtocols.cpp b/mozilla/netwerk/test/TestProtocols.cpp index c5524215905..4657fae9e24 100644 --- a/mozilla/netwerk/test/TestProtocols.cpp +++ b/mozilla/netwerk/test/TestProtocols.cpp @@ -251,20 +251,9 @@ public: InputTestConsumer(); virtual ~InputTestConsumer(); - // ISupports interface... NS_DECL_ISUPPORTS - - // IStreamListener interface... - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); - - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength); - - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg); + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER }; diff --git a/mozilla/netwerk/test/TestSocketIO.cpp b/mozilla/netwerk/test/TestSocketIO.cpp index 32b8bddab68..446a8542504 100644 --- a/mozilla/netwerk/test/TestSocketIO.cpp +++ b/mozilla/netwerk/test/TestSocketIO.cpp @@ -56,21 +56,9 @@ public: InputTestConsumer(); virtual ~InputTestConsumer(); - // ISupports interface... NS_DECL_ISUPPORTS - - // IStreamListener interface... - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); - - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength); - - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg); - + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER }; @@ -133,28 +121,21 @@ class TestWriteObserver : public nsIStreamObserver { public: - TestWriteObserver(nsIChannel* aTransport); + TestWriteObserver(nsIChannel* aChannel); virtual ~TestWriteObserver(); - // ISupports interface... NS_DECL_ISUPPORTS - - // IStreamObserver interface... - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); - - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg); + NS_DECL_NSISTREAMOBSERVER protected: nsIChannel* mTransport; }; -TestWriteObserver::TestWriteObserver(nsIChannel* aTransport) +TestWriteObserver::TestWriteObserver(nsIChannel* aChannel) { NS_INIT_REFCNT(); - mTransport = aTransport; + mTransport = aChannel; NS_ADDREF(mTransport); } diff --git a/mozilla/netwerk/test/TestSocketTransport.cpp b/mozilla/netwerk/test/TestSocketTransport.cpp index 6bef3e71e85..dd0df831c61 100644 --- a/mozilla/netwerk/test/TestSocketTransport.cpp +++ b/mozilla/netwerk/test/TestSocketTransport.cpp @@ -110,23 +110,10 @@ public: TestConnection(const char* aHostName, PRInt32 aPort, PRBool aAsyncFlag); virtual ~TestConnection(); - // nsISupports interface... NS_DECL_ISUPPORTS - - // nsIRunnable interface... - NS_IMETHOD Run(void); - - // IStreamListener interface... - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); - - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength); - - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, - nsresult aStatus, - const PRUnichar* aMsg); + NS_DECL_NSIRUNNABLE + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER // TestConnection methods... nsresult WriteBuffer(void); diff --git a/mozilla/netwerk/test/makefile.win b/mozilla/netwerk/test/makefile.win index 65825b43862..39cd4f6fac1 100644 --- a/mozilla/netwerk/test/makefile.win +++ b/mozilla/netwerk/test/makefile.win @@ -25,7 +25,8 @@ PROG4 = .\$(OBJDIR)\TestProtocols.exe PROG5 = .\$(OBJDIR)\TestSocketTransport.exe PROG6 = .\$(OBJDIR)\urltest.exe PROG7 = .\$(OBJDIR)\TestFileInput2.exe -PROGRAMS = $(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5) $(PROG6) $(PROG7) +PROG8 = .\$(OBJDIR)\TestFileTransport.exe +PROGRAMS = $(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5) $(PROG6) $(PROG7) $(PROG8) LCFLAGS=-DUSE_NSREG -GX @@ -62,3 +63,5 @@ $(PROG5): $(OBJDIR) TestSocketTransport.cpp $(PROG6): $(OBJDIR) urltest.cpp $(PROG7): $(OBJDIR) TestFileInput2.cpp + +$(PROG8): $(OBJDIR) TestFileTransport.cpp diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index 9855b24b36c..d1806eb89c9 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -133,9 +133,7 @@ public: NS_DECL_ISUPPORTS #ifdef NECKO - // nsIStreamObserver methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER #else NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 Progress, PRUint32 ProgressMax) { return NS_OK; } NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg) { return NS_OK; } @@ -144,6 +142,13 @@ public: #endif }; +#ifdef NECKO +NS_IMETHODIMP CStreamListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +{ + return NS_OK; +} +#endif + #ifdef NECKO NS_IMETHODIMP CStreamListener::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index a68ac231ef7..124b4162302 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -122,14 +122,8 @@ public: nsresult Init(nsDocLoaderImpl *aDocLoader, nsIStreamListener *aListener); NS_DECL_ISUPPORTS - - // nsIStreamListener methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, - const PRUnichar *errorMsg); - - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, - PRUint32 sourceOffset, PRUint32 count); + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER protected: virtual ~nsChannelListener(); @@ -300,10 +294,7 @@ public: void SetParent(nsDocLoaderImpl* aParent); void SetDocumentChannel(nsIChannel* channel); - // nsIStreamObserver methods: (for observing the load group) - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER nsILoadGroup* GetLoadGroup() { return mLoadGroup; } diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index a68ac231ef7..124b4162302 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -122,14 +122,8 @@ public: nsresult Init(nsDocLoaderImpl *aDocLoader, nsIStreamListener *aListener); NS_DECL_ISUPPORTS - - // nsIStreamListener methods: - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, - const PRUnichar *errorMsg); - - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, - PRUint32 sourceOffset, PRUint32 count); + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER protected: virtual ~nsChannelListener(); @@ -300,10 +294,7 @@ public: void SetParent(nsDocLoaderImpl* aParent); void SetDocumentChannel(nsIChannel* channel); - // nsIStreamObserver methods: (for observing the load group) - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER nsILoadGroup* GetLoadGroup() { return mLoadGroup; } diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h index c6c2612d951..fcf706c5c43 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h @@ -90,10 +90,7 @@ public: NS_IMETHOD LoadURL(const nsString &aURL); #ifdef NECKO - // nsIStreamObserver - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, - nsresult status, const PRUnichar *errorMsg); + NS_DECL_NSISTREAMOBSERVER #else // nsIStreamObserver NS_IMETHOD OnStartRequest(nsIURI* aURL, const char *aContentType); diff --git a/mozilla/xpcom/build/Makefile.in b/mozilla/xpcom/build/Makefile.in index c5569645b68..1c72730e5cb 100644 --- a/mozilla/xpcom/build/Makefile.in +++ b/mozilla/xpcom/build/Makefile.in @@ -48,6 +48,7 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../io \ -I$(srcdir)/../components \ -I$(srcdir)/../threads \ + -I$(srcdir)/../threads/_xpidlgen \ -I$(srcdir)/../proxy/src \ $(NULL) diff --git a/mozilla/xpcom/build/makefile.win b/mozilla/xpcom/build/makefile.win index 425235a657c..8a34c1db0bc 100644 --- a/mozilla/xpcom/build/makefile.win +++ b/mozilla/xpcom/build/makefile.win @@ -37,6 +37,7 @@ LINCS = \ -I..\io \ -I..\components \ -I..\threads \ + -I..\threads\_xpidlgen \ -I..\reflect\xptinfo\src \ -I..\proxy\src \ $(NULL) diff --git a/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp b/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp index 6da24799c0e..87863f8d6c7 100644 --- a/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp @@ -161,24 +161,9 @@ public: nsIContentViewerContainer* aContainer, nsIStreamListener** aResult); - // nsISupports interface NS_DECL_ISUPPORTS - - // nsIStreamObserver interface - NS_IMETHOD OnStartRequest(nsIChannel* aChannel, nsISupports* aContext); - - NS_IMETHOD OnStopRequest(nsIChannel* aChannel, - nsISupports* aContext, - nsresult aStatus, - const PRUnichar* aErrorMsg); - - // nsIStreamListener interface - NS_IMETHOD OnDataAvailable(nsIChannel* aChannel, - nsISupports* aContext, - nsIInputStream* aStream, - PRUint32 aSourceOffset, - PRUint32 aCount); - + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER };