From 89f98a47db7cd691a1c4060a4e18c0c6e93095d0 Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Tue, 22 Jun 1999 00:19:58 +0000 Subject: [PATCH] Added stuff needed for landing -- LoadQuiet, BypassCache, BypassProxy --- netwerk/Makefile.in | 1 + netwerk/base/public/nsIChannel.idl | 13 +++++ netwerk/base/src/nsSocketTransport.cpp | 19 ++++++++ netwerk/base/src/nsSocketTransport.h | 4 ++ netwerk/makefile.win | 1 + netwerk/protocol/file/src/nsFileChannel.cpp | 20 ++++++++ netwerk/protocol/file/src/nsFileChannel.h | 9 +++- netwerk/protocol/ftp/src/nsFTPChannel.cpp | 14 ++++++ netwerk/protocol/ftp/src/nsFTPChannel.h | 6 ++- .../protocol/http/public/nsIHTTPChannel.idl | 4 ++ netwerk/protocol/http/src/nsHTTPChannel.cpp | 47 +++++++++++++++++++ netwerk/protocol/http/src/nsHTTPChannel.h | 12 ++++- 12 files changed, 146 insertions(+), 4 deletions(-) diff --git a/netwerk/Makefile.in b/netwerk/Makefile.in index 05ae76b9ca29..eca150857686 100644 --- a/netwerk/Makefile.in +++ b/netwerk/Makefile.in @@ -30,6 +30,7 @@ DIRS= \ dns \ build \ protocol \ + util \ test \ $(NULL) diff --git a/netwerk/base/public/nsIChannel.idl b/netwerk/base/public/nsIChannel.idl index cf0659bcd1f7..0207cf48e8d7 100644 --- a/netwerk/base/public/nsIChannel.idl +++ b/netwerk/base/public/nsIChannel.idl @@ -87,5 +87,18 @@ interface nsIChannel : nsIRequest in nsIEventQueue eventQueue, in nsIStreamObserver observer); + /** + * Setting this attribute causes the loading process to not deliver status + * notifications to the program performing the load. + */ + attribute boolean LoadQuiet; + + /** + * Returns the content MIME type of the channel if available. Note that the + * content type can often be wrongly specified (wrong file extension, wrong + * MIME type, wrong document type stored on a server, etc.) and the caller + * most likely wants to verify with the actual data. + */ + readonly attribute string ContentType; }; diff --git a/netwerk/base/src/nsSocketTransport.cpp b/netwerk/base/src/nsSocketTransport.cpp index 5599835eea05..f378acfb8639 100644 --- a/netwerk/base/src/nsSocketTransport.cpp +++ b/netwerk/base/src/nsSocketTransport.cpp @@ -1240,4 +1240,23 @@ nsSocketTransport::OpenOutputStream(PRUint32 startPosition, nsIOutputStream* *re return rv; } +NS_IMETHODIMP +nsSocketTransport::GetLoadQuiet(PRBool *aLoadQuiet) +{ + *aLoadQuiet = mLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetLoadQuiet(PRBool aLoadQuiet) +{ + mLoadQuiet = aLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::GetContentType(char * *aContentType) +{ + return NS_ERROR_FAILURE; // XXX doesn't make sense for transports +} diff --git a/netwerk/base/src/nsSocketTransport.h b/netwerk/base/src/nsSocketTransport.h index 2e74b0965515..ba2339dfada0 100644 --- a/netwerk/base/src/nsSocketTransport.h +++ b/netwerk/base/src/nsSocketTransport.h @@ -91,6 +91,9 @@ public: nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); + NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); + NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetContentType(char * *aContentType); // nsIBufferObserver methods: NS_IMETHOD OnFull(nsIBuffer* buffer); @@ -150,6 +153,7 @@ protected: PRUint32 mSourceOffset; nsSocketTransportService* mService; + PRBool mLoadQuiet; }; diff --git a/netwerk/makefile.win b/netwerk/makefile.win index c8aca92e08b8..1252cb1d67da 100644 --- a/netwerk/makefile.win +++ b/netwerk/makefile.win @@ -24,6 +24,7 @@ DIRS= \ dns \ build \ protocol \ + util \ test \ $(NULL) diff --git a/netwerk/protocol/file/src/nsFileChannel.cpp b/netwerk/protocol/file/src/nsFileChannel.cpp index fc2f881cfade..777d2b3c58d1 100644 --- a/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/netwerk/protocol/file/src/nsFileChannel.cpp @@ -417,6 +417,26 @@ nsFileChannel::AsyncWrite(nsIInputStream *fromStream, return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsFileChannel::GetLoadQuiet(PRBool *aLoadQuiet) +{ + *aLoadQuiet = mLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::SetLoadQuiet(PRBool aLoadQuiet) +{ + mLoadQuiet = aLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::GetContentType(char * *aContentType) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + //////////////////////////////////////////////////////////////////////////////// // nsIRunnable methods: //////////////////////////////////////////////////////////////////////////////// diff --git a/netwerk/protocol/file/src/nsFileChannel.h b/netwerk/protocol/file/src/nsFileChannel.h index 21bf4b159843..11e6394078b5 100644 --- a/netwerk/protocol/file/src/nsFileChannel.h +++ b/netwerk/protocol/file/src/nsFileChannel.h @@ -67,6 +67,13 @@ public: /* void AsyncWrite (in nsIInputStream fromStream, in unsigned long startPosition, in long writeCount, in nsISupports ctxt, in nsIEventQueue eventQueue, in nsIStreamObserver observer); */ NS_IMETHOD AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition, PRInt32 writeCount, nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); + /* attribute boolean LoadQuiet; */ + NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); + NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + + /* readonly attribute string ContentType; */ + NS_IMETHOD GetContentType(char * *aContentType); + //////////////////////////////////////////////////////////////////////////// // from nsIFileChannel: @@ -173,8 +180,8 @@ protected: PRUint32 mSourceOffset; PRInt32 mAmount; -private: PRLock* mLock; + PRBool mLoadQuiet; }; #define NS_FILE_TRANSPORT_SEGMENT_SIZE (4*1024) diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/netwerk/protocol/ftp/src/nsFTPChannel.cpp index d98a79ec15e0..0c425b2bada8 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -186,6 +186,20 @@ nsFTPChannel::AsyncWrite(nsIInputStream *fromStream, return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsFTPChannel::GetLoadQuiet(PRBool *aLoadQuiet) +{ + *aLoadQuiet = mLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::SetLoadQuiet(PRBool aLoadQuiet) +{ + mLoadQuiet = aLoadQuiet; + return NS_OK; +} + NS_IMETHODIMP nsFTPChannel::GetContentType(char* *contentType) { diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.h b/netwerk/protocol/ftp/src/nsFTPChannel.h index c4dc5511e2cc..1cff37045b16 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -55,6 +55,9 @@ public: nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); + NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); + NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetContentType(char * *aContentType); // nsIFTPChannel methods: NS_IMETHOD Get(void); @@ -88,8 +91,6 @@ public: nsresult Init(const char* verb, nsIURI* uri, nsIEventSinkGetter* getter, nsIEventQueue* queue); - NS_IMETHOD GetContentType(char* *contentType); - protected: nsIURI* mUrl; nsIEventQueue* mEventQueue; @@ -97,6 +98,7 @@ protected: PRBool mConnected; nsIStreamListener* mListener; + PRBool mLoadQuiet; }; #endif /* nsFTPChannel_h___ */ diff --git a/netwerk/protocol/http/public/nsIHTTPChannel.idl b/netwerk/protocol/http/public/nsIHTTPChannel.idl index 071cb13fe7bb..888f1c47fa91 100644 --- a/netwerk/protocol/http/public/nsIHTTPChannel.idl +++ b/netwerk/protocol/http/public/nsIHTTPChannel.idl @@ -49,6 +49,10 @@ interface nsIHTTPChannel : nsIChannel readonly attribute nsIHTTPEventSink EventSink; readonly attribute nsIStreamListener ResponseDataListener; + + attribute boolean BypassCache; + + attribute boolean BypassProxy; }; diff --git a/netwerk/protocol/http/src/nsHTTPChannel.cpp b/netwerk/protocol/http/src/nsHTTPChannel.cpp index 9fb9155e23f0..72824d4c2a5b 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -211,6 +211,26 @@ nsHTTPChannel::AsyncWrite(nsIInputStream *fromStream, return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsHTTPChannel::GetLoadQuiet(PRBool *aLoadQuiet) +{ + *aLoadQuiet = mLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::SetLoadQuiet(PRBool aLoadQuiet) +{ + mLoadQuiet = aLoadQuiet; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::GetContentType(char * *aContentType) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + //////////////////////////////////////////////////////////////////////////////// // nsIHTTPChannel methods: @@ -297,6 +317,33 @@ nsHTTPChannel::GetResponseDataListener(nsIStreamListener* *aListener) return rv; } +NS_IMETHODIMP +nsHTTPChannel::GetBypassCache(PRBool *aBypassCache) +{ + *aBypassCache = mBypassCache; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::SetBypassCache(PRBool aBypassCache) +{ + mBypassCache = aBypassCache; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::GetBypassProxy(PRBool *aBypassProxy) +{ + *aBypassProxy = mBypassProxy; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::SetBypassProxy(PRBool aBypassProxy) +{ + mBypassProxy = aBypassProxy; + return NS_OK; +} static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); diff --git a/netwerk/protocol/http/src/nsHTTPChannel.h b/netwerk/protocol/http/src/nsHTTPChannel.h index 3f8648240109..dd77c708f960 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/netwerk/protocol/http/src/nsHTTPChannel.h @@ -74,7 +74,10 @@ public: nsISupports *ctxt, nsIEventQueue *eventQueue, nsIStreamObserver *observer); - NS_IMETHOD Open(); + NS_IMETHOD GetLoadQuiet(PRBool *aLoadQuiet); + NS_IMETHOD SetLoadQuiet(PRBool aLoadQuiet); + NS_IMETHOD GetContentType(char * *aContentType); + NS_IMETHOD Open(); // nsIHTTPChannel methods: NS_IMETHOD GetRequestHeader(const char *headerName, char **_retval); @@ -85,6 +88,10 @@ public: NS_IMETHOD GetResponseString(char * *aResponseString); NS_IMETHOD GetEventSink(nsIHTTPEventSink* *eventSink); NS_IMETHOD GetResponseDataListener(nsIStreamListener* *aListener); + NS_IMETHOD GetBypassCache(PRBool *aBypassCache); + NS_IMETHOD SetBypassCache(PRBool aBypassCache); + NS_IMETHOD GetBypassProxy(PRBool *aBypassProxy); + NS_IMETHOD SetBypassProxy(PRBool aBypassProxy); // nsHTTPChannel methods: nsresult Init(); @@ -101,6 +108,9 @@ protected: nsHTTPRequest* m_pRequest; nsHTTPResponse* m_pResponse; nsIStreamListener* m_pResponseDataListener; + PRBool mLoadQuiet; + PRBool mBypassCache; + PRBool mBypassProxy; }; #endif /* _nsHTTPChannel_h_ */