From 03f69c5003e8c43e398b57b714f0330b971513e4 Mon Sep 17 00:00:00 2001 From: "disttsc%bart.nl" Date: Mon, 12 Feb 2001 03:14:23 +0000 Subject: [PATCH] Back out dougt's channel changes git-svn-id: svn://10.0.0.236/trunk@86793 18797224-902f-48f8-a5cc-f745e15eee43 --- .../chrome/src/nsChromeProtocolHandler.cpp | 180 +- .../content/base/src/nsSyncLoadService.cpp | 2 +- mozilla/content/xml/document/src/Makefile.in | 2 +- .../xml/document/src/nsXMLContentSink.cpp | 6 +- .../xml/document/src/nsXMLDocument.cpp | 13 +- .../xul/document/src/nsXULDocument.cpp | 120 +- .../content/xul/document/src/nsXULDocument.h | 4 +- .../xpcom/base/src/nsLDAPChannel.cpp | 182 +- .../docshell/base/nsDSURIContentListener.cpp | 6 +- mozilla/docshell/base/nsDocShell.cpp | 19 +- mozilla/docshell/base/nsDocShell.h | 4 +- mozilla/docshell/base/nsWebShell.cpp | 30 +- mozilla/docshell/base/nsWebShell.h | 4 +- mozilla/editor/base/nsEditorShell.cpp | 2 +- mozilla/editor/composer/src/nsEditorShell.cpp | 2 +- mozilla/embedding/browser/Makefile.in | 1 - .../src/control/WebBrowserContainer.cpp | 21 +- .../browser/gtk/src/GtkMozEmbedChrome.cpp | 11 +- .../webBrowser/nsWBURIContentListener.cpp | 2 +- .../webBrowser/nsWebBrowserPersist.cpp | 83 +- .../browser/webBrowser/nsWebBrowserPersist.h | 4 +- .../extensions/cookie/nsCookieHTTPNotify.cpp | 10 +- .../extensions/datetime/nsDateTimeChannel.cpp | 153 +- .../extensions/datetime/nsDateTimeChannel.h | 7 +- mozilla/extensions/finger/nsFingerChannel.cpp | 155 +- mozilla/extensions/finger/nsFingerChannel.h | 10 +- .../irc/js/lib/chatzilla-service.js | 22 +- .../extensions/irc/js/lib/connection-xpcom.js | 16 +- mozilla/extensions/pics/src/nsPICS.cpp | 26 +- .../extensions/psm-glue/public/psm-glue.js | 2 - .../psm-glue/src/nsPSMComponent.cpp | 33 +- .../source/xml/parser/nsSyncLoader.cpp | 2 +- .../extensions/wallet/src/nsWalletService.cpp | 11 +- .../extensions/xml-rpc/src/nsXmlRpcClient.js | 8 +- .../xmlextras/base/src/nsDOMParser.cpp | 111 +- .../xmlextras/base/src/nsXMLHttpRequest.cpp | 6 +- .../xmlextras/base/src/nsXMLHttpRequest.h | 1 - .../xmlextras/tests/TestXMLExtras.cpp | 2 +- .../xmlterm/base/mozXMLTerminal.cpp | 10 +- .../extensions/xmlterm/ui/xmlterm-service.js | 28 +- mozilla/gfx/src/nsImageNetContextAsync.cpp | 80 +- mozilla/gfx/src/nsImageNetContextSync.cpp | 7 +- mozilla/htmlparser/robot/nsDebugRobot.cpp | 10 +- mozilla/htmlparser/src/CParserContext.cpp | 4 +- mozilla/htmlparser/src/CParserContext.h | 2 +- mozilla/htmlparser/src/nsParser.cpp | 27 +- .../htmlparser/tests/grabpage/grabpage.cpp | 2 +- mozilla/intl/strres/src/nsStringBundle.cpp | 6 +- mozilla/layout/base/nsPresShell.cpp | 59 +- mozilla/layout/html/base/src/nsPresShell.cpp | 59 +- .../html/document/src/nsHTMLContentSink.cpp | 8 +- .../html/document/src/nsHTMLDocument.cpp | 52 +- .../html/document/src/nsImageDocument.cpp | 16 +- mozilla/layout/xbl/src/nsXBLService.cpp | 37 +- mozilla/layout/xml/document/src/Makefile.in | 2 +- .../xml/document/src/nsXMLContentSink.cpp | 6 +- .../layout/xml/document/src/nsXMLDocument.cpp | 13 +- .../layout/xml/document/src/nsXMLDocument.h | 2 +- .../absync/src/nsAbSyncPostEngine.cpp | 26 +- .../mailnews/absync/src/nsAbSyncPostEngine.h | 1 + mozilla/mailnews/base/public/nsIMsgFolder.idl | 4 +- .../base/src/nsCopyMessageStreamListener.cpp | 6 +- mozilla/mailnews/base/src/nsMessenger.cpp | 6 +- .../base/src/nsMsgFolderCompactor.cpp | 8 +- .../mailnews/base/src/nsMsgFolderCompactor.h | 2 +- .../mailnews/base/src/nsMsgPrintEngine.cpp | 14 +- .../mailnews/base/src/nsMsgStatusFeedback.cpp | 6 +- mozilla/mailnews/base/src/nsMsgWindow.cpp | 7 +- mozilla/mailnews/base/util/nsMsgDBFolder.cpp | 32 +- mozilla/mailnews/base/util/nsMsgDBFolder.h | 4 +- mozilla/mailnews/base/util/nsMsgFolder.cpp | 1 - mozilla/mailnews/base/util/nsMsgProtocol.cpp | 202 +- mozilla/mailnews/base/util/nsMsgProtocol.h | 12 +- mozilla/mailnews/compose/src/nsMsgCompose.cpp | 6 +- .../src/nsMsgComposeContentHandler.cpp | 7 +- mozilla/mailnews/compose/src/nsMsgQuote.cpp | 2 +- .../mailnews/compose/src/nsMsgSendLater.cpp | 9 +- .../mailnews/compose/src/nsSmtpProtocol.cpp | 5 +- mozilla/mailnews/compose/src/nsSmtpProtocol.h | 2 +- .../mailnews/compose/src/nsSmtpService.cpp | 117 +- mozilla/mailnews/compose/src/nsURLFetcher.cpp | 50 +- mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp | 2 +- .../imap/src/nsImapIncomingServer.cpp | 5 +- .../mailnews/imap/src/nsImapMailFolder.cpp | 19 +- mozilla/mailnews/imap/src/nsImapProtocol.cpp | 202 +- mozilla/mailnews/imap/src/nsImapProtocol.h | 3 +- mozilla/mailnews/imap/src/nsImapService.cpp | 6 +- mozilla/mailnews/imap/src/nsImapUrl.cpp | 6 +- .../mailnews/local/src/nsMailboxProtocol.cpp | 24 +- .../mailnews/local/src/nsMailboxProtocol.h | 10 +- mozilla/mailnews/local/src/nsParseMailbox.cpp | 6 +- mozilla/mailnews/local/src/nsPop3Protocol.cpp | 4 +- mozilla/mailnews/local/src/nsPop3Protocol.h | 2 +- .../mime/emitters/src/nsMimeBaseEmitter.cpp | 10 +- .../mime/emitters/src/nsMimeBaseEmitter.h | 2 +- mozilla/mailnews/mime/src/mimemoz2.cpp | 1 + .../mailnews/mime/src/nsStreamConverter.cpp | 37 +- mozilla/mailnews/news/src/nsNNTPProtocol.cpp | 64 +- mozilla/mailnews/news/src/nsNNTPProtocol.h | 4 +- mozilla/mailnews/news/src/nsNntpService.cpp | 5 +- mozilla/modules/libjar/nsJARChannel.cpp | 143 +- mozilla/modules/libjar/nsJARChannel.h | 6 +- .../plugin/base/src/nsPluginHostImpl.cpp | 47 +- .../plugin/base/src/nsPluginHostImpl.h | 1 - .../plugin/base/src/nsPluginViewer.cpp | 35 +- .../plugin/nglsrc/nsPluginHostImpl.cpp | 47 +- .../modules/plugin/nglsrc/nsPluginHostImpl.h | 1 - .../modules/plugin/nglsrc/nsPluginViewer.cpp | 35 +- mozilla/netwerk/base/public/MANIFEST_IDL | 1 - mozilla/netwerk/base/public/Makefile.in | 1 - mozilla/netwerk/base/public/makefile.win | 4 +- mozilla/netwerk/base/public/nsIChannel.idl | 161 +- mozilla/netwerk/base/public/nsIDownloader.idl | 4 +- .../base/public/nsIFileTransportService.idl | 18 +- mozilla/netwerk/base/public/nsIIOService.idl | 9 + mozilla/netwerk/base/public/nsILoadGroup.idl | 27 +- .../base/public/nsIProgressEventSink.idl | 8 +- .../base/public/nsISocketTransport.idl | 7 +- .../base/public/nsISocketTransportService.idl | 47 +- .../netwerk/base/public/nsIStreamListener.idl | 6 +- .../netwerk/base/public/nsIStreamLoader.idl | 9 +- .../netwerk/base/public/nsIStreamObserver.idl | 10 +- .../netwerk/base/public/nsIStreamProvider.idl | 4 +- mozilla/netwerk/base/public/nsITransport.idl | 105 - mozilla/netwerk/base/public/nsNetUtil.h | 113 +- mozilla/netwerk/base/public/security-prefs.js | 4 - .../base/src/nsAsyncStreamListener.cpp | 50 +- .../netwerk/base/src/nsAsyncStreamListener.h | 12 +- mozilla/netwerk/base/src/nsDownloader.cpp | 26 +- mozilla/netwerk/base/src/nsFileTransport.cpp | 220 +- mozilla/netwerk/base/src/nsFileTransport.h | 11 +- .../base/src/nsFileTransportService.cpp | 6 +- mozilla/netwerk/base/src/nsIOService.cpp | 34 + .../netwerk/base/src/nsInputStreamChannel.cpp | 317 +- .../netwerk/base/src/nsInputStreamChannel.h | 4 +- mozilla/netwerk/base/src/nsLoadGroup.cpp | 284 +- mozilla/netwerk/base/src/nsLoadGroup.h | 13 +- .../base/src/nsSimpleStreamListener.cpp | 10 +- .../base/src/nsSimpleStreamProvider.cpp | 10 +- .../netwerk/base/src/nsSocketTransport.cpp | 2595 +++++++++-------- mozilla/netwerk/base/src/nsSocketTransport.h | 281 +- .../base/src/nsSocketTransportService.cpp | 12 +- .../base/src/nsStreamListenerProxy.cpp | 86 +- .../netwerk/base/src/nsStreamListenerProxy.h | 2 +- mozilla/netwerk/base/src/nsStreamLoader.cpp | 23 +- mozilla/netwerk/base/src/nsStreamLoader.h | 2 +- .../base/src/nsStreamObserverProxy.cpp | 38 +- .../netwerk/base/src/nsStreamObserverProxy.h | 4 +- .../base/src/nsStreamProviderProxy.cpp | 42 +- .../netwerk/base/src/nsSyncStreamListener.cpp | 6 +- .../cache/filecache/nsDiskCacheRecord.cpp | 24 +- .../cache/filecache/nsDiskCacheRecord.h | 47 +- .../filecache/nsDiskCacheRecordChannel.cpp | 459 +-- .../filecache/nsDiskCacheRecordChannel.h | 48 +- .../netwerk/cache/filecache/nsNetDiskCache.h | 44 +- mozilla/netwerk/cache/memcache/nsMemCache.h | 2 +- .../cache/memcache/nsMemCacheChannel.cpp | 346 ++- .../cache/memcache/nsMemCacheChannel.h | 21 +- .../cache/memcache/nsMemCacheRecord.cpp | 14 +- .../netwerk/cache/memcache/nsMemCacheRecord.h | 4 +- .../netwerk/cache/mgr/nsCacheEntryChannel.cpp | 174 +- .../netwerk/cache/mgr/nsCacheEntryChannel.h | 42 +- mozilla/netwerk/cache/mgr/nsCachedNetData.cpp | 39 +- mozilla/netwerk/cache/mgr/nsCachedNetData.h | 6 +- .../netwerk/cache/public/nsICachedNetData.idl | 21 +- .../cache/public/nsINetDataCacheRecord.idl | 14 +- .../netwerk/cache/public/nsIStreamAsFile.idl | 2 +- mozilla/netwerk/macbuild/netwerk.mcp | Bin 145144 -> 145144 bytes mozilla/netwerk/macbuild/netwerkIDL.mcp | Bin 75140 -> 75140 bytes .../netwerk/mime/src/nsXMLMIMEDataSource.cpp | 27 +- .../protocol/data/src/nsDataChannel.cpp | 114 +- .../netwerk/protocol/data/src/nsDataChannel.h | 2 + .../datetime/src/nsDateTimeChannel.cpp | 153 +- .../protocol/datetime/src/nsDateTimeChannel.h | 7 +- .../protocol/file/public/nsIFileChannel.idl | 132 +- .../file/public/nsIFileProtocolHandler.idl | 39 +- .../protocol/file/src/nsFileChannel.cpp | 242 +- .../netwerk/protocol/file/src/nsFileChannel.h | 4 +- .../protocol/finger/src/nsFingerChannel.cpp | 155 +- .../protocol/finger/src/nsFingerChannel.h | 10 +- .../netwerk/protocol/ftp/src/nsFTPChannel.cpp | 171 +- .../netwerk/protocol/ftp/src/nsFTPChannel.h | 17 +- .../ftp/src/nsFtpConnectionThread.cpp | 267 +- .../protocol/ftp/src/nsFtpConnectionThread.h | 18 +- .../ftp/src/nsFtpControlConnection.cpp | 54 +- .../protocol/ftp/src/nsFtpControlConnection.h | 21 +- .../protocol/http/public/nsIHTTPChannel.idl | 4 +- .../protocol/http/src/nsHTTPChannel.cpp | 302 +- .../netwerk/protocol/http/src/nsHTTPChannel.h | 12 +- .../protocol/http/src/nsHTTPHandler.cpp | 90 +- .../netwerk/protocol/http/src/nsHTTPHandler.h | 19 +- .../protocol/http/src/nsHTTPRequest.cpp | 133 +- .../netwerk/protocol/http/src/nsHTTPRequest.h | 19 +- .../http/src/nsHTTPResponseListener.cpp | 108 +- .../protocol/http/src/nsHTTPSHandler.cpp | 15 +- .../protocol/http/src/nsHTTPSHandler.h | 8 +- .../netwerk/protocol/jar/src/nsJARChannel.cpp | 143 +- .../netwerk/protocol/jar/src/nsJARChannel.h | 6 +- mozilla/netwerk/protocol/res/src/Makefile.in | 2 +- .../netwerk/protocol/res/src/nsResChannel.cpp | 320 +- .../netwerk/protocol/res/src/nsResChannel.h | 10 +- .../protocol/res/src/nsResProtocolHandler.cpp | 2 +- .../converters/mozTXTToHTMLConv.cpp | 10 +- .../converters/nsFTPDirListingConv.cpp | 93 +- .../converters/nsFTPDirListingConv.h | 6 +- .../streamconv/converters/nsHTTPChunkConv.cpp | 15 +- .../converters/nsHTTPCompressConv.cpp | 81 +- .../converters/nsHTTPCompressConv.h | 2 +- .../converters/nsMultiMixedConv.cpp | 40 +- .../streamconv/converters/nsTXTToHTMLConv.cpp | 30 +- .../streamconv/converters/nsTXTToHTMLConv.h | 1 + .../converters/nsUnknownDecoder.cpp | 37 +- .../streamconv/converters/nsUnknownDecoder.h | 5 +- .../netwerk/streamconv/test/Converters.cpp | 12 +- .../streamconv/test/TestStreamConv.cpp | 21 +- mozilla/netwerk/test/Makefile.in | 3 +- mozilla/netwerk/test/TestCacheMgr.cpp | 21 +- mozilla/netwerk/test/TestCallbacks.cpp | 24 +- mozilla/netwerk/test/TestFileInput.cpp | 12 +- mozilla/netwerk/test/TestFileInput2.cpp | 10 +- mozilla/netwerk/test/TestFileTransport.cpp | 36 +- mozilla/netwerk/test/TestProtocols.cpp | 80 +- mozilla/netwerk/test/TestRawCache.cpp | 29 +- mozilla/netwerk/test/TestRes.cpp | 15 +- mozilla/netwerk/test/TestSocketIO.cpp | 207 +- mozilla/netwerk/test/TestSocketInput.cpp | 20 +- mozilla/netwerk/test/TestSocketTransport.cpp | 58 +- mozilla/netwerk/test/TestSyncHTTP.cpp | 8 +- mozilla/netwerk/test/TestWriteStream.cpp | 7 +- .../parser/htmlparser/robot/nsDebugRobot.cpp | 10 +- .../parser/htmlparser/src/CParserContext.cpp | 4 +- .../parser/htmlparser/src/CParserContext.h | 2 +- mozilla/parser/htmlparser/src/nsParser.cpp | 27 +- .../htmlparser/tests/grabpage/grabpage.cpp | 2 +- mozilla/profile/Acct/nsAccount.cpp | 4 +- mozilla/rdf/base/src/nsRDFContentSink.cpp | 3 +- mozilla/rdf/base/src/nsRDFXMLDataSource.cpp | 27 +- .../chrome/src/nsChromeProtocolHandler.cpp | 180 +- mozilla/rdf/content/src/Makefile.in | 2 +- mozilla/rdf/content/src/nsXULDocument.cpp | 120 +- mozilla/rdf/content/src/nsXULDocument.h | 4 +- mozilla/uriloader/base/nsDocLoader.cpp | 157 +- mozilla/uriloader/base/nsDocLoader.h | 24 +- mozilla/uriloader/base/nsIContentHandler.idl | 6 +- .../base/nsIDocumentLoaderObserver.idl | 13 +- .../uriloader/base/nsIURIContentListener.idl | 4 +- mozilla/uriloader/base/nsIURILoader.idl | 3 +- mozilla/uriloader/base/nsURILoader.cpp | 88 +- .../exthandler/nsExternalHelperAppService.cpp | 52 +- .../exthandler/nsExternalHelperAppService.h | 2 +- .../exthandler/nsExternalProtocolHandler.cpp | 93 +- .../webshell/tests/viewer/nsBrowserWindow.cpp | 15 +- .../webshell/tests/viewer/nsWebCrawler.cpp | 11 +- .../widget/src/gtk/nsGtkMozRemoteHelper.cpp | 2 +- mozilla/widget/src/gtk/nsSound.cpp | 20 +- mozilla/widget/src/os2/nsSound.cpp | 20 +- mozilla/widget/src/windows/nsSound.cpp | 5 +- mozilla/xpcom/tests/PropertiesTest.cpp | 2 +- mozilla/xpcom/tests/utils/io.js | 4 +- .../appshell/public/nsIXULBrowserWindow.idl | 8 +- .../browser/public/nsIXULBrowserWindow.idl | 8 +- .../browser/resources/content/navigator.js | 15 +- .../xpfe/browser/src/nsBrowserInstance.cpp | 49 +- mozilla/xpfe/browser/src/nsBrowserInstance.h | 4 +- .../bookmarks/src/nsBookmarksService.cpp | 11 +- .../directory/nsDirectoryViewer.cpp | 12 +- .../related/src/nsRelatedLinksHandler.cpp | 6 +- .../search/src/nsInternetSearchService.cpp | 35 +- .../ucth/public/nsIUnkContentTypeHandler.idl | 4 +- .../ucth/src/nsUnknownContentTypeHandler.cpp | 11 +- .../components/xfer/src/nsStreamTransfer.cpp | 7 +- .../components/xfer/src/nsStreamXferOp.cpp | 53 +- .../xpfe/components/xfer/src/nsStreamXferOp.h | 4 +- mozilla/xpinstall/src/nsInstallTrigger.cpp | 5 +- mozilla/xpinstall/src/nsXPInstallManager.cpp | 18 +- 275 files changed, 7847 insertions(+), 5710 deletions(-) diff --git a/mozilla/chrome/src/nsChromeProtocolHandler.cpp b/mozilla/chrome/src/nsChromeProtocolHandler.cpp index 9d3566b0c6d..392fb916814 100644 --- a/mozilla/chrome/src/nsChromeProtocolHandler.cpp +++ b/mozilla/chrome/src/nsChromeProtocolHandler.cpp @@ -116,25 +116,27 @@ public: NS_DECL_ISUPPORTS // nsIRequest - NS_IMETHOD GetName(PRUnichar* *result) { return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetName(PRUnichar* *result) { + NS_NOTREACHED("nsCachedChromeChannel::GetName"); + return NS_ERROR_NOT_IMPLEMENTED; + } NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; } NS_IMETHOD GetStatus(nsresult *status) { *status = mStatus; return NS_OK; } NS_IMETHOD Cancel(nsresult status) { mStatus = status; return NS_OK; } NS_IMETHOD Suspend(void) { return NS_OK; } NS_IMETHOD Resume(void) { return NS_OK; } - -// nsIChannel - NS_DECL_NSICHANNEL + // nsIChannel + NS_DECL_NSICHANNEL }; #ifdef PR_LOGGING PRLogModuleInfo* nsCachedChromeChannel::gLog; #endif -NS_IMPL_ISUPPORTS2(nsCachedChromeChannel, - nsIChannel, - nsIRequest); +NS_IMPL_ADDREF(nsCachedChromeChannel); +NS_IMPL_RELEASE(nsCachedChromeChannel); +NS_IMPL_QUERY_INTERFACE2(nsCachedChromeChannel, nsIRequest, nsIChannel); nsresult nsCachedChromeChannel::Create(nsIURI* aURI, nsIChannel** aResult) @@ -209,7 +211,7 @@ nsCachedChromeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsCachedChromeChannel::Open(nsIInputStream **_retval) +nsCachedChromeChannel::OpenInputStream(nsIInputStream **_retval) { // NS_NOTREACHED("don't do that"); *_retval = nsnull; @@ -217,7 +219,15 @@ nsCachedChromeChannel::Open(nsIInputStream **_retval) } NS_IMETHODIMP -nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +nsCachedChromeChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("don't do that"); + *_retval = nsnull; + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { if (listener) { nsresult rv; @@ -227,7 +237,7 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: adding self to load group %p", this, mLoadGroup.get())); - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -247,7 +257,7 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: removing self from load group %p", this, mLoadGroup.get())); - (void) mLoadGroup->RemoveRequest(this, nsnull, nsnull, nsnull); + (void) mLoadGroup->RemoveChannel(this, nsnull, nsnull, nsnull); } return rv; @@ -261,9 +271,10 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) } NS_IMETHODIMP -nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +nsCachedChromeChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { - return NS_ERROR_NOT_IMPLEMENTED; + NS_NOTREACHED("don't do that"); + return NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -280,6 +291,113 @@ nsCachedChromeChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) return NS_OK; } +NS_IMETHODIMP +nsCachedChromeChannel::GetContentType(char * *aContentType) +{ + *aContentType = nsXPIDLCString::Copy("text/cached-xul"); + return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetContentType(const char *aContentType) +{ + // Do not allow the content-type to be changed. + NS_NOTREACHED("don't do that"); + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetContentLength(PRInt32 *aContentLength) +{ + NS_NOTREACHED("don't do that"); + *aContentLength = 0; + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetContentLength(PRInt32 aContentLength) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetContentLength"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsCachedChromeChannel::GetOwner(nsISupports * *aOwner) { @@ -323,34 +441,12 @@ nsCachedChromeChannel::SetNotificationCallbacks(nsIInterfaceRequestor * aNotific return NS_OK; // ignored } + NS_IMETHODIMP -nsCachedChromeChannel::GetContentType(char * *aContentType) +nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - *aContentType = nsXPIDLCString::Copy("text/cached-xul"); - return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP -nsCachedChromeChannel::SetContentType(const char *aContentType) -{ - // Do not allow the content-type to be changed. - NS_NOTREACHED("don't do that"); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsCachedChromeChannel::GetContentLength(PRInt32 *aContentLength) -{ - NS_NOTREACHED("don't do that"); - *aContentLength = 0; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsCachedChromeChannel::SetContentLength(PRInt32 aContentLength) -{ - NS_NOTREACHED("nsCachedChromeChannel::SetContentLength"); - return NS_ERROR_NOT_IMPLEMENTED; + *aSecurityInfo = nsnull; + return NS_OK; } nsresult @@ -427,14 +523,12 @@ nsCachedChromeChannel::HandleStopLoadEvent(PLEvent* aEvent) // remove it from the load group. LoadEvent* event = NS_REINTERPRET_CAST(LoadEvent*, aEvent); nsCachedChromeChannel* channel = event->mChannel; - nsIRequest* request = NS_REINTERPRET_CAST(nsIRequest*, channel); - PR_LOG(gLog, PR_LOG_DEBUG, ("nsCachedChromeChannel[%p]: firing OnStopRequest for %p", channel, channel->mListener.get())); - (void) channel->mListener->OnStopRequest(request, channel->mContext, + (void) channel->mListener->OnStopRequest(channel, channel->mContext, channel->mStatus, nsnull); if (channel->mLoadGroup) { @@ -442,7 +536,7 @@ nsCachedChromeChannel::HandleStopLoadEvent(PLEvent* aEvent) ("nsCachedChromeChannel[%p]: removing self from load group %p", channel, channel->mLoadGroup.get())); - (void) channel->mLoadGroup->RemoveRequest(request, nsnull, nsnull, nsnull); + (void) channel->mLoadGroup->RemoveChannel(channel, nsnull, nsnull, nsnull); } channel->mListener = nsnull; diff --git a/mozilla/content/base/src/nsSyncLoadService.cpp b/mozilla/content/base/src/nsSyncLoadService.cpp index b117e9653c9..d60c04a4f18 100644 --- a/mozilla/content/base/src/nsSyncLoadService.cpp +++ b/mozilla/content/base/src/nsSyncLoadService.cpp @@ -298,7 +298,7 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval) } // Start reading from the channel - rv = channel->AsyncOpen(listener, nsnull); + rv = channel->AsyncRead(listener, nsnull); if (NS_FAILED(rv)) { if (modalEventQueue) { diff --git a/mozilla/content/xml/document/src/Makefile.in b/mozilla/content/xml/document/src/Makefile.in index 0dcfc5eb57f..1254cc04393 100644 --- a/mozilla/content/xml/document/src/Makefile.in +++ b/mozilla/content/xml/document/src/Makefile.in @@ -28,7 +28,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout LIBRARY_NAME = gkxmldoc_s -REQUIRES = xpcom js dom locale widget caps htmlparser necko view docshell webshell uriloader pref xpconnect uconv chardet expat lwbrk exthandler mime +REQUIRES = xpcom js dom locale widget caps htmlparser necko view docshell webshell uriloader pref xpconnect uconv chardet expat lwbrk CPPSRCS = \ nsXMLContentSink.cpp \ diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 9e3ed468c39..3babaa8bd8d 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -1669,11 +1669,7 @@ nsXMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader, if (NS_OK == aStatus) { { // scope in block so nsCOMPtr released at one point nsCOMPtr channel; - nsCOMPtr request; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) - channel = do_QueryInterface(request); - + aLoader->GetChannel(getter_AddRefs(channel)); nsCOMPtr url; if (channel) { channel->GetURI(getter_AddRefs(url)); diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 5904f9e70ba..b3533b20968 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -74,11 +74,6 @@ #include "nsIPrincipal.h" #include "nsIAggregatePrincipal.h" -#include "nsCExternalHandlerService.h" -#include "nsIMIMEService.h" -#include "nsNetUtil.h" -#include "nsMimeTypes.h" - // XXX The XML world depends on the html atoms #include "nsHTMLAtoms.h" @@ -356,7 +351,7 @@ nsXMLDocument::Load(const nsAReadableString& aUrl) } // Start an asynchronous read of the XML document - rv = channel->AsyncOpen(listener, nsnull); + rv = channel->AsyncRead(listener, nsnull); return rv; } @@ -386,10 +381,8 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, rv = aChannel->GetURI(getter_AddRefs(aUrl)); if (NS_FAILED(rv)) return rv; - nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) return rv; - rv = MIMEService->GetTypeFromURI(aUrl, &aContentType); - + rv = aChannel->GetContentType(&aContentType); + if (NS_SUCCEEDED(rv)) { if ( 0 == PL_strcmp(aContentType, "text/html")) { bIsHTML = PR_TRUE; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 6268e060d47..17c60632f23 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -127,10 +127,6 @@ #include "nsIDOMDocumentType.h" #include "nsIXBLService.h" #include "nsReadableUtils.h" -#include "nsCExternalHandlerService.h" -#include "nsIMIMEService.h" -#include "nsNetUtil.h" -#include "nsMimeTypes.h" //---------------------------------------------------------------------- @@ -317,19 +313,19 @@ NS_IMPL_ISUPPORTS1(nsProxyLoadStream, nsIInputStream); //---------------------------------------------------------------------- // -// PlaceholderRequest +// PlaceholderChannel // -// This is a dummy request implementation that we add to the load +// This is a dummy channel implementation that we add to the load // group. It ensures that EndDocumentLoad() in the docshell doesn't // fire before we've finished building the complete document content // model. // -class PlaceHolderRequest : public nsIChannel +class PlaceholderChannel : public nsIChannel { protected: - PlaceHolderRequest(); - virtual ~PlaceHolderRequest(); + PlaceholderChannel(); + virtual ~PlaceholderChannel(); static PRInt32 gRefCnt; static nsIURI* gURI; @@ -338,12 +334,13 @@ protected: public: static nsresult - Create(nsIRequest** aResult); + Create(nsIChannel** aResult); NS_DECL_ISUPPORTS // nsIRequest NS_IMETHOD GetName(PRUnichar* *result) { + NS_NOTREACHED("PlaceholderChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; } @@ -352,50 +349,63 @@ public: NS_IMETHOD Suspend(void) { return NS_OK; } NS_IMETHOD Resume(void) { return NS_OK; } - // nsIChannel + // nsIChannel NS_IMETHOD GetOriginalURI(nsIURI* *aOriginalURI) { *aOriginalURI = gURI; NS_ADDREF(*aOriginalURI); return NS_OK; } NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI) { gURI = aOriginalURI; NS_ADDREF(gURI); return NS_OK; } NS_IMETHOD GetURI(nsIURI* *aURI) { *aURI = gURI; NS_ADDREF(*aURI); return NS_OK; } NS_IMETHOD SetURI(nsIURI* aURI) { gURI = aURI; NS_ADDREF(gURI); return NS_OK; } - NS_IMETHOD Open(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } - NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } - NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes) { return NS_OK; } - NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } - NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } - NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } - NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } - NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } - NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } - NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { *aSecurityInfo = nsnull; return NS_OK; } - NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } - NS_IMETHOD SetContentType(const char * aContentType) { return NS_OK; } - NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return NS_OK; } - NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return NS_OK; } - + NS_IMETHOD OpenInputStream(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD OpenOutputStream(nsIOutputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD AsyncOpen(nsIStreamObserver *observer, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } + NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes) { return NS_OK; } + NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } + NS_IMETHOD SetContentType(const char *aContentType) { return NS_OK; } + NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { *aContentLength = 0; return NS_OK; } + NS_IMETHOD SetContentLength(PRInt32 aContentLength) { NS_NOTREACHED("SetContentLength"); NS_NOTREACHED("NOTREACHED"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferOffset(PRUint32 *aTransferOffset) { NS_NOTREACHED("GetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferOffset(PRUint32 aTransferOffset) { NS_NOTREACHED("SetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferCount(PRInt32 *aTransferCount) { NS_NOTREACHED("GetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferCount(PRInt32 aTransferCount) { NS_NOTREACHED("SetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) { NS_NOTREACHED("GetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferSegmentSize(PRUint32 aBufferSegmentSize) { NS_NOTREACHED("SetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferMaxSize(PRUint32 *aBufferMaxSize) { NS_NOTREACHED("GetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferMaxSize(PRUint32 aBufferMaxSize) { NS_NOTREACHED("SetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetLocalFile(nsIFile* *result) { NS_NOTREACHED("GetLocalFile"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetPipeliningAllowed(PRBool *aPipeliningAllowed) { *aPipeliningAllowed = PR_FALSE; return NS_OK; } + NS_IMETHOD SetPipeliningAllowed(PRBool aPipeliningAllowed) { NS_NOTREACHED("SetPipeliningAllowed"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } + NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } + NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } + NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } + NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } + NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } + NS_IMETHOD GetSecurityInfo(nsISupports **info) {*info = nsnull; return NS_OK;} }; -PRInt32 PlaceHolderRequest::gRefCnt; -nsIURI* PlaceHolderRequest::gURI; +PRInt32 PlaceholderChannel::gRefCnt; +nsIURI* PlaceholderChannel::gURI; -NS_IMPL_ADDREF(PlaceHolderRequest); -NS_IMPL_RELEASE(PlaceHolderRequest); -NS_IMPL_QUERY_INTERFACE2(PlaceHolderRequest, nsIRequest, nsIChannel); +NS_IMPL_ADDREF(PlaceholderChannel); +NS_IMPL_RELEASE(PlaceholderChannel); +NS_IMPL_QUERY_INTERFACE2(PlaceholderChannel, nsIRequest, nsIChannel); nsresult -PlaceHolderRequest::Create(nsIRequest** aResult) +PlaceholderChannel::Create(nsIChannel** aResult) { - PlaceHolderRequest* request = new PlaceHolderRequest(); - if (! request) + PlaceholderChannel* channel = new PlaceholderChannel(); + if (! channel) return NS_ERROR_OUT_OF_MEMORY; - *aResult = request; + *aResult = channel; NS_ADDREF(*aResult); return NS_OK; } -PlaceHolderRequest::PlaceHolderRequest() +PlaceholderChannel::PlaceholderChannel() { NS_INIT_REFCNT(); @@ -407,7 +417,7 @@ PlaceHolderRequest::PlaceHolderRequest() } -PlaceHolderRequest::~PlaceHolderRequest() +PlaceholderChannel::~PlaceholderChannel() { if (--gRefCnt == 0) { NS_IF_RELEASE(gURI); @@ -763,9 +773,8 @@ nsXULDocument::StartDocumentLoad(const char* aCommand, // certain hacks (cough, the directory viewer) need to be able to // StartDocumentLoad() before the channel's content type has been // detected. - nsXPIDLCString contentType; - aChannel->GetContentType(getter_Copies(contentType)); + (void) aChannel->GetContentType(getter_Copies(contentType)); if (contentType && PL_strcmp(contentType, "text/cached-xul") == 0) { // Look in the chrome cache: we've got this puppy loaded @@ -4934,16 +4943,16 @@ nsXULDocument::PrepareToWalk() // Add a dummy channel to the load group as a placeholder for the document // load - rv = PlaceHolderRequest::Create(getter_AddRefs(mPlaceHolderRequest)); + rv = PlaceholderChannel::Create(getter_AddRefs(mPlaceholderChannel)); if (NS_FAILED(rv)) return rv; nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); if (group) { - nsCOMPtr channel = do_QueryInterface(mPlaceHolderRequest); - rv = channel->SetLoadGroup(group); + rv = mPlaceholderChannel->SetLoadGroup(group); if (NS_FAILED(rv)) return rv; - rv = group->AddRequest(mPlaceHolderRequest, nsnull); + + rv = group->AddChannel(mPlaceholderChannel, nsnull); if (NS_FAILED(rv)) return rv; } } @@ -5287,10 +5296,10 @@ nsXULDocument::ResumeWalk() // docshell, and run the onload handlers, etc. nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); if (group) { - rv = group->RemoveRequest(mPlaceHolderRequest, nsnull, NS_OK, nsnull); + rv = group->RemoveChannel(mPlaceholderChannel, nsnull, NS_OK, nsnull); if (NS_FAILED(rv)) return rv; - mPlaceHolderRequest = nsnull; + mPlaceholderChannel = nsnull; } return rv; } @@ -5352,11 +5361,8 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader, { if (aLoader) { - nsCOMPtr request; nsCOMPtr channel; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) - channel = do_QueryInterface(request); + aLoader->GetChannel(getter_AddRefs(channel)); if (channel) { nsCOMPtr uri; @@ -6521,14 +6527,14 @@ nsXULDocument::CachedChromeStreamListener::~CachedChromeStreamListener() NS_IMPL_ISUPPORTS2(nsXULDocument::CachedChromeStreamListener, nsIStreamObserver, nsIStreamListener); NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIRequest *request, nsISupports* acontext) +nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIChannel* aChannel, nsISupports* acontext) { return NS_OK; } NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request, +nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -6543,7 +6549,7 @@ nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request, NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIRequest *request, +nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream* aInStr, PRUint32 aSourceOffset, @@ -6573,14 +6579,14 @@ nsXULDocument::ParserObserver::~ParserObserver() NS_IMPL_ISUPPORTS1(nsXULDocument::ParserObserver, nsIStreamObserver); NS_IMETHODIMP -nsXULDocument::ParserObserver::OnStartRequest(nsIRequest *request, +nsXULDocument::ParserObserver::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) { return NS_OK; } NS_IMETHODIMP -nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request, +nsXULDocument::ParserObserver::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -6592,10 +6598,6 @@ nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request, // walk along. #define YELL_IF_MISSING_OVERLAY 1 #if defined(DEBUG) || defined(YELL_IF_MISSING_OVERLAY) - - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; - nsCOMPtr uri; aChannel->GetOriginalURI(getter_AddRefs(uri)); diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 26642d103f4..be5d165392a 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -119,7 +119,7 @@ public: NS_IMETHOD GetContentType(nsAWritableString& aContentType) const; NS_IMETHOD StartDocumentLoad(const char* aCommand, - nsIChannel *channel, + nsIChannel* aChannel, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, @@ -642,7 +642,7 @@ protected: * A "dummy" channel that is used as a placeholder to signal document load * completion. */ - nsCOMPtr mPlaceHolderRequest; + nsCOMPtr mPlaceholderChannel; /** * Create a XUL template builder on the specified node if a 'datasources' diff --git a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp index 2e3b2bef92d..46cf82af769 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp @@ -54,9 +54,7 @@ static NS_DEFINE_IID(kILDAPMessageListenerIID, NS_ILDAPMESSAGELISTENER_IID); static NS_DEFINE_IID(kILoadGroupIID, NS_ILOADGROUP_IID); static NS_DEFINE_IID(kIProgressEventSink, NS_IPROGRESSEVENTSINK_IID); -NS_IMPL_THREADSAFE_ISUPPORTS3(nsLDAPChannel, - nsIChannel, - nsIRequest, +NS_IMPL_THREADSAFE_ISUPPORTS3(nsLDAPChannel, nsIChannel, nsIRequest, nsILDAPMessageListener); nsLDAPChannel::nsLDAPChannel() @@ -214,7 +212,7 @@ nsLDAPChannel::Cancel(nsresult aStatus) // remove self from loadgroup to stop the throbber // if (mLoadGroup) { - rv = mLoadGroup->RemoveRequest(this, mResponseContext, aStatus, + rv = mLoadGroup->RemoveChannel(this, mResponseContext, aStatus, nsnull); if (NS_FAILED(rv)) return rv; @@ -285,6 +283,55 @@ nsLDAPChannel::GetURI(nsIURI* *aURI) return NS_OK; } +// getter and setter for transferOffset attribute: +// +// The start offset from the beginning of the data from/to which +// reads/writes will occur. Users may set the transferOffset before making +// any of the following requests: asyncOpen, asyncRead, asyncWrite, +// openInputStream, openOutputstream. +// +NS_IMETHODIMP +nsLDAPChannel::SetTransferOffset(PRUint32 newOffset) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsLDAPChannel::GetTransferOffset(PRUint32 *offset) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +// getter and setter for transferCount attribute +// +// Accesses the count of bytes to be transfered. For openInputStream and +// asyncRead, this specifies the amount to read, for asyncWrite, this +// specifies the amount to write (note that for openOutputStream, the +// end of the data can be signified simply by closing the stream). +// If the transferCount is set after reading has been initiated, the +// amount specified will become the current remaining amount to read +// before the channel is closed (this can be useful if the content +// length is encoded at the start of the stream). +// +// A transferCount value of -1 means the amount is unspecified, i.e. +// read or write all the data that is available. +// +NS_IMETHODIMP +nsLDAPChannel::SetTransferCount(PRInt32 newCount) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsLDAPChannel::GetTransferCount(PRInt32 *count) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + // getter and setter for loadAttributes attribute: // // The load attributes for the channel. E.g. setting the load @@ -516,6 +563,86 @@ nsLDAPChannel::GetSecurityInfo(nsISupports* *aSecurityInfo) return NS_ERROR_NOT_IMPLEMENTED; } +// getter and setter for bufferSegmentSize attribute +// +// The buffer segment size is used as the initial size for any +// transfer buffers, and the increment size for whenever the buffer +// space needs to be grown. (Note this parameter is passed along to +// any underlying nsIPipe objects.) If unspecified, the channel +// implementation picks a default. +// +// attribute unsigned long bufferSegmentSize; +// +NS_IMETHODIMP +nsLDAPChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsLDAPChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +// getter and setter for the bufferMaxSize attribute +// +// Accesses the buffer maximum size. The buffer maximum size is the limit +// size that buffer will be grown to before suspending the channel. +// (Note this parameter is passed along to any underlying nsIPipe objects.) +// If unspecified, the channel implementation picks a default. +// +// attribute unsigned long bufferMaxSize; +// +NS_IMETHODIMP +nsLDAPChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsLDAPChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +// Returns a local file to the channel's data if one exists, null otherwise. +// +// readonly attribute nsIFile localFile; +NS_IMETHODIMP +nsLDAPChannel::GetLocalFile(nsIFile* *aFile) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +// getter and setter for pipeliningAllowed attribute +// +// Setting pipeliningAllowed causes the load of a URL (issued via asyncOpen, +// asyncRead or asyncWrite) to be deferred in order to allow the request to +// be pipelined for greater throughput efficiency. Pipelined requests will +// be forced to load when the first non-pipelined request is issued. +// +// attribute boolean pipeliningAllowed; +// +NS_IMETHODIMP +nsLDAPChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::GetPipeLiningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsLDAPChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + // nsIChannel operations // Opens a blocking input stream to the URL's specified source. @@ -526,14 +653,35 @@ nsLDAPChannel::GetSecurityInfo(nsISupports* *aSecurityInfo) // the data, the amount available is returned in the stream. // NS_IMETHODIMP -nsLDAPChannel::Open(nsIInputStream* *result) +nsLDAPChannel::OpenInputStream(nsIInputStream* *result) { NS_NOTYETIMPLEMENTED("nsLDAPChannel::OpenInputStream"); return NS_ERROR_NOT_IMPLEMENTED; } +// Opens a blocking output stream to the URL's specified destination. +// @param startPosition - The offset from the start of the data +// from which to begin writing. +// NS_IMETHODIMP -nsLDAPChannel::AsyncOpen(nsIStreamListener* aListener, +nsLDAPChannel::OpenOutputStream(nsIOutputStream* *result) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +// Reads asynchronously from the URL's specified source. Notifications +// are provided to the stream listener on the thread of the specified +// event queue. +// The startPosition argument designates the offset in the source where +// the data will be read. +// If the readCount == -1 then all the available data is delivered to +// the stream listener. +// +// void asyncRead(in nsIStreamListener listener, +// in nsISupports ctxt); +NS_IMETHODIMP +nsLDAPChannel::AsyncRead(nsIStreamListener* aListener, nsISupports* aCtxt) { nsresult rv; @@ -548,7 +696,7 @@ nsLDAPChannel::AsyncOpen(nsIStreamListener* aListener, // add ourselves to the appropriate loadgroup // if (mLoadGroup) { - mLoadGroup->AddRequest(this, mResponseContext); + mLoadGroup->AddChannel(this, mResponseContext); } // slurp out relevant pieces of the URL @@ -664,6 +812,24 @@ nsLDAPChannel::AsyncOpen(nsIStreamListener* aListener, return NS_OK; } +// Writes asynchronously to the URL's specified destination. Notifications +// are provided to the stream observer on the thread of the specified +// event queue. +// The startPosition argument designates the offset in the destination where +// the data will be written. +// If the writeCount == -1, then all the available data in the input +// stream is written. +// +// void asyncWrite(in nsIStreamProvider provider, +// in nsISupports ctxt); +NS_IMETHODIMP +nsLDAPChannel::AsyncWrite(nsIStreamProvider* provider, + nsISupports* ctxt) +{ + NS_NOTYETIMPLEMENTED("nsLDAPChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + /** * Messages received are passed back via this function. * @@ -838,7 +1004,7 @@ nsLDAPChannel::OnLDAPSearchResult(nsILDAPMessage *aMessage) // remove self from loadgroup to stop the throbber // if (mLoadGroup) { - rv = mLoadGroup->RemoveRequest(this, mResponseContext, NS_OK, nsnull); + rv = mLoadGroup->RemoveChannel(this, mResponseContext, NS_OK, nsnull); if (NS_FAILED(rv)) { NS_WARNING("nsLDAPChannel::OnSearchResult(): " "mLoadGroup->RemoveChannel() failed"); diff --git a/mozilla/docshell/base/nsDSURIContentListener.cpp b/mozilla/docshell/base/nsDSURIContentListener.cpp index af965962ef1..d58838aea4b 100644 --- a/mozilla/docshell/base/nsDSURIContentListener.cpp +++ b/mozilla/docshell/base/nsDSURIContentListener.cpp @@ -80,7 +80,7 @@ NS_IMETHODIMP nsDSURIContentListener::GetProtocolHandler(nsIURI* aURI, NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, nsURILoadCommand aCommand, const char* aWindowTarget, - nsIRequest* request, nsIStreamListener** aContentHandler, + nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler, PRBool* aAbortProcess) { NS_ENSURE_ARG_POINTER(aContentHandler); @@ -89,8 +89,6 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, // determine if the channel has just been retargeted to us... nsLoadFlags loadAttribs = 0; - nsCOMPtr aOpenedChannel = do_QueryInterface(request); - aOpenedChannel->GetLoadAttributes(&loadAttribs); PRUint32 loadType = mDocShell->ConvertDocShellLoadInfoToLoadType((nsDocShellInfoLoadType) aCommand); @@ -102,7 +100,7 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, } nsresult rv = mDocShell->CreateContentViewer(aContentType, - request, aContentHandler); + aOpenedChannel, aContentHandler); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; // it's okay if we don't know how to handle the content if(loadAttribs & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 8d187b53ffd..37c2ee75d2b 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2751,7 +2751,7 @@ NS_IMETHODIMP nsDocShell::CreateAboutBlankContentViewer() } NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, - nsIRequest *request, nsIStreamListener** aContentHandler) + nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler) { // Can we check the content type of the current content viewer // and reuse it without destroying it and re-creating it? @@ -2761,17 +2761,12 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, // Instantiate the content viewer object nsCOMPtr viewer; - nsresult rv = NewContentViewerObj(aContentType, request, loadGroup, - aContentHandler, getter_AddRefs(viewer)); - - if(NS_FAILED(rv)) + if(NS_FAILED(NewContentViewerObj(aContentType, aOpenedChannel, loadGroup, + aContentHandler, getter_AddRefs(viewer)))) return NS_ERROR_FAILURE; // we've created a new document so go ahead and call OnLoadingSite mURIResultedInDocument = PR_TRUE; - - nsCOMPtr aOpenedChannel = do_QueryInterface(request); - OnLoadingSite(aOpenedChannel); // let's try resetting the load group if we need to... @@ -2802,9 +2797,9 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, aOpenedChannel->SetLoadAttributes(loadAttribs); - loadGroup->AddRequest(request, nsnull); + loadGroup->AddChannel(aOpenedChannel, nsnull); if(currentLoadGroup) - currentLoadGroup->RemoveRequest(request, nsnull, nsnull, nsnull); + currentLoadGroup->RemoveChannel(aOpenedChannel, nsnull, nsnull, nsnull); } #ifdef SH_IN_FRAMES @@ -2818,7 +2813,7 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, } nsresult nsDocShell::NewContentViewerObj(const char* aContentType, - nsIRequest *request, nsILoadGroup* aLoadGroup, + nsIChannel* aOpenedChannel, nsILoadGroup* aLoadGroup, nsIStreamListener** aContentHandler, nsIContentViewer** aViewer) { //XXX This should probably be some category thing.... @@ -2845,8 +2840,6 @@ nsresult nsDocShell::NewContentViewerObj(const char* aContentType, if(!docLoaderFactory) return NS_ERROR_FAILURE; } - - nsCOMPtr aOpenedChannel = do_QueryInterface(request); // Now create an instance of the content viewer NS_ENSURE_SUCCESS(docLoaderFactory->CreateInstance( diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 6ca51af1e2c..1fcee615fda 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -191,9 +191,9 @@ protected: NS_IMETHOD EnsureDeviceContext(); NS_IMETHOD CreateAboutBlankContentViewer(); NS_IMETHOD CreateContentViewer(const char* aContentType, - nsIRequest *request, nsIStreamListener** aContentHandler); + nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler); NS_IMETHOD NewContentViewerObj(const char* aContentType, - nsIRequest *request, nsILoadGroup* aLoadGroup, + nsIChannel* aOpenedChannel, nsILoadGroup* aLoadGroup, nsIStreamListener** aContentHandler, nsIContentViewer** aViewer); NS_IMETHOD SetupNewViewer(nsIContentViewer* aNewViewer); diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index e1ad70b4d50..86bd29b344c 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -891,10 +891,10 @@ nsWebShell::GetLinkState(const char* aLinkURI, nsLinkState& aState) // are cleaned up. // NS_IMETHODIMP -nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *request, +nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt32 aStateFlags, nsresult aStatus) { - if (!request) { + if (!aRequest) { return NS_OK; } @@ -903,8 +903,7 @@ nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *request, if (aProgress == webProgress.get()) { nsCOMPtr url; - - nsCOMPtr channel = do_QueryInterface(request); + nsCOMPtr channel(do_QueryInterface(aRequest)); nsCOMPtr dlObserver; (void) channel->GetURI(getter_AddRefs(url)); @@ -937,21 +936,21 @@ nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *request, * Fire the OnEndDocumentLoad of the DocLoaderobserver */ if(dlObserver && url) { - dlObserver->OnEndDocumentLoad(mDocLoader, request, aStatus); + dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus); } } } } if (aStateFlags & STATE_IS_REQUEST) { - nsCOMPtr channel = do_QueryInterface(request); - + nsCOMPtr channel(do_QueryInterface(aRequest)); + if (aStateFlags & STATE_START) { /* *Fire the OnStartDocumentLoad of the webshell observer */ if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) { - mDocLoaderObserver->OnStartURLLoad(mDocLoader, request); + mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel); } } else if (aStateFlags & STATE_STOP) { @@ -959,26 +958,27 @@ nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *request, *Fire the OnEndDocumentLoad of the webshell observer */ if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) { - mDocLoaderObserver->OnEndURLLoad(mDocLoader, request, aStatus); + mDocLoaderObserver->OnEndURLLoad(mDocLoader, channel, aStatus); } } } - return nsDocShell::OnStateChange(aProgress, request, aStateFlags, aStatus); + return nsDocShell::OnStateChange(aProgress, aRequest, aStateFlags, aStatus); } //---------------------------------------------------------------------- nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, - nsIChannel* channel, + nsIChannel *aChannel, nsresult aStatus) { nsresult rv = NS_OK; - if(!channel) + if(!aChannel) return NS_ERROR_NULL_POINTER; - + nsCOMPtr url; - rv = channel->GetURI(getter_AddRefs(url)); + + rv = aChannel->GetURI(getter_AddRefs(url)); if (NS_FAILED(rv)) return rv; // clean up reload state for meta charset @@ -993,7 +993,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, // during this load handler. // nsCOMPtr kungFuDeathGrip(this); - nsDocShell::EndPageLoad(aProgress, channel, aStatus); + nsDocShell::EndPageLoad(aProgress, aChannel, aStatus); // // If the page load failed, then deal with the error condition... diff --git a/mozilla/docshell/base/nsWebShell.h b/mozilla/docshell/base/nsWebShell.h index 707b016846f..20998508efb 100644 --- a/mozilla/docshell/base/nsWebShell.h +++ b/mozilla/docshell/base/nsWebShell.h @@ -138,7 +138,7 @@ protected: // sub-documents - ie. frames) has been completely loaded. // virtual nsresult EndPageLoad(nsIWebProgress *aProgress, - nsIChannel* channel, + nsIChannel *aChannel, nsresult aStatus); nsIEventQueue* mThreadEventQueue; @@ -156,7 +156,7 @@ protected: nsresult FireUnloadForChildren(); - nsresult CreateViewer(nsIRequest* request, + nsresult CreateViewer(nsIChannel* aChannel, const char* aContentType, const char* aCommand, nsIStreamListener** aResult); diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 5bd402056fb..29596bf8f24 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -4904,7 +4904,7 @@ NS_IMETHODIMP nsEditorShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler } /* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */ -NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) +NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { NS_ENSURE_ARG_POINTER(aContentHandler); NS_ENSURE_ARG_POINTER(aAbortProcess); diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 5bd402056fb..29596bf8f24 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -4904,7 +4904,7 @@ NS_IMETHODIMP nsEditorShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler } /* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */ -NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) +NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { NS_ENSURE_ARG_POINTER(aContentHandler); NS_ENSURE_ARG_POINTER(aAbortProcess); diff --git a/mozilla/embedding/browser/Makefile.in b/mozilla/embedding/browser/Makefile.in index c0f618763b5..94f2fc814c9 100644 --- a/mozilla/embedding/browser/Makefile.in +++ b/mozilla/embedding/browser/Makefile.in @@ -35,5 +35,4 @@ ifdef MOZ_ENABLE_PHOTON DIRS += photon endif - include $(topsrcdir)/config/rules.mk diff --git a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp index caf32dccf82..d0159701dc5 100644 --- a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -388,8 +388,8 @@ NS_IMETHODIMP CWebBrowserContainer::GetProtocolHandler(nsIURI *aURI, nsIProtocol } -/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */ -NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) +/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */ +NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -714,7 +714,7 @@ CWebBrowserContainer::GetPersistence(PRBool* aPersistX, PRBool* aPersistY, NS_IMETHODIMP -CWebBrowserContainer::OnStartRequest(nsIRequest *request, nsISupports* aContext) +CWebBrowserContainer::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) { USES_CONVERSION; NG_TRACE(_T("CWebBrowserContainer::OnStartRequest(...)\n")); @@ -724,7 +724,7 @@ CWebBrowserContainer::OnStartRequest(nsIRequest *request, nsISupports* aContext) NS_IMETHODIMP -CWebBrowserContainer::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) +CWebBrowserContainer::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) { USES_CONVERSION; NG_TRACE(_T("CWebBrowserContainer::OnStopRequest(..., %d, \"%s\")\n"), (int) aStatus, W2T((PRUnichar *) aMsg)); @@ -758,7 +758,7 @@ CWebBrowserContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* pUR // we need this to fire the document complete NS_IMETHODIMP -CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) +CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *aChannel, nsresult aStatus) { NG_TRACE(_T("CWebBrowserContainer::OnEndDocumentLoad(..., \"\")\n")); @@ -776,9 +776,6 @@ CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *r char* aString = nsnull; nsIURI* pURI = nsnull; - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_NULL_POINTER; - aChannel->GetURI(&pURI); if (pURI == nsnull) { @@ -807,7 +804,7 @@ CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *r NS_IMETHODIMP -CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) +CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel) { NG_TRACE(_T("CWebBrowserContainer::OnStartURLLoad(..., \"\")\n")); @@ -818,7 +815,7 @@ CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *requ NS_IMETHODIMP -CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) +CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, PRUint32 aProgress, PRUint32 aProgressMax) { USES_CONVERSION; NG_TRACE(_T("CWebBrowserContainer::OnProgress(..., \"%d\", \"%d\")\n"), (int) aProgress, (int) aProgressMax); @@ -828,7 +825,7 @@ CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIRequest *r NS_IMETHODIMP -CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) +CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, nsString& aMsg) { NG_TRACE(_T("CWebBrowserContainer::OnStatusURLLoad(..., \"\")\n")); @@ -843,7 +840,7 @@ CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIRequest *req NS_IMETHODIMP -CWebBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) +CWebBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) { NG_TRACE(_T("CWebBrowserContainer::OnEndURLLoad(..., \"\")\n")); diff --git a/mozilla/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp b/mozilla/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp index 1f39b40cf36..10700b14ce4 100644 --- a/mozilla/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp +++ b/mozilla/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp @@ -264,8 +264,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::OpenStream (const char *aBaseURI, const char *a return rv; // start our request - nsCOMPtr request = do_QueryInterface(mChannel); - rv = mStreamListener->OnStartRequest(request, NULL); + rv = mStreamListener->OnStartRequest(mChannel, NULL); if (NS_FAILED(rv)) return rv; @@ -282,8 +281,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::AppendToStream (const char *aData, gint32 aLen) rv = embedStream->Append(aData, aLen); if (NS_FAILED(rv)) return rv; - nsCOMPtr request = do_QueryInterface(mChannel); - rv = mStreamListener->OnDataAvailable(request, + rv = mStreamListener->OnDataAvailable(mChannel, NULL, mStream, mOffset, /* offset */ @@ -299,8 +297,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::CloseStream (void) nsresult rv; NS_ENSURE_STATE(mDoingStream); mDoingStream = PR_FALSE; - nsCOMPtr request = do_QueryInterface(mChannel); - rv = mStreamListener->OnStopRequest(request, + rv = mStreamListener->OnStopRequest(mChannel, NULL, NS_OK, NULL); @@ -534,7 +531,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::GetProtocolHandler(nsIURI *aURI, nsIProtocolHan } NS_IMETHODIMP GtkMozEmbedChrome::DoContent(const char *aContentType, nsURILoadCommand aCommand, - const char *aWindowTarget, nsIRequest *request, + const char *aWindowTarget, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::DoContent\n")); diff --git a/mozilla/embedding/browser/webBrowser/nsWBURIContentListener.cpp b/mozilla/embedding/browser/webBrowser/nsWBURIContentListener.cpp index 72cf6bce23c..091b92acf63 100644 --- a/mozilla/embedding/browser/webBrowser/nsWBURIContentListener.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWBURIContentListener.cpp @@ -93,7 +93,7 @@ NS_IMETHODIMP nsWBURIContentListener::GetProtocolHandler(nsIURI* aURI, NS_IMETHODIMP nsWBURIContentListener::DoContent(const char* aContentType, nsURILoadCommand aCommand, const char* aWindowTarget, - nsIRequest* request, nsIStreamListener** aContentHandler, + nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler, PRBool* aAbortProcess) { NS_ERROR("Hmmmm, why is this getting called on this object?"); diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp index e0e04f6fee0..0e1953382dd 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp @@ -86,7 +86,7 @@ void nsWebBrowserPersist::CleanUp() mOutputStream->Close(); mOutputStream = nsnull; } - mOutputTransport = nsnull; + mOutputChannel = nsnull; } NS_IMPL_ADDREF(nsWebBrowserPersist) @@ -162,6 +162,10 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa } } + // Query the content type + nsXPIDLCString contentType; + inputChannel->GetContentType(getter_Copies(contentType)); + NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); @@ -184,7 +188,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa } // Open a channel on the local file - nsCOMPtr outputChannel; + nsCOMPtr outputChannel; rv = fts->CreateTransport(file, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0664, getter_AddRefs(outputChannel)); if (NS_FAILED(rv)) @@ -193,12 +197,10 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa return NS_ERROR_FAILURE; } - mOutputTransport = outputChannel; + mOutputChannel = outputChannel; -//dougt wtf?! why both a async and sync read? - // Read from the input channel - rv = inputChannel->AsyncOpen(this, nsnull); + rv = inputChannel->AsyncRead(this, nsnull); if (NS_FAILED(rv)) { OnEndDownload(); @@ -206,7 +208,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa } nsCOMPtr inStream; - rv = inputChannel->Open(getter_AddRefs(inStream)); + rv = inputChannel->OpenInputStream(getter_AddRefs(inStream)); if (NS_FAILED(rv)) { OnEndDownload(); @@ -217,10 +219,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa mInputStream = inStream; // Get the output channel ready for writing - nsCOMPtr writeRequest; - rv = NS_AsyncWriteFromStream(getter_AddRefs(writeRequest), - outputChannel, inStream, 0, 0, 0, - NS_STATIC_CAST(nsIStreamObserver*, this), nsnull); + rv = NS_AsyncWriteFromStream(outputChannel, inStream, NS_STATIC_CAST(nsIStreamObserver *, this), nsnull); if (NS_FAILED(rv)) { OnEndDownload(); @@ -395,13 +394,15 @@ NS_IMETHODIMP nsWebBrowserPersist::OnProgress(PRUint32 aStatus, nsIURI *aURI, PR //***************************************************************************** -NS_IMETHODIMP nsWebBrowserPersist::OnStartRequest(nsIRequest* request, nsISupports *ctxt) +/* void onStartRequest (in nsIChannel channel, in nsISupports ctxt); */ +NS_IMETHODIMP nsWebBrowserPersist::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { - nsresult rv = mOutputTransport->OpenOutputStream(0, -1, 0, getter_AddRefs(mOutputStream)); + nsresult rv = mOutputChannel->OpenOutputStream(getter_AddRefs(mOutputStream)); return rv; } -NS_IMETHODIMP nsWebBrowserPersist::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult status, const PRUnichar *statusArg) +/* void onStopRequest (in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); */ +NS_IMETHODIMP nsWebBrowserPersist::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *statusArg) { OnEndDownload(); CleanUp(); @@ -414,7 +415,7 @@ NS_IMETHODIMP nsWebBrowserPersist::OnStopRequest(nsIRequest* request, nsISupport //***************************************************************************** -NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(nsIRequest* request, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 aOffset, PRUint32 aLength) +NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 aOffset, PRUint32 aLength) { nsresult rv = NS_OK; unsigned long bytesRemaining = aLength; @@ -452,9 +453,9 @@ NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(nsIRequest* request, nsISuppo // Cancel reading? if (cancel) { - if (request) + if (aChannel) { - request->Cancel(NS_BINDING_ABORTED); + aChannel->Cancel(NS_BINDING_ABORTED); } CleanUp(); OnEndDownload(); @@ -543,6 +544,8 @@ nsWebBrowserPersist::CleanupURIMap(nsHashKey *aKey, void *aData, void* closure) nsresult nsWebBrowserPersist::OnWalkDOMNode(nsIDOMNode *aNode, PRBool *aAbort) { + nsresult rv = NS_OK; + // Test the node to see if it's an image, frame, iframe, css, js nsCOMPtr nodeAsImage = do_QueryInterface(aNode); if (nodeAsImage) @@ -610,6 +613,8 @@ nsWebBrowserPersist::OnWalkDOMNode(nsIDOMNode *aNode, PRBool *aAbort) nsresult nsWebBrowserPersist::CloneNodeWithFixedUpURIAttributes(nsIDOMNode *aNodeIn, nsIDOMNode **aNodeOut) { + nsresult rv = NS_OK; + *aNodeOut = nsnull; // Test the node to see if it's an image, frame, iframe, css, js @@ -887,36 +892,30 @@ nsWebBrowserPersist::MakeAndStoreLocalFilenameInURIMap(const char *aURI, nsStrin // Create a unique file name for the uri MakeFilenameFromURI(uri, inputChannel, filename); - if (!mMIMEService) - { - mMIMEService = do_GetService(NS_MIMESERVICE_CONTRACTID); - if (!mMIMEService) - return NS_ERROR_FAILURE; - } - - // Strap on the file extension using the mime lookup service - + // Query the content type nsXPIDLCString contentType; - rv = mMIMEService->GetTypeFromURI(uri, getter_Copies(contentType)); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr mimeInfo; - mMIMEService->GetFromMIMEType(contentType, getter_AddRefs(mimeInfo)); - if (mimeInfo) + inputChannel->GetContentType(getter_Copies(contentType)); + + // Strap on the file extension using the mime lookup service + if (mMIMEService) { - // Append the mime file extension - nsXPIDLCString fileExtension; - if (NS_SUCCEEDED(mimeInfo->FirstExtension(getter_Copies(fileExtension)))) + nsCOMPtr mimeInfo; + mMIMEService->GetFromMIMEType(contentType, getter_AddRefs(mimeInfo)); + if (mimeInfo) { - nsString newExt; - newExt.AssignWithConversion("."); - newExt.AppendWithConversion(fileExtension); - // TODO no need to append if an extension for the mime type is already there - filename.Append(newExt); + // Append the mime file extension + nsXPIDLCString fileExtension; + if (NS_SUCCEEDED(mimeInfo->FirstExtension(getter_Copies(fileExtension)))) + { + nsString newExt; + newExt.AssignWithConversion("."); + newExt.AppendWithConversion(fileExtension); + // TODO no need to append if an extension for the mime type is already there + filename.Append(newExt); + } } } - + // Store the file name URIData *data = new URIData; if (!data) diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.h b/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.h index 2a20abf5a78..20584876067 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.h +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.h @@ -32,7 +32,7 @@ #include "nsIChannel.h" #include "nsIStyleSheet.h" #include "nsIDocumentEncoder.h" -#include "nsITransport.h" + #include "nsHashtable.h" #include "nsIWebBrowserPersist.h" @@ -95,7 +95,7 @@ private: nsCOMPtr mMIMEService; nsCOMPtr mInputChannel; nsCOMPtr mInputStream; - nsCOMPtr mOutputTransport; + nsCOMPtr mOutputChannel; nsCOMPtr mOutputStream; nsCOMPtr mBaseURI; nsCOMPtr mURI; diff --git a/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp b/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp index abeaaf2c62c..64ca57e3a06 100644 --- a/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp +++ b/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp @@ -162,10 +162,8 @@ nsCookieHTTPNotify::ModifyRequest(nsISupports *aContext) nsCOMPtr pChannel; if (pLoadGroup) { - nsCOMPtr pRequest; - rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest)); - if (pRequest) - pChannel = do_QueryInterface(pRequest); + rv = pLoadGroup->GetDefaultLoadChannel(getter_AddRefs(pChannel)); + if (NS_FAILED(rv)) return rv; } nsCOMPtr pFirstURL; @@ -224,10 +222,8 @@ nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext) if (NS_FAILED(rv)) return rv; nsCOMPtr pChannel; if (pLoadGroup) { - nsCOMPtr pRequest; - rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest)); + rv = pLoadGroup->GetDefaultLoadChannel(getter_AddRefs(pChannel)); if (NS_FAILED(rv)) return rv; - pChannel = do_QueryInterface(pRequest); } nsCOMPtr pFirstURL; if (pChannel) { diff --git a/mozilla/extensions/datetime/nsDateTimeChannel.cpp b/mozilla/extensions/datetime/nsDateTimeChannel.cpp index e92e99dc207..082a0a6cc27 100644 --- a/mozilla/extensions/datetime/nsDateTimeChannel.cpp +++ b/mozilla/extensions/datetime/nsDateTimeChannel.cpp @@ -28,8 +28,6 @@ #include "nsIInterfaceRequestor.h" #include "nsXPIDLString.h" #include "nsISocketTransportService.h" -#include "nsITransport.h" -#include "nsIProgressEventSink.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -43,11 +41,7 @@ nsDateTimeChannel::nsDateTimeChannel() { nsDateTimeChannel::~nsDateTimeChannel() { } -NS_IMPL_ISUPPORTS4(nsDateTimeChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamObserver) +NS_IMPL_ISUPPORTS4(nsDateTimeChannel, nsIChannel, nsIRequest, nsIStreamListener, nsIStreamObserver) nsresult nsDateTimeChannel::Init(nsIURI* uri) @@ -162,48 +156,57 @@ nsDateTimeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsDateTimeChannel::Open(nsIInputStream **_retval) +nsDateTimeChannel::OpenInputStream(nsIInputStream **_retval) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - transport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; - return transport->OpenInputStream(0, -1, 0, _retval); + return channel->OpenInputStream(_retval); } NS_IMETHODIMP -nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) +nsDateTimeChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("nsDateTimeChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener, + nsISupports *ctxt) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(transport)); + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - transport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; mListener = aListener; - - nsCOMPtr request; - return transport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(request)); + + return channel->AsyncRead(this, ctxt); +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + NS_NOTREACHED("nsDateTimeChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -253,6 +256,83 @@ nsDateTimeChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsDateTimeChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsDateTimeChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsDateTimeChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsDateTimeChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsDateTimeChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsDateTimeChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsDateTimeChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsDateTimeChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsDateTimeChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsDateTimeChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -265,11 +345,11 @@ NS_IMETHODIMP nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) { if (mLoadGroup) // if we already had a load group remove ourselves... - (void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); + (void)mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); mLoadGroup = aLoadGroup; if (mLoadGroup) { - return mLoadGroup->AddRequest(this, nsnull); + return mLoadGroup->AddChannel(this, nsnull); } return NS_OK; } @@ -304,26 +384,25 @@ nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification return NS_OK; } -NS_IMETHODIMP -nsDateTimeChannel::GetSecurityInfo(nsISupports **sec) +NS_IMETHODIMP +nsDateTimeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - NS_ENSURE_ARG_POINTER(sec); - *sec = nsnull; + *aSecurityInfo = nsnull; return NS_OK; } // nsIStreamObserver methods NS_IMETHODIMP -nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { +nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { return mListener->OnStartRequest(this, aContext); } NS_IMETHODIMP -nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, +nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { if (mLoadGroup) { - nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); + nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } return mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); @@ -332,7 +411,7 @@ nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext, +nsDateTimeChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { mContentLength = aLength; diff --git a/mozilla/extensions/datetime/nsDateTimeChannel.h b/mozilla/extensions/datetime/nsDateTimeChannel.h index 278f9c7a198..e80a83681c8 100644 --- a/mozilla/extensions/datetime/nsDateTimeChannel.h +++ b/mozilla/extensions/datetime/nsDateTimeChannel.h @@ -39,10 +39,7 @@ #include "nsIStreamListener.h" -class nsDateTimeChannel -: public nsIChannel, - public nsIStreamListener { - +class nsDateTimeChannel : public nsIChannel, public nsIStreamListener { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -70,6 +67,8 @@ protected: nsCString mContentType; PRInt32 mContentLength; nsCOMPtr mOwner; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; PRInt32 mPort; nsXPIDLCString mHost; diff --git a/mozilla/extensions/finger/nsFingerChannel.cpp b/mozilla/extensions/finger/nsFingerChannel.cpp index c43dadd3a62..f85e08414cf 100644 --- a/mozilla/extensions/finger/nsFingerChannel.cpp +++ b/mozilla/extensions/finger/nsFingerChannel.cpp @@ -32,7 +32,6 @@ #include "nsMimeTypes.h" #include "nsIStreamConverterService.h" #include "nsITXTToHTMLConv.h" -#include "nsIProgressEventSink.h" #include "nsNetUtil.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -54,11 +53,8 @@ nsFingerChannel::nsFingerChannel() nsFingerChannel::~nsFingerChannel() { } -NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamObserver) +NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel, nsIChannel, nsIRequest, + nsIStreamListener, nsIStreamObserver) nsresult nsFingerChannel::Init(nsIURI* uri) @@ -148,8 +144,8 @@ nsFingerChannel::Cancel(nsresult status) nsresult rv = NS_ERROR_FAILURE; mStatus = status; - if (mTransportRequest) { - rv = mTransportRequest->Cancel(status); + if (mTransport) { + rv = mTransport->Cancel(status); } return rv; } @@ -202,48 +198,60 @@ nsFingerChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsFingerChannel::Open(nsIInputStream **_retval) +nsFingerChannel::OpenInputStream(nsIInputStream **_retval) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; + nsCOMPtr channel; rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, - BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); + BUFFER_MAX_SIZE, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - mTransport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; - return mTransport->OpenInputStream(0, -1, 0, _retval); + return channel->OpenInputStream(_retval); } NS_IMETHODIMP -nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) +nsFingerChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("nsFingerChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; + nsCOMPtr channel; rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, - BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); + BUFFER_MAX_SIZE, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - mTransport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; mListener = aListener; mResponseContext = ctxt; + mTransport = channel; - return SendRequest(mTransport); + return SendRequest(channel); +} + +NS_IMETHODIMP +nsFingerChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + NS_NOTREACHED("nsFingerChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -293,6 +301,83 @@ nsFingerChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsFingerChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsFingerChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsFingerChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsFingerChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsFingerChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsFingerChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsFingerChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsFingerChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsFingerChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsFingerChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsFingerChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsFingerChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -347,7 +432,7 @@ nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) // nsIStreamObserver methods NS_IMETHODIMP -nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { +nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { if (!mActAsObserver) { // acting as a listener return mListener->OnStartRequest(this, mResponseContext); @@ -360,14 +445,14 @@ nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { NS_IMETHODIMP -nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, +nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (NS_FAILED(aStatus) || !mActAsObserver) { if (mLoadGroup) { - rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); + rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } rv = mListener->OnStopRequest(this, mResponseContext, aStatus, aStatusArg); @@ -402,8 +487,7 @@ nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, converter->PreFormatHTML(PR_TRUE); } - return mTransport->AsyncRead(converterListener, mResponseContext, 0,-1, 0, - getter_AddRefs(mTransportRequest)); + return aChannel->AsyncRead(converterListener, mResponseContext); } } @@ -411,7 +495,7 @@ nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext, +nsFingerChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { mContentLength = aLength; @@ -419,7 +503,7 @@ nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext, } nsresult -nsFingerChannel::SendRequest(nsITransport* aTransport) { +nsFingerChannel::SendRequest(nsIChannel* aChannel) { // The text to send should already be in mUser nsresult rv = NS_OK; @@ -428,7 +512,7 @@ nsFingerChannel::SendRequest(nsITransport* aTransport) { nsCString requestBuffer(mUser); if (mLoadGroup) { - mLoadGroup->AddRequest(this, nsnull); + mLoadGroup->AddChannel(this, nsnull); } requestBuffer.Append(CRLF); @@ -441,10 +525,9 @@ nsFingerChannel::SendRequest(nsITransport* aTransport) { charstream = do_QueryInterface(result, &rv); if (NS_FAILED(rv)) return rv; - rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest), - aTransport, charstream, - 0, requestBuffer.Length(), 0, - this, nsnull); + rv = aChannel->SetTransferCount(requestBuffer.Length()); + if (NS_FAILED(rv)) return rv; + rv = NS_AsyncWriteFromStream(aChannel, charstream, this, nsnull); return rv; } diff --git a/mozilla/extensions/finger/nsFingerChannel.h b/mozilla/extensions/finger/nsFingerChannel.h index e77455dc689..dc24c0e6d24 100644 --- a/mozilla/extensions/finger/nsFingerChannel.h +++ b/mozilla/extensions/finger/nsFingerChannel.h @@ -33,12 +33,9 @@ #include "nsIURI.h" #include "nsFingerHandler.h" #include "nsIStreamListener.h" -#include "nsITransport.h" -class nsFingerChannel -: public nsIChannel, - public nsIStreamListener { +class nsFingerChannel : public nsIChannel, public nsIStreamListener { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -77,12 +74,11 @@ protected: nsXPIDLCString mRequest; nsCOMPtr mResponseContext; - nsCOMPtr mTransport; - nsCOMPtr mTransportRequest; + nsCOMPtr mTransport; nsresult mStatus; protected: - nsresult SendRequest(nsITransport* aTransport); + nsresult SendRequest(nsIChannel* aChannel); }; #endif /* nsFingerChannel_h___ */ diff --git a/mozilla/extensions/irc/js/lib/chatzilla-service.js b/mozilla/extensions/irc/js/lib/chatzilla-service.js index 6b5e09c3a17..e1ebdf96c22 100644 --- a/mozilla/extensions/irc/js/lib/chatzilla-service.js +++ b/mozilla/extensions/irc/js/lib/chatzilla-service.js @@ -107,14 +107,13 @@ function (iid) { } IRCContentHandler.prototype.handleContent = -function (aContentType, aCommand, aWindowTarget, aSourceContext, aRequest) +function (aContentType, aCommand, aWindowTarget, aSourceContext, aChannel) { var e; - var channel = aRequest.QueryInterface(nsIChannel); - + dump ("ircLoader.handleContent (" + aContentType + ", " + aCommand + ", " + aWindowTarget + ", " + aSourceContext + ", " + - channel.URI.spec + ")\n"); + aChannel.URI.spec + ")\n"); var windowManager = Components.classes[MEDIATOR_CONTRACTID].getService(nsIWindowMediator); @@ -124,13 +123,13 @@ function (aContentType, aCommand, aWindowTarget, aSourceContext, aRequest) if (w) { w.focus(); - w.gotoIRCURL(channel.URI.spec); + w.gotoIRCURL(aChannel.URI.spec); } else { var ass = Components.classes[ASS_CONTRACTID].getService(nsIAppShellService); w = ass.getHiddenDOMWindow(); - w.open("chrome://chatzilla/content/chatzilla.xul?" + channel.URI.spec, + w.open("chrome://chatzilla/content/chatzilla.xul?" + aChannel.URI.spec, "_blank", "chrome,menubar,toolbar,resizable"); } @@ -211,6 +210,8 @@ function (iid) { } /* nsIChannel */ +BogusChannel.prototype.transferOffset = 0; +BogusChannel.prototype.transferCount = 0; BogusChannel.prototype.loadAttributes = null; BogusChannel.prototype.contentType = "x-application-irc"; BogusChannel.prototype.contentLength = 0; @@ -218,9 +219,14 @@ BogusChannel.prototype.owner = null; BogusChannel.prototype.loadGroup = null; BogusChannel.prototype.notificationCallbacks = null; BogusChannel.prototype.securityInfo = null; +BogusChannel.prototype.bufferSegmentSize = 0; +BogusChannel.prototype.bufferMaxSize = 0; +BogusChannel.prototype.shouldCache = false; +BogusChannel.prototype.pipeliningAllowed = false; -BogusChannel.prototype.open = -BogusChannel.prototype.asyncOpen = +BogusChannel.prototype.openInputStream = +BogusChannel.prototype.openOutputStream = +BogusChannel.prototype.asyncWrite = function () { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; diff --git a/mozilla/extensions/irc/js/lib/connection-xpcom.js b/mozilla/extensions/irc/js/lib/connection-xpcom.js index e9663251113..ce3d61f0ada 100644 --- a/mozilla/extensions/irc/js/lib/connection-xpcom.js +++ b/mozilla/extensions/irc/js/lib/connection-xpcom.js @@ -79,7 +79,7 @@ CBSConnection.prototype.connect = function(host, port, bind, tcp_flag) if (!this._channel) throw ("Error opening channel."); - this._outputStream = this._channel.openOutputStream(0, -1, 0); + this._outputStream = this._channel.openOutputStream(0); if (!this._outputStream) throw ("Error getting output stream."); @@ -134,7 +134,7 @@ CBSConnection.prototype.readData = function(timeout) if (!this._inputStream) { this._inputStream = - toScriptableInputStream(this._channel.openInputStream (0, -1, 0)); + toScriptableInputStream(this._channel.openInputStream (0, 0)); if (!this._inputStream) throw ("Error getting input stream."); } @@ -168,7 +168,7 @@ if (jsenv.HAS_DOCUMENT) CBSConnection.prototype.startAsyncRead = function (server) { - this._channel.asyncRead (new StreamListener (server), this, 0, -1, 0); + this._channel.asyncRead (new StreamListener (server), this); } } @@ -179,20 +179,20 @@ function StreamListener(server) } StreamListener.prototype.onStartRequest = -function (request, ctxt) +function (channel, ctxt) { - dd ("onStartRequest: " + request + ", " + ctxt); + dd ("onStartRequest: " + channel + ", " + ctxt); } StreamListener.prototype.onStopRequest = -function (request, ctxt, status, errorMsg) +function (channel, ctxt, status, errorMsg) { - dd ("onStopRequest: " + request + ", " + ctxt + ", " + status + ", " + + dd ("onStopRequest: " + channel + ", " + ctxt + ", " + status + ", " + errorMsg); } StreamListener.prototype.onDataAvailable = -function (request, ctxt, inStr, sourceOffset, count) +function (channel, ctxt, inStr, sourceOffset, count) { ctxt = ctxt.wrappedJSObject; if (!ctxt) diff --git a/mozilla/extensions/pics/src/nsPICS.cpp b/mozilla/extensions/pics/src/nsPICS.cpp index 18c3594bb08..0534ca77871 100644 --- a/mozilla/extensions/pics/src/nsPICS.cpp +++ b/mozilla/extensions/pics/src/nsPICS.cpp @@ -147,11 +147,11 @@ public: // nsIDocumentLoaderObserver NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand); - NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus); - NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request); - NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg); - NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus); + NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus); + NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel); + NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg); + NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus); // NS_IMETHOD OnConnectionsComplete(); @@ -696,7 +696,7 @@ nsPICS::OnStartDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsPICS::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsresult aStatus) { nsresult rv = NS_OK; @@ -719,13 +719,9 @@ nsPICS::OnEndDocumentLoad(nsIDocumentLoader* loader, } NS_IMETHODIMP -nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) +nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel) { nsresult rv = NS_OK; - - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) - return NS_ERROR_FAILURE; nsCOMPtr aURL; rv = channel->GetURI(getter_AddRefs(aURL)); @@ -802,7 +798,7 @@ nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) NS_IMETHODIMP nsPICS::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -813,7 +809,7 @@ nsPICS::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsPICS::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsString& aMsg) { if(!mPICSRatingsEnabled) @@ -823,13 +819,11 @@ nsPICS::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsPICS::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsresult aStatus) { nsresult rv; - nsCOMPtr channel = do_QueryInterface(request); - nsCOMPtr aURL; rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/extensions/psm-glue/public/psm-glue.js b/mozilla/extensions/psm-glue/public/psm-glue.js index 56b302a7932..7b97b561eb9 100644 --- a/mozilla/extensions/psm-glue/public/psm-glue.js +++ b/mozilla/extensions/psm-glue/public/psm-glue.js @@ -9,5 +9,3 @@ pref("security.warn_entering_secure", true); pref("security.warn_leaving_secure", true); pref("security.warn_viewing_mixed", true); pref("security.warn_submit_insecure", true); - -pref("security.ui.enable", true); \ No newline at end of file diff --git a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp index 9d6c61b5bd7..e6f60adf8dc 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp +++ b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp @@ -719,15 +719,12 @@ NS_IMPL_ISUPPORTS(CertDownloader,NS_GET_IID(nsIStreamListener)); const PRInt32 kDefaultCertAllocLength = 2048; NS_IMETHODIMP -CertDownloader::OnStartRequest(nsIRequest *request, nsISupports* context) +CertDownloader::OnStartRequest(nsIChannel* channel, nsISupports* context) { - nsresult rv = NS_OK; - - nsCOMPtr channel = do_QueryInterface(request); - if (channel) - rv = channel->GetContentLength(&mContentLength); - - if (!channel || rv != NS_OK || mContentLength == -1) + nsresult rv; + + rv = channel->GetContentLength(&mContentLength); + if (rv != NS_OK || mContentLength == -1) mContentLength = kDefaultCertAllocLength; mBufferOffset = 0; @@ -740,7 +737,7 @@ CertDownloader::OnStartRequest(nsIRequest *request, nsISupports* context) NS_IMETHODIMP -CertDownloader::OnDataAvailable(nsIRequest *request, +CertDownloader::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -779,7 +776,7 @@ CertDownloader::OnDataAvailable(nsIRequest *request, NS_IMETHODIMP -CertDownloader::OnStopRequest(nsIRequest *request, +CertDownloader::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aMsg) @@ -860,23 +857,20 @@ nsPSMComponent::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports* aWindowContext, - nsIRequest *request) + nsIChannel * aChannel) { // We were called via CI. We better protect ourselves and addref. NS_ADDREF_THIS(); nsresult rv = NS_OK; - if (!request) return NS_ERROR_NULL_POINTER; + if (!aChannel) return NS_ERROR_NULL_POINTER; CMUint32 type = getPSMCertType(aContentType); if (type != -1) { - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) - return NS_ERROR_FAILURE; + // I can't directly open the passed channel cause it fails :-( - nsCOMPtr uri; rv = aChannel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; @@ -885,11 +879,10 @@ nsPSMComponent::HandleContent(const char * aContentType, rv = NS_OpenURI(getter_AddRefs(channel), uri); if (NS_FAILED(rv)) return rv; - return channel->AsyncOpen(new CertDownloader(type), NS_STATIC_CAST(nsIPSMComponent*,this)); - + return channel->AsyncRead(new CertDownloader(type), NS_STATIC_CAST(nsIPSMComponent*,this)); } - return NS_ERROR_FAILURE; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMPL_ISUPPORTS(CertContentListener, NS_GET_IID(nsIURIContentListener)); @@ -964,7 +957,7 @@ NS_IMETHODIMP CertContentListener::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIRequest * request, + nsIChannel * aOpenedChannel, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { diff --git a/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp b/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp index b117e9653c9..d60c04a4f18 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp +++ b/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp @@ -298,7 +298,7 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval) } // Start reading from the channel - rv = channel->AsyncOpen(listener, nsnull); + rv = channel->AsyncRead(listener, nsnull); if (NS_FAILED(rv)) { if (modalEventQueue) { diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 14ace2b32f3..c17e00e88d2 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -253,7 +253,7 @@ nsWalletlibService::OnStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI* aURL #include "prmem.h" NS_IMETHODIMP -nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *request, nsresult aStatus) +nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* channel, nsresult aStatus) { nsresult rv = NS_OK; @@ -373,7 +373,6 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *re nsCOMPtr interfaces; nsCOMPtr prompter; - nsCOMPtr channel = do_QueryInterface(request); if (channel) channel->GetNotificationCallbacks(getter_AddRefs(interfaces)); if (interfaces) @@ -408,21 +407,21 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *re NS_IMETHODIMP nsWalletlibService::OnStartURLLoad - (nsIDocumentLoader* loader, nsIRequest *request) + (nsIDocumentLoader* loader, nsIChannel* channel) { return NS_OK; } NS_IMETHODIMP nsWalletlibService::OnProgressURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) + (nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP nsWalletlibService::OnStatusURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) + (nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg) { return NS_OK; } @@ -430,7 +429,7 @@ nsWalletlibService::OnStatusURLLoad NS_IMETHODIMP nsWalletlibService::OnEndURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) + (nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) { return NS_OK; } diff --git a/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js b/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js index 036f1c9e11d..820ca6e15fc 100644 --- a/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js +++ b/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js @@ -18,9 +18,9 @@ /* * nsXmlRpcClient XPCOM component - * Version: $Revision: 1.13 $ + * Version: $Revision: 1.14 $ * - * $Id: nsXmlRpcClient.js,v 1.13 2001-02-10 00:14:31 dougt%netscape.com Exp $ + * $Id: nsXmlRpcClient.js,v 1.14 2001-02-12 03:12:39 disttsc%bart.nl Exp $ */ /* @@ -125,7 +125,7 @@ nsXmlRpcClient.prototype = { debug('Do the deed.'); - var input = channel.open(0, 0, 0); + var input = channel.openInputStream(); input = toScriptableStream(input); var now = new Date() @@ -220,7 +220,7 @@ nsXmlRpcClient.prototype = { var chann = this._getChannel(requestBody); // And...... call! - chann.asyncOpen(this, context); + chann.asyncRead(this, context); }, // Return a HTTP channel ready for POSTing. diff --git a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp index c532a274cae..5dbd5ecbbc8 100644 --- a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp @@ -82,9 +82,7 @@ nsDOMParserChannel::~nsDOMParserChannel() { } -NS_IMPL_ISUPPORTS2(nsDOMParserChannel, - nsIChannel, - nsIRequest) +NS_IMPL_ISUPPORTS2(nsDOMParserChannel, nsIRequest, nsIChannel) /* boolean isPending (); */ NS_IMETHODIMP nsDOMParserChannel::GetName(PRUnichar* *result) @@ -161,6 +159,38 @@ NS_IMETHODIMP nsDOMParserChannel::SetURI(nsIURI * aURI) return NS_OK; } +/* attribute unsigned long transferOffset; */ +NS_IMETHODIMP nsDOMParserChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsDOMParserChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute long transferCount; */ +NS_IMETHODIMP nsDOMParserChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_ENSURE_ARG(aTransferCount); + *aTransferCount = -1; + return NS_OK; +} +NS_IMETHODIMP nsDOMParserChannel::SetTransferCount(PRInt32 aTransferCount) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute nsLoadFlags loadAttributes; */ +NS_IMETHODIMP nsDOMParserChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsDOMParserChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + /* attribute string contentType; */ NS_IMETHODIMP nsDOMParserChannel::GetContentType(char * *aContentType) { @@ -202,16 +232,6 @@ NS_IMETHODIMP nsDOMParserChannel::SetOwner(nsISupports * aOwner) return NS_OK; } -/* attribute nsLoadFlags loadAttributes; */ -NS_IMETHODIMP nsDOMParserChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsDOMParserChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - /* attribute nsILoadGroup loadGroup; */ NS_IMETHODIMP nsDOMParserChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup) { @@ -242,12 +262,62 @@ NS_IMETHODIMP nsDOMParserChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsDOMParserChannel::Open(nsIInputStream **_retval) +/* attribute unsigned long bufferSegmentSize; */ +NS_IMETHODIMP nsDOMParserChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsDOMParserChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) { return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsDOMParserChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +/* attribute unsigned long bufferMaxSize; */ +NS_IMETHODIMP nsDOMParserChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsDOMParserChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* readonly attribute nsIFile localFile; */ +NS_IMETHODIMP nsDOMParserChannel::GetLocalFile(nsIFile * *aLocalFile) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute boolean pipeliningAllowed; */ +NS_IMETHODIMP nsDOMParserChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsDOMParserChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIInputStream openInputStream (); */ +NS_IMETHODIMP nsDOMParserChannel::OpenInputStream(nsIInputStream **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIOutputStream openOutputStream (); */ +NS_IMETHODIMP nsDOMParserChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void asyncRead (in nsIStreamListener listener, in nsISupports ctxt); */ +NS_IMETHODIMP nsDOMParserChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void asyncWrite (in nsIStreamProvider provider, in nsISupports ctxt); */ +NS_IMETHODIMP nsDOMParserChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -439,7 +509,6 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream, if (principal) { channel->SetOwner(principal); } - nsCOMPtr request = NS_STATIC_CAST(nsIRequest*, parserChannel); // Tell the document to start loading nsCOMPtr listener; @@ -456,15 +525,15 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream, // Now start pumping data to the listener nsresult status; - rv = listener->OnStartRequest(request, nsnull); - request->GetStatus(&status); + rv = listener->OnStartRequest(channel, nsnull); + channel->GetStatus(&status); if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) { - rv = listener->OnDataAvailable(request, nsnull, stream, 0, contentLength); - request->GetStatus(&status); + rv = listener->OnDataAvailable(channel, nsnull, stream, 0, contentLength); + channel->GetStatus(&status); } - rv = listener->OnStopRequest(request, nsnull, status, nsnull); + rv = listener->OnStopRequest(channel, nsnull, status, nsnull); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; *_retval = domDocument; diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 92a45280c4e..f58c87b0c07 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -603,8 +603,8 @@ nsXMLHttpRequest::GetStatusText(char * *aStatusText) NS_IMETHODIMP nsXMLHttpRequest::Abort() { - if (mReadRequest) { - return mReadRequest->Cancel(NS_BINDING_ABORTED); + if (mChannel) { + return mChannel->Cancel(NS_BINDING_ABORTED); } return NS_OK; @@ -1038,7 +1038,7 @@ nsXMLHttpRequest::Send(nsISupports *body) // Start reading from the channel mStatus = XML_HTTP_REQUEST_SENT; - rv = mChannel->AsyncOpen(listener, nsnull); + rv = mChannel->AsyncRead(listener, nsnull); #ifdef IMPLEMENT_SYNC_LOAD if (NS_FAILED(rv)) { diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h index 4dfaa4905bb..eb258639522 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h @@ -89,7 +89,6 @@ protected: nsIInputStream** aStream); nsCOMPtr mChannel; - nsCOMPtr mReadRequest; nsCOMPtr mDocument; nsCOMPtr mBaseURI; nsCOMPtr mBaseDocument; diff --git a/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp b/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp index 0bdebf9b80a..971f1983234 100644 --- a/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp +++ b/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp @@ -91,7 +91,7 @@ int main (int argc, char* argv[]) nsnull ); if (NS_SUCCEEDED( rv )) { - rv = pChannel->Open( getter_AddRefs( pInputStream ) ); + rv = pChannel->OpenInputStream( getter_AddRefs( pInputStream ) ); if (NS_SUCCEEDED( rv )) { rv = pInputStream->Available(&uiContentLength ); diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index fff6c9d0ff6..0510d9dfd5b 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -1059,7 +1059,7 @@ mozXMLTerminal::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, } NS_IMETHODIMP -mozXMLTerminal::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest* request, +mozXMLTerminal::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) { @@ -1068,7 +1068,7 @@ mozXMLTerminal::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest* request NS_IMETHODIMP mozXMLTerminal::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest* request) + nsIChannel* channel) { return NS_OK; @@ -1076,7 +1076,7 @@ mozXMLTerminal::OnStartURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP mozXMLTerminal::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, PRUint32 aProgress, + nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; @@ -1084,14 +1084,14 @@ mozXMLTerminal::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP mozXMLTerminal::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, nsString& aMsg) + nsIChannel* channel, nsString& aMsg) { return NS_OK; } NS_IMETHODIMP mozXMLTerminal::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, nsresult aStatus) + nsIChannel* channel, nsresult aStatus) { XMLT_LOG(mozXMLTerminal::OnEndURLLoad,20,("\n")); diff --git a/mozilla/extensions/xmlterm/ui/xmlterm-service.js b/mozilla/extensions/xmlterm/ui/xmlterm-service.js index 39ee1a941bc..90b7a7f85af 100644 --- a/mozilla/extensions/xmlterm/ui/xmlterm-service.js +++ b/mozilla/extensions/xmlterm/ui/xmlterm-service.js @@ -114,12 +114,10 @@ function (iid) { } TelnetContentHandler.prototype.handleContent = -function (aContentType, aCommand, aWindowTarget, aSourceContext, aRequest) +function (aContentType, aCommand, aWindowTarget, aSourceContext, aChannel) { var e; - var aChannel = aRequest.QueryInterface(Components.interfaces.nsIChannel); - dump ("telnetLoader.handleContent (" + aContentType + ", " + aCommand + ", " + aWindowTarget + ", " + aSourceContext + ", " + aChannel.URI.spec + ")\n"); @@ -220,11 +218,8 @@ function (aURI) //dump("gSystemPrincipal="+gSystemPrincipal+"\n"); // Cancel XUL request and release channel - - // why are you canceling here?! you have not even opened anything yet - dougt. - // temChannel.cancel(Components.results.NS_BINDING_ABORTED); - - temChannel = null; + temChannel.cancel(Components.results.NS_BINDING_ABORTED); + temChannel = null; // Get current process directory var dscontractid = "@mozilla.org/file/directory_service;1"; @@ -284,6 +279,8 @@ function (iid) { } /* nsIChannel */ +BogusChannel.prototype.transferOffset = 0; +BogusChannel.prototype.transferCount = 0; BogusChannel.prototype.loadAttributes = null; BogusChannel.prototype.contentType = "x-application-telnet"; BogusChannel.prototype.contentLength = 0; @@ -291,10 +288,14 @@ BogusChannel.prototype.owner = null; BogusChannel.prototype.loadGroup = null; BogusChannel.prototype.notificationCallbacks = null; BogusChannel.prototype.securityInfo = null; +BogusChannel.prototype.bufferSegmentSize = 0; +BogusChannel.prototype.bufferMaxSize = 0; BogusChannel.prototype.shouldCache = false; +BogusChannel.prototype.pipeliningAllowed = false; -BogusChannel.prototype.open = -BogusChannel.prototype.asyncOpen = +BogusChannel.prototype.openInputStream = +BogusChannel.prototype.openOutputStream = +BogusChannel.prototype.asyncWrite = function () { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; @@ -306,6 +307,12 @@ function (observer, ctxt) observer.onStartRequest (this, ctxt); } +BogusChannel.prototype.asyncRead = +function (listener, ctxt) +{ + return listener.onStartRequest (this, ctxt); +} + /* nsIRequest */ BogusChannel.prototype.isPending = function () @@ -321,7 +328,6 @@ function (aStatus) this.status = aStatus; } -BogusChannel.prototype.parent = BogusChannel.prototype.suspend = BogusChannel.prototype.resume = function () diff --git a/mozilla/gfx/src/nsImageNetContextAsync.cpp b/mozilla/gfx/src/nsImageNetContextAsync.cpp index d9510f8b212..2ee95c0fae0 100644 --- a/mozilla/gfx/src/nsImageNetContextAsync.cpp +++ b/mozilla/gfx/src/nsImageNetContextAsync.cpp @@ -98,8 +98,8 @@ public: virtual int GetContentLength(ilIURL * aURL); nsresult RemoveRequest(ImageConsumer *aConsumer); - nsresult RequestDone(ImageConsumer *aConsumer, nsIRequest* request, - nsISupports* ctxt, nsresult status, const PRUnichar* aMsg); + nsresult RequestDone(ImageConsumer *aConsumer, nsIChannel* channel, + nsISupports* ctxt, nsresult status, const PRUnichar* aMsg); nsVoidArray *mRequests; // WEAK references to |ImageConsumer|s ImgCachePolicy mReloadPolicy; @@ -121,10 +121,10 @@ public: NS_DECL_NSIURICONTENTLISTENER NS_DECL_NSIINTERFACEREQUESTOR - void SetKeepPumpingData(nsIRequest* request, nsISupports* context) { - NS_ADDREF(request); - NS_IF_RELEASE(mRequest); - mRequest = request; + void SetKeepPumpingData(nsIChannel* channel, nsISupports* context) { + NS_ADDREF(channel); + NS_IF_RELEASE(mChannel); + mChannel = channel; NS_IF_ADDREF(context); NS_IF_RELEASE(mUserContext); @@ -145,7 +145,7 @@ protected: PRBool mFirstRead; char *mBuffer; PRInt32 mStatus; - nsIRequest* mRequest; + nsIChannel* mChannel; nsISupports* mUserContext; PRBool mIsMulti; }; @@ -162,7 +162,7 @@ ImageConsumer::ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext) mStream = nsnull; mBuffer = nsnull; mStatus = 0; - mRequest = nsnull; + mChannel = nsnull; mUserContext = nsnull; mIsMulti = PR_FALSE; } @@ -262,7 +262,7 @@ NS_IMETHODIMP ImageConsumer::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIRequest * aOpenedChannel, + nsIChannel * aOpenedChannel, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { @@ -294,10 +294,8 @@ ImageConsumer::DoContent(const char * aContentType, NS_IMETHODIMP -ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) +ImageConsumer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { - nsCOMPtr channel = do_QueryInterface(aRequest); - PRUint32 httpStatus; if (mInterrupted) { mStatus = MK_INTERRUPTED; @@ -320,7 +318,7 @@ ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) } ilINetReader *reader = mURL->GetReader(); //ptn test: nsCOMPtr?? - /*nsresult err=*/ reader->FlushImgBuffer(); //flush current data in buffer before starting + nsresult err= reader->FlushImgBuffer(); //flush current data in buffer before starting nsresult rv = NS_OK; char* aContentType = NULL; @@ -355,15 +353,13 @@ ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) NS_IMETHODIMP -ImageConsumer::OnDataAvailable(nsIRequest* request, nsISupports* aContext, - nsIInputStream *pIStream, PRUint32 offset, PRUint32 length) +ImageConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIInputStream *pIStream, + PRUint32 offset, PRUint32 length) { PRUint32 max_read=0; PRUint32 bytes_read = 0; ilINetReader *reader = mURL->GetReader(); - nsCOMPtr channel = do_QueryInterface(request); - if (mInterrupted || mStatus != 0) { mStatus = MK_INTERRUPTED; reader->StreamAbort(mStatus); @@ -486,12 +482,12 @@ ImageConsumer::KeepPumpingStream(nsITimer *aTimer, void *aClosure) ImageConsumer *consumer = (ImageConsumer *)aClosure; nsAutoString status; - consumer->OnStopRequest(consumer->mRequest, consumer->mUserContext, + consumer->OnStopRequest(consumer->mChannel, consumer->mUserContext, NS_BINDING_SUCCEEDED, status.GetUnicode()); } NS_IMETHODIMP -ImageConsumer::OnStopRequest(nsIRequest* request, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) +ImageConsumer::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) { if (mTimer) { mTimer->Cancel(); @@ -510,12 +506,12 @@ ImageConsumer::OnStopRequest(nsIRequest* request, nsISupports* aContext, nsresul nsresult err = mStream->Available(&str_length); if (NS_SUCCEEDED(err)) { NS_ASSERTION((str_length > 0), "No data left in the stream!"); - err = OnDataAvailable(request, aContext, mStream, 0, str_length); // XXX fix offset + err = OnDataAvailable(channel, aContext, mStream, 0, str_length); // XXX fix offset if (NS_SUCCEEDED(err)) { // If we still have the stream, there's still data to be // pumped, so we set a timer to call us back again. if (mStream) { - SetKeepPumpingData(request, aContext); + SetKeepPumpingData(channel, aContext); nsresult rv; mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); @@ -554,7 +550,7 @@ ImageConsumer::OnStopRequest(nsIRequest* request, nsISupports* aContext, nsresul reader->NetRequestDone(mURL, mStatus); NS_RELEASE(reader); - return mContext->RequestDone(this, request, aContext, status, aMsg); + return mContext->RequestDone(this, channel, aContext, status, aMsg); } void @@ -587,7 +583,7 @@ ImageConsumer::~ImageConsumer() if (mBuffer != nsnull) { PR_DELETE(mBuffer); } - NS_IF_RELEASE(mRequest); + NS_IF_RELEASE(mChannel); NS_IF_RELEASE(mUserContext); } @@ -726,10 +722,8 @@ ImageNetContextImpl::GetContentLength (ilIURL * aURL) rv = NS_OpenURI(getter_AddRefs(channel), nsurl, nsnull, group, sink); if (NS_FAILED(rv)) return 0; - // Why would this code ever return anything but zero. we don't do asyncread - // on the channel we create? - // Commenting this line for now TODO -gagan - //rv = channel->GetContentLength(&content_length); + + rv = channel->GetContentLength(&content_length); return content_length; } @@ -791,16 +785,14 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { - // Get the defloadRequest from the loadgroup- - nsCOMPtr defLoadRequest; - if (NS_SUCCEEDED(group->GetDefaultLoadRequest( - getter_AddRefs(defLoadRequest))) && defLoadRequest) + // Get the defloadchannel from the loadgroup- + nsCOMPtr defLoadChannel; + if (NS_SUCCEEDED(group->GetDefaultLoadChannel( + getter_AddRefs(defLoadChannel))) && defLoadChannel) { - nsCOMPtr reqchannel = do_QueryInterface(defLoadRequest); - // Get the referrer from the loadchannel- nsCOMPtr referrer; - if (NS_SUCCEEDED(reqchannel->GetURI(getter_AddRefs(referrer)))) + if (NS_SUCCEEDED(defLoadChannel->GetURI(getter_AddRefs(referrer)))) { // Set the referrer- httpChannel->SetReferrer(referrer, @@ -834,7 +826,7 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, rv = pURILoader->OpenURI(channel, loadCmd, nsnull /* window target */, window); } - // rv = channel->AsyncOpen(ic, nsnull); + // rv = channel->AsyncRead(ic, nsnull); if (NS_FAILED(rv)) goto error; } @@ -859,8 +851,8 @@ ImageNetContextImpl::RemoveRequest(ImageConsumer *aConsumer) } nsresult -ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer, nsIRequest* request, - nsISupports* ctxt, nsresult status, const PRUnichar* aMsg) +ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer, nsIChannel* channel, + nsISupports* ctxt, nsresult status, const PRUnichar* aMsg) { RemoveRequest(aConsumer); /// if (mLoadGroup) @@ -887,18 +879,14 @@ NS_NewImageNetContext(ilINetContext **aInstancePtrResult, if(aLoadContext){ nsCOMPtr group (do_GetInterface(aLoadContext)); - /*nsresult rv = */group->GetDefaultLoadAttributes(&necko_attribs); + nsresult rv = group->GetDefaultLoadAttributes(&necko_attribs); /* Need code to check freshness of necko cache. */ - nsCOMPtr defLoadRequest; - nsCOMPtr channel; - if (NS_SUCCEEDED(group->GetDefaultLoadRequest( - getter_AddRefs(defLoadRequest))) && defLoadRequest) - { - channel = do_QueryInterface(defLoadRequest); - if (channel) channel->GetLoadAttributes(&defchan_attribs); - } + nsCOMPtr defLoadChannel; + if (NS_SUCCEEDED(group->GetDefaultLoadChannel( + getter_AddRefs(defLoadChannel))) && defLoadChannel) + defLoadChannel->GetLoadAttributes(&defchan_attribs); #if defined( DEBUG ) if (image_net_context_async_log_module == NULL) { diff --git a/mozilla/gfx/src/nsImageNetContextSync.cpp b/mozilla/gfx/src/nsImageNetContextSync.cpp index 95b588980d3..463c0525ce3 100644 --- a/mozilla/gfx/src/nsImageNetContextSync.cpp +++ b/mozilla/gfx/src/nsImageNetContextSync.cpp @@ -218,9 +218,6 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, if(aContentType){ nsCRT::free(aContentType); } - } - - if (!aContentType) { aContentType = nsCRT::strdup("unknown"); } if(nsCRT::strlen(aContentType) > 50){ @@ -229,8 +226,8 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, nsCRT::free(aContentType); aContentType = nsCRT::strdup("unknown"); } - - rv = channel->Open( &stream); + + rv = channel->OpenInputStream(&stream); NS_RELEASE(channel); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index b425214c371..41be60fa94d 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -152,7 +152,7 @@ CStreamListener::OnStartDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsresult aStatus) { fputs("done.\n",stdout); @@ -162,14 +162,14 @@ CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest *request) + nsIChannel* channel) { return NS_OK; } NS_IMETHODIMP CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -178,7 +178,7 @@ CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsString& aMsg) { return NS_OK; @@ -186,7 +186,7 @@ CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsresult aStatus) { return NS_OK; diff --git a/mozilla/htmlparser/src/CParserContext.cpp b/mozilla/htmlparser/src/CParserContext.cpp index 4bafaaf0a63..c3bbaaacf78 100644 --- a/mozilla/htmlparser/src/CParserContext.cpp +++ b/mozilla/htmlparser/src/CParserContext.cpp @@ -61,7 +61,7 @@ CParserContext::CParserContext(nsScanner* aScanner, mContextType=eCTNone; mCopyUnused=aCopyUnused; mParserCommand=aCommand; - mRequest=0; + mChannel=0; mValidator=0; } @@ -92,7 +92,7 @@ CParserContext::CParserContext(const CParserContext &aContext) : mMimeType() { mStreamListenerState=aContext.mStreamListenerState; mMultipart=aContext.mMultipart; mContextType=aContext.mContextType; - mRequest=aContext.mRequest; + mChannel=aContext.mChannel; mParserCommand=aContext.mParserCommand; SetMimeType(aContext.mMimeType); } diff --git a/mozilla/htmlparser/src/CParserContext.h b/mozilla/htmlparser/src/CParserContext.h index e9ac2471984..9e282589875 100644 --- a/mozilla/htmlparser/src/CParserContext.h +++ b/mozilla/htmlparser/src/CParserContext.h @@ -72,7 +72,7 @@ public: eContextType mContextType; eAutoDetectResult mAutoDetectStatus; eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors... - nsIRequest* mRequest; // provided by necko to differnciate different input streams + nsIChannel* mChannel; // provided by necko to differnciate different input streams nsScanner* mScanner; nsIDTD* mDTD; diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index e2d35b6f1a0..7f9e83a5e70 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -2062,11 +2062,11 @@ nsITokenizer* nsParser::GetTokenizer(void) { * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) +nsParser::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult result=0; if (nsnull != mProgressEventSink) { - mProgressEventSink->OnProgress(request, aContext, aProgress, aProgressMax); + mProgressEventSink->OnProgress(channel, aContext, aProgress, aProgressMax); } return result; } @@ -2079,12 +2079,12 @@ nsParser::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgr * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIRequest *request, nsISupports* aContext, +nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; if (nsnull != mProgressEventSink) { - rv = mProgressEventSink->OnStatus(request, aContext, aStatus, aStatusArg); + rv = mProgressEventSink->OnStatus(channel, aContext, aStatus, aStatusArg); NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } return NS_OK; @@ -2102,22 +2102,19 @@ nsParser::OnStatus(nsIRequest *request, nsISupports* aContext, * @param * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { +nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { NS_PRECONDITION((eNone==mParserContext->mStreamListenerState),kBadListenerInit); if (nsnull != mObserver) { - mObserver->OnStartRequest(request, aContext); + mObserver->OnStartRequest(channel, aContext); } mParserContext->mStreamListenerState=eOnStart; mParserContext->mAutoDetectStatus=eUnknownDetect; - mParserContext->mRequest=request; + mParserContext->mChannel=channel; mParserContext->mDTD=0; nsresult rv; char* contentType = nsnull; - nsCOMPtr channel = do_QueryInterface(request); - NS_ASSERTION(channel, "parser needs a channel to find a dtd"); - rv = channel->GetContentType(&contentType); if (NS_SUCCEEDED(rv)) { @@ -2313,7 +2310,7 @@ ParserWriteFunc(nsIInputStream* in, * @return error code (usually 0) */ -nsresult nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext, +nsresult nsParser::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIInputStream *pIStream, PRUint32 sourceOffset, PRUint32 aLength) { @@ -2325,12 +2322,12 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail CParserContext *theContext=mParserContext; while(theContext) { - if(theContext->mRequest!=request && theContext->mPrevContext) + if(theContext->mChannel!=channel && theContext->mPrevContext) theContext=theContext->mPrevContext; else break; } - if(theContext && theContext->mRequest==request) { + if(theContext && theContext->mChannel==channel) { theContext->mStreamListenerState=eOnDataAvail; @@ -2369,7 +2366,7 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail * @param * @return */ -nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, +nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) { @@ -2401,7 +2398,7 @@ nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, // XXX Should we wait to notify our observers as well if the // parser isn't yet enabled? if (nsnull != mObserver) { - mObserver->OnStopRequest(request, aContext, status, aMsg); + mObserver->OnStopRequest(channel, aContext, status, aMsg); } #ifdef rickgdebug diff --git a/mozilla/htmlparser/tests/grabpage/grabpage.cpp b/mozilla/htmlparser/tests/grabpage/grabpage.cpp index 07a224ece41..4b42cfac0d7 100644 --- a/mozilla/htmlparser/tests/grabpage/grabpage.cpp +++ b/mozilla/htmlparser/tests/grabpage/grabpage.cpp @@ -237,7 +237,7 @@ PageGrabber::Grab(const nsString& aURL) if(copier) { NS_ADDREF(copier); - rv = channel->AsyncOpen(copier, nsnull); + rv = channel->AsyncRead(copier, nsnull); if (NS_OK != rv) { NS_RELEASE(copier); diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index 556ac838c28..30d10b2c1b2 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -238,10 +238,8 @@ nsStringBundle::OnStreamComplete(nsIStreamLoader* aLoader, nsXPIDLCString uriSpec; if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr request; - aLoader->GetRequest(getter_AddRefs(request)); - nsCOMPtr channel(do_QueryInterface(request)); - + nsCOMPtr channel; + aLoader->GetChannel(getter_AddRefs(channel)); if (channel) { nsCOMPtr uri; channel->GetURI(getter_AddRefs(uri)); diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 3cc991f23f4..9e4fd957de0 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -634,12 +634,13 @@ protected: public: static nsresult - Create(nsIRequest** aResult, nsIPresShell* aPresShell); + Create(nsIChannel** aResult, nsIPresShell* aPresShell); NS_DECL_ISUPPORTS // nsIRequest NS_IMETHOD GetName(PRUnichar* *result) { + NS_NOTREACHED("DummyLayoutRequest::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; } @@ -648,27 +649,39 @@ public: NS_IMETHOD Suspend(void) { return NS_OK; } NS_IMETHOD Resume(void) { return NS_OK; } - // nsIChannel + // nsIChannel NS_IMETHOD GetOriginalURI(nsIURI* *aOriginalURI) { *aOriginalURI = gURI; NS_ADDREF(*aOriginalURI); return NS_OK; } NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI) { gURI = aOriginalURI; NS_ADDREF(gURI); return NS_OK; } NS_IMETHOD GetURI(nsIURI* *aURI) { *aURI = gURI; NS_ADDREF(*aURI); return NS_OK; } NS_IMETHOD SetURI(nsIURI* aURI) { gURI = aURI; NS_ADDREF(gURI); return NS_OK; } - NS_IMETHOD Open(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } - NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } + NS_IMETHOD OpenInputStream(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD OpenOutputStream(nsIOutputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes) { return NS_OK; } - NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } - NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } - NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } - NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } - NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } - NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } - NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { *aSecurityInfo = nsnull; return NS_OK; } - NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } - NS_IMETHOD SetContentType(const char * aContentType) { return NS_OK; } - NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return NS_OK; } - NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return NS_OK; } - + NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } + NS_IMETHOD SetContentType(const char *aContentType) { return NS_OK; } + NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { *aContentLength = 0; return NS_OK; } + NS_IMETHOD SetContentLength(PRInt32 aContentLength) { NS_NOTREACHED("SetContentLength"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferOffset(PRUint32 *aTransferOffset) { NS_NOTREACHED("GetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferOffset(PRUint32 aTransferOffset) { NS_NOTREACHED("SetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferCount(PRInt32 *aTransferCount) { NS_NOTREACHED("GetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferCount(PRInt32 aTransferCount) { NS_NOTREACHED("SetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) { NS_NOTREACHED("GetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferSegmentSize(PRUint32 aBufferSegmentSize) { NS_NOTREACHED("SetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferMaxSize(PRUint32 *aBufferMaxSize) { NS_NOTREACHED("GetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferMaxSize(PRUint32 aBufferMaxSize) { NS_NOTREACHED("SetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetLocalFile(nsIFile* *result) { NS_NOTREACHED("GetLocalFile"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetPipeliningAllowed(PRBool *aPipeliningAllowed) { *aPipeliningAllowed = PR_FALSE; return NS_OK; } + NS_IMETHOD SetPipeliningAllowed(PRBool aPipeliningAllowed) { NS_NOTREACHED("SetPipeliningAllowed"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } + NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } + NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } + NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } + NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } + NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } + NS_IMETHOD GetSecurityInfo(nsISupports **info) {*info = nsnull; return NS_OK;} }; PRInt32 DummyLayoutRequest::gRefCnt; @@ -679,7 +692,7 @@ NS_IMPL_RELEASE(DummyLayoutRequest); NS_IMPL_QUERY_INTERFACE2(DummyLayoutRequest, nsIRequest, nsIChannel); nsresult -DummyLayoutRequest::Create(nsIRequest** aResult, nsIPresShell* aPresShell) +DummyLayoutRequest::Create(nsIChannel** aResult, nsIPresShell* aPresShell) { DummyLayoutRequest* request = new DummyLayoutRequest(aPresShell); if (!request) @@ -1052,7 +1065,7 @@ protected: nsCOMPtr mObserverService; // Observer service for reflow events nsCOMPtr mDragService; PRInt32 mRCCreatedDuringLoad; // Counter to keep track of reflow commands created during doc - nsCOMPtr mDummyLayoutRequest; + nsCOMPtr mDummyLayoutRequest; // used for list of posted events and attribute changes. To be done // after reflow. @@ -5330,10 +5343,10 @@ PresShell::AddDummyLayoutRequest(void) } if (loadGroup) { - nsCOMPtr channel = do_QueryInterface(mDummyLayoutRequest); - rv = channel->SetLoadGroup(loadGroup); + rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; - rv = loadGroup->AddRequest(mDummyLayoutRequest, nsnull); + + rv = loadGroup->AddChannel(mDummyLayoutRequest, nsnull); if (NS_FAILED(rv)) return rv; } @@ -5357,7 +5370,7 @@ PresShell::RemoveDummyLayoutRequest(void) } if (loadGroup && mDummyLayoutRequest) { - rv = loadGroup->RemoveRequest(mDummyLayoutRequest, nsnull, NS_OK, nsnull); + rv = loadGroup->RemoveChannel(mDummyLayoutRequest, nsnull, NS_OK, nsnull); if (NS_FAILED(rv)) return rv; mDummyLayoutRequest = nsnull; diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 3cc991f23f4..9e4fd957de0 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -634,12 +634,13 @@ protected: public: static nsresult - Create(nsIRequest** aResult, nsIPresShell* aPresShell); + Create(nsIChannel** aResult, nsIPresShell* aPresShell); NS_DECL_ISUPPORTS // nsIRequest NS_IMETHOD GetName(PRUnichar* *result) { + NS_NOTREACHED("DummyLayoutRequest::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; } @@ -648,27 +649,39 @@ public: NS_IMETHOD Suspend(void) { return NS_OK; } NS_IMETHOD Resume(void) { return NS_OK; } - // nsIChannel + // nsIChannel NS_IMETHOD GetOriginalURI(nsIURI* *aOriginalURI) { *aOriginalURI = gURI; NS_ADDREF(*aOriginalURI); return NS_OK; } NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI) { gURI = aOriginalURI; NS_ADDREF(gURI); return NS_OK; } NS_IMETHOD GetURI(nsIURI* *aURI) { *aURI = gURI; NS_ADDREF(*aURI); return NS_OK; } NS_IMETHOD SetURI(nsIURI* aURI) { gURI = aURI; NS_ADDREF(gURI); return NS_OK; } - NS_IMETHOD Open(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } - NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } + NS_IMETHOD OpenInputStream(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD OpenOutputStream(nsIOutputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes) { return NS_OK; } - NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } - NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } - NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } - NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } - NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } - NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } - NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { *aSecurityInfo = nsnull; return NS_OK; } - NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } - NS_IMETHOD SetContentType(const char * aContentType) { return NS_OK; } - NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return NS_OK; } - NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return NS_OK; } - + NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } + NS_IMETHOD SetContentType(const char *aContentType) { return NS_OK; } + NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { *aContentLength = 0; return NS_OK; } + NS_IMETHOD SetContentLength(PRInt32 aContentLength) { NS_NOTREACHED("SetContentLength"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferOffset(PRUint32 *aTransferOffset) { NS_NOTREACHED("GetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferOffset(PRUint32 aTransferOffset) { NS_NOTREACHED("SetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferCount(PRInt32 *aTransferCount) { NS_NOTREACHED("GetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferCount(PRInt32 aTransferCount) { NS_NOTREACHED("SetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) { NS_NOTREACHED("GetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferSegmentSize(PRUint32 aBufferSegmentSize) { NS_NOTREACHED("SetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferMaxSize(PRUint32 *aBufferMaxSize) { NS_NOTREACHED("GetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferMaxSize(PRUint32 aBufferMaxSize) { NS_NOTREACHED("SetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetLocalFile(nsIFile* *result) { NS_NOTREACHED("GetLocalFile"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetPipeliningAllowed(PRBool *aPipeliningAllowed) { *aPipeliningAllowed = PR_FALSE; return NS_OK; } + NS_IMETHOD SetPipeliningAllowed(PRBool aPipeliningAllowed) { NS_NOTREACHED("SetPipeliningAllowed"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } + NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } + NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } + NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } + NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } + NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } + NS_IMETHOD GetSecurityInfo(nsISupports **info) {*info = nsnull; return NS_OK;} }; PRInt32 DummyLayoutRequest::gRefCnt; @@ -679,7 +692,7 @@ NS_IMPL_RELEASE(DummyLayoutRequest); NS_IMPL_QUERY_INTERFACE2(DummyLayoutRequest, nsIRequest, nsIChannel); nsresult -DummyLayoutRequest::Create(nsIRequest** aResult, nsIPresShell* aPresShell) +DummyLayoutRequest::Create(nsIChannel** aResult, nsIPresShell* aPresShell) { DummyLayoutRequest* request = new DummyLayoutRequest(aPresShell); if (!request) @@ -1052,7 +1065,7 @@ protected: nsCOMPtr mObserverService; // Observer service for reflow events nsCOMPtr mDragService; PRInt32 mRCCreatedDuringLoad; // Counter to keep track of reflow commands created during doc - nsCOMPtr mDummyLayoutRequest; + nsCOMPtr mDummyLayoutRequest; // used for list of posted events and attribute changes. To be done // after reflow. @@ -5330,10 +5343,10 @@ PresShell::AddDummyLayoutRequest(void) } if (loadGroup) { - nsCOMPtr channel = do_QueryInterface(mDummyLayoutRequest); - rv = channel->SetLoadGroup(loadGroup); + rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; - rv = loadGroup->AddRequest(mDummyLayoutRequest, nsnull); + + rv = loadGroup->AddChannel(mDummyLayoutRequest, nsnull); if (NS_FAILED(rv)) return rv; } @@ -5357,7 +5370,7 @@ PresShell::RemoveDummyLayoutRequest(void) } if (loadGroup && mDummyLayoutRequest) { - rv = loadGroup->RemoveRequest(mDummyLayoutRequest, nsnull, NS_OK, nsnull); + rv = loadGroup->RemoveChannel(mDummyLayoutRequest, nsnull, NS_OK, nsnull); if (NS_FAILED(rv)) return rv; mDummyLayoutRequest = nsnull; diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 75ccd42adbe..c9950719f75 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -4715,12 +4715,8 @@ HTMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader, nsCOMPtr httpChannel; nsCOMPtr channel; - nsCOMPtr request; - rv = aLoader->GetRequest(getter_AddRefs(request)); - NS_ASSERTION(request, "StreamLoader's request went away prematurely"); - if (NS_FAILED(rv)) return rv; - - channel = do_QueryInterface(request); + rv = aLoader->GetChannel(getter_AddRefs(channel)); + NS_ASSERTION(channel, "StreamLoader's channel went away prematurely"); if (channel) { httpChannel = do_QueryInterface(channel); diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 75c15c3096f..fd9adb6e18d 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -585,35 +585,33 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, nsCOMPtr file; rv = fileChannel->GetFile(getter_AddRefs(file)); - if (NS_SUCCEEDED(rv)) - { - // if we failed to get a last modification date, then we don't want to necessarily - // fail to create a document for this file. Just don't set the last modified date on it... - rv = file->GetLastModificationDate(&modDate); - if (NS_SUCCEEDED(rv)) - { - PRExplodedTime prtime; - char buf[100]; - PRInt64 intermediateValue; + if (NS_FAILED(rv)) { return rv; } + // if we failed to get a last modification date, then we don't want to necessarily + // fail to create a document for this file. Just don't set the last modified date on it... + rv = file->GetLastModificationDate(&modDate); + if (NS_SUCCEEDED(rv)) + { + PRExplodedTime prtime; + char buf[100]; + PRInt64 intermediateValue; - LL_I2L(intermediateValue, PR_USEC_PER_MSEC); - LL_MUL(usecs, modDate, intermediateValue); - PR_ExplodeTime(usecs, PR_LocalTimeParameters, &prtime); + LL_I2L(intermediateValue, PR_USEC_PER_MSEC); + LL_MUL(usecs, modDate, intermediateValue); + PR_ExplodeTime(usecs, PR_LocalTimeParameters, &prtime); - // Use '%#c' for windows, because '%c' is backward-compatible and - // non-y2k with msvc; '%#c' requests that a full year be used in the - // result string. Other OSes just use "%c". - PR_FormatTime(buf, sizeof buf, - #if defined(XP_PC) && !defined(XP_OS2) - "%#c", - #else - "%c", - #endif - &prtime); - lastModified.AssignWithConversion(buf); - SetLastModified(lastModified); - } - } + // Use '%#c' for windows, because '%c' is backward-compatible and + // non-y2k with msvc; '%#c' requests that a full year be used in the + // result string. Other OSes just use "%c". + PR_FormatTime(buf, sizeof buf, +#if defined(XP_PC) && !defined(XP_OS2) + "%#c", +#else + "%c", +#endif + &prtime); + lastModified.AssignWithConversion(buf); + SetLastModified(lastModified); + } } static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); diff --git a/mozilla/layout/html/document/src/nsImageDocument.cpp b/mozilla/layout/html/document/src/nsImageDocument.cpp index 4201b7d24d9..4e4a62c4d67 100644 --- a/mozilla/layout/html/document/src/nsImageDocument.cpp +++ b/mozilla/layout/html/document/src/nsImageDocument.cpp @@ -121,14 +121,10 @@ ImageListener::~ImageListener() NS_IMPL_THREADSAFE_ISUPPORTS(ImageListener, NS_GET_IID(nsIStreamListener)) NS_IMETHODIMP -ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt) +ImageListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { nsresult rv; nsIURI* uri; - - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_NULL_POINTER; - rv = channel->GetURI(&uri); if (NS_FAILED(rv)) return rv; @@ -137,11 +133,11 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt) if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStartRequest(request, ctxt); + return mNextStream->OnStartRequest(channel, ctxt); } NS_IMETHODIMP -ImageListener::OnStopRequest(nsIRequest* request, nsISupports *ctxt, +ImageListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if(mDocument){ @@ -151,17 +147,17 @@ ImageListener::OnStopRequest(nsIRequest* request, nsISupports *ctxt, if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStopRequest(request, ctxt, status, errorMsg); + return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); } NS_IMETHODIMP -ImageListener::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, +ImageListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); + return mNextStream->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/xbl/src/nsXBLService.cpp b/mozilla/layout/xbl/src/nsXBLService.cpp index 9b57da9ebbd..2119b7ef260 100644 --- a/mozilla/layout/xbl/src/nsXBLService.cpp +++ b/mozilla/layout/xbl/src/nsXBLService.cpp @@ -260,37 +260,38 @@ nsXBLStreamListener::~nsXBLStreamListener() } } +/* void onDataAvailable (in nsIChannel channel, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */ NS_IMETHODIMP -nsXBLStreamListener::OnDataAvailable(nsIRequest *request, nsISupports* aCtxt, nsIInputStream* aInStr, +nsXBLStreamListener::OnDataAvailable(nsIChannel* aChannel, nsISupports* aCtxt, nsIInputStream* aInStr, PRUint32 aSourceOffset, PRUint32 aCount) { if (mInner) - return mInner->OnDataAvailable(request, aCtxt, aInStr, aSourceOffset, aCount); + return mInner->OnDataAvailable(aChannel, aCtxt, aInStr, aSourceOffset, aCount); return NS_ERROR_FAILURE; } +/* void onStartRequest (in nsIChannel channel, in nsISupports ctxt); */ NS_IMETHODIMP -nsXBLStreamListener::OnStartRequest(nsIRequest* request, nsISupports* aCtxt) +nsXBLStreamListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aCtxt) { if (mInner) - return mInner->OnStartRequest(request, aCtxt); + return mInner->OnStartRequest(aChannel, aCtxt); return NS_ERROR_FAILURE; } +/* void onStopRequest (in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); */ NS_IMETHODIMP -nsXBLStreamListener::OnStopRequest(nsIRequest* request, nsISupports* aCtxt, nsresult aStatus, const PRUnichar* aStatusArg) +nsXBLStreamListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aCtxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mInner) { - rv = mInner->OnStopRequest(request, aCtxt, aStatus, aStatusArg); + rv = mInner->OnStopRequest(aChannel, aCtxt, aStatus, aStatusArg); } if (NS_FAILED(rv) || NS_FAILED(aStatus)) { - - nsCOMPtr aChannel = do_QueryInterface(request); - if (aChannel) + if (aChannel) { nsCOMPtr channelURI; aChannel->GetURI(getter_AddRefs(channelURI)); @@ -1190,7 +1191,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun nsCOMPtr loadGroup; if (aBoundDocument) aBoundDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - nsCOMPtr request; + nsCOMPtr channel; rv = NS_OpenURI(getter_AddRefs(channel), aURI, nsnull, loadGroup); if (NS_FAILED(rv)) return rv; @@ -1232,22 +1233,18 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun xblListener->AddRequest(req); // Now kick off the async read. - channel->AsyncOpen(xblListener, nsnull); + channel->AsyncRead(xblListener, nsnull); return NS_OK; } // Now do a blocking synchronous parse of the file. nsCOMPtr in; PRUint32 sourceOffset = 0; - rv = channel->Open(getter_AddRefs(in)); + rv = channel->OpenInputStream(getter_AddRefs(in)); // If we couldn't open the channel, then just return. if (NS_FAILED(rv)) return NS_OK; - - request = do_QueryInterface(channel); - - NS_ASSERTION(request != nsnull, "no request info"); - + NS_ASSERTION(in != nsnull, "no input stream"); if (! in) return NS_ERROR_FAILURE; @@ -1256,7 +1253,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun if (! proxy) return NS_ERROR_FAILURE; - listener->OnStartRequest(request, nsnull); + listener->OnStartRequest(channel, nsnull); while (PR_TRUE) { char buf[1024]; PRUint32 readCount; @@ -1269,12 +1266,12 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun proxy->SetBuffer(buf, readCount); - rv = listener->OnDataAvailable(request, nsnull, proxy, sourceOffset, readCount); + rv = listener->OnDataAvailable(channel, nsnull, proxy, sourceOffset, readCount); sourceOffset += readCount; if (NS_FAILED(rv)) break; } - listener->OnStopRequest(request, nsnull, NS_OK, nsnull); + listener->OnStopRequest(channel, nsnull, NS_OK, nsnull); // don't leak proxy! proxy->Close(); diff --git a/mozilla/layout/xml/document/src/Makefile.in b/mozilla/layout/xml/document/src/Makefile.in index 0dcfc5eb57f..1254cc04393 100644 --- a/mozilla/layout/xml/document/src/Makefile.in +++ b/mozilla/layout/xml/document/src/Makefile.in @@ -28,7 +28,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout LIBRARY_NAME = gkxmldoc_s -REQUIRES = xpcom js dom locale widget caps htmlparser necko view docshell webshell uriloader pref xpconnect uconv chardet expat lwbrk exthandler mime +REQUIRES = xpcom js dom locale widget caps htmlparser necko view docshell webshell uriloader pref xpconnect uconv chardet expat lwbrk CPPSRCS = \ nsXMLContentSink.cpp \ diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index 9e3ed468c39..3babaa8bd8d 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -1669,11 +1669,7 @@ nsXMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader, if (NS_OK == aStatus) { { // scope in block so nsCOMPtr released at one point nsCOMPtr channel; - nsCOMPtr request; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) - channel = do_QueryInterface(request); - + aLoader->GetChannel(getter_AddRefs(channel)); nsCOMPtr url; if (channel) { channel->GetURI(getter_AddRefs(url)); diff --git a/mozilla/layout/xml/document/src/nsXMLDocument.cpp b/mozilla/layout/xml/document/src/nsXMLDocument.cpp index 5904f9e70ba..b3533b20968 100644 --- a/mozilla/layout/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/layout/xml/document/src/nsXMLDocument.cpp @@ -74,11 +74,6 @@ #include "nsIPrincipal.h" #include "nsIAggregatePrincipal.h" -#include "nsCExternalHandlerService.h" -#include "nsIMIMEService.h" -#include "nsNetUtil.h" -#include "nsMimeTypes.h" - // XXX The XML world depends on the html atoms #include "nsHTMLAtoms.h" @@ -356,7 +351,7 @@ nsXMLDocument::Load(const nsAReadableString& aUrl) } // Start an asynchronous read of the XML document - rv = channel->AsyncOpen(listener, nsnull); + rv = channel->AsyncRead(listener, nsnull); return rv; } @@ -386,10 +381,8 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, rv = aChannel->GetURI(getter_AddRefs(aUrl)); if (NS_FAILED(rv)) return rv; - nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) return rv; - rv = MIMEService->GetTypeFromURI(aUrl, &aContentType); - + rv = aChannel->GetContentType(&aContentType); + if (NS_SUCCEEDED(rv)) { if ( 0 == PL_strcmp(aContentType, "text/html")) { bIsHTML = PR_TRUE; diff --git a/mozilla/layout/xml/document/src/nsXMLDocument.h b/mozilla/layout/xml/document/src/nsXMLDocument.h index c5fe3152dd1..8832b5cf43a 100644 --- a/mozilla/layout/xml/document/src/nsXMLDocument.h +++ b/mozilla/layout/xml/document/src/nsXMLDocument.h @@ -52,7 +52,7 @@ public: NS_IMETHOD GetContentType(nsAWritableString& aContentType) const; NS_IMETHOD StartDocumentLoad(const char* aCommand, - nsIChannel* channel, + nsIChannel* aChannel, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, diff --git a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp index c0d5e58bb20..c179a9dc4fb 100644 --- a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp +++ b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp @@ -342,7 +342,7 @@ NS_IMETHODIMP nsAbSyncPostEngine::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIRequest *request, + nsIChannel * aOpenedChannel, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { @@ -391,7 +391,7 @@ nsAbSyncPostEngine::StillRunning(PRBool *running) // Methods for nsIStreamListener... nsresult -nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream, +nsAbSyncPostEngine::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { PRUint32 readLen = aLength; @@ -417,7 +417,7 @@ nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsI // Methods for nsIStreamObserver nsresult -nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +nsAbSyncPostEngine::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt) { if (mAuthenticationRunning) NotifyListenersOnStartAuthOperation(); @@ -427,7 +427,7 @@ nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt) } nsresult -nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) +nsAbSyncPostEngine::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) { #ifdef NS_DEBUG_rhp printf("nsAbSyncPostEngine::OnStopRequest()\n"); @@ -441,20 +441,20 @@ nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, mStillRunning = PR_FALSE; // Check the content type! - nsCOMPtr channel = do_QueryInterface(request); - if (channel) + if (aChannel) { char *contentType = nsnull; char *charset = nsnull; - if (NS_SUCCEEDED(channel->GetContentType(&contentType)) && contentType) + if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType) { if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE)) { mContentType = contentType; } } - nsCOMPtr httpChannel = do_QueryInterface(channel); + + nsCOMPtr httpChannel = do_QueryInterface(aChannel); if (httpChannel) { if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset) @@ -706,8 +706,8 @@ nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData) httpChannel->SetRequestMethod(method); if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0))) httpChannel->SetUploadStream(postStream); - - httpChannel->AsyncOpen(this, nsnull); + + httpChannel->AsyncRead(this, nsnull); return NS_OK; } @@ -844,9 +844,11 @@ nsAbSyncPostEngine::CancelAbSync() { rv = mSyncMojo->CancelTheMojo(); } - else if (mChannel) + else { - rv = mChannel->Cancel(NS_BINDING_ABORTED); + nsCOMPtr httpChannel = do_QueryInterface(mChannel); + if (httpChannel) + rv = httpChannel->Cancel(NS_BINDING_ABORTED); } return rv; diff --git a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h index 4395ea10530..43df4ca17b5 100644 --- a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h +++ b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h @@ -109,6 +109,7 @@ private: PRBool mAuthenticationRunning; nsCOMPtr mSyncMojo; nsCOMPtr mChannel; + char *mSyncProtocolRequest; char *mSyncProtocolRequestPrefix; diff --git a/mozilla/mailnews/base/public/nsIMsgFolder.idl b/mozilla/mailnews/base/public/nsIMsgFolder.idl index 08bffa7b5bb..d16a7160e58 100644 --- a/mozilla/mailnews/base/public/nsIMsgFolder.idl +++ b/mozilla/mailnews/base/public/nsIMsgFolder.idl @@ -44,7 +44,7 @@ interface nsIMsgFilterList; interface nsIMsgFolderCacheElement; interface nsAutoString; -interface nsITransport; +interface nsIFileChannel; typedef long nsMsgBiffState; // enumerated type for determining if a message has been replied to, forwarded, etc. @@ -344,7 +344,7 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne nsIMsgDBHdr GetMessageHeader(in nsMsgKey msgKey); boolean shouldStoreMsgOffline(in nsMsgKey msgKey); boolean hasMsgOffline(in nsMsgKey msgKey); - nsITransport getOfflineFileTransport(in nsMsgKey msgKey, out PRUint32 offset, out PRUint32 size); + nsIFileChannel getOfflineFileChannel(in nsMsgKey msgKey); void DownloadMessagesForOffline(in nsISupportsArray messages); nsIMsgFolder getChildWithURI(in string uri, in boolean deep); void downloadAllForOffline(in nsIUrlListener listener, in nsIMsgWindow window); diff --git a/mozilla/mailnews/base/src/nsCopyMessageStreamListener.cpp b/mozilla/mailnews/base/src/nsCopyMessageStreamListener.cpp index 9b86f290a96..475ee920e7a 100644 --- a/mozilla/mailnews/base/src/nsCopyMessageStreamListener.cpp +++ b/mozilla/mailnews/base/src/nsCopyMessageStreamListener.cpp @@ -131,14 +131,14 @@ NS_IMETHODIMP nsCopyMessageStreamListener::EndMessage(nsMsgKey key) } -NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIRequest * /* request */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) +NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { nsresult rv; rv = mDestination->CopyData(aIStream, aLength); return rv; } -NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest * request, nsISupports *ctxt) +NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) { nsCOMPtr message; nsresult rv = NS_OK; @@ -154,7 +154,7 @@ NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest * request, return rv; } -NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { nsresult rv = NS_OK; nsCOMPtr uri = do_QueryInterface(ctxt, &rv); diff --git a/mozilla/mailnews/base/src/nsMessenger.cpp b/mozilla/mailnews/base/src/nsMessenger.cpp index b9285c49357..c47c67577a2 100644 --- a/mozilla/mailnews/base/src/nsMessenger.cpp +++ b/mozilla/mailnews/base/src/nsMessenger.cpp @@ -1595,7 +1595,7 @@ nsSaveMsgListener::OnStopCopy(nsresult aStatus) } NS_IMETHODIMP -nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport) +nsSaveMsgListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aSupport) { nsresult rv = NS_OK; if (m_fileSpec) @@ -1612,7 +1612,7 @@ nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport) } NS_IMETHODIMP -nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport, +nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport, nsresult status, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -1710,7 +1710,7 @@ nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport, } NS_IMETHODIMP -nsSaveMsgListener::OnDataAvailable(nsIRequest* request, +nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel, nsISupports* aSupport, nsIInputStream* inStream, PRUint32 srcOffset, diff --git a/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp b/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp index c6ed32aea61..d6c7170f0eb 100644 --- a/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp +++ b/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp @@ -281,7 +281,7 @@ nsFolderCompactState::GetMessage(nsIMessage **message) NS_IMETHODIMP -nsFolderCompactState::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +nsFolderCompactState::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { nsresult rv = NS_ERROR_FAILURE; NS_ASSERTION(m_fileStream, "Fatal, null m_fileStream...\n"); @@ -296,7 +296,7 @@ nsFolderCompactState::OnStartRequest(nsIRequest *request, nsISupports *ctxt) } NS_IMETHODIMP -nsFolderCompactState::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +nsFolderCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { @@ -355,7 +355,7 @@ done: } NS_IMETHODIMP -nsFolderCompactState::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +nsFolderCompactState::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { @@ -397,7 +397,7 @@ nsOfflineStoreCompactState::InitDB(nsIMsgDatabase *db) } NS_IMETHODIMP -nsOfflineStoreCompactState::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +nsOfflineStoreCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { diff --git a/mozilla/mailnews/base/src/nsMsgFolderCompactor.h b/mozilla/mailnews/base/src/nsMsgFolderCompactor.h index f38ddce0f96..965c537cc15 100644 --- a/mozilla/mailnews/base/src/nsMsgFolderCompactor.h +++ b/mozilla/mailnews/base/src/nsMsgFolderCompactor.h @@ -72,7 +72,7 @@ public: virtual ~nsOfflineStoreCompactState(void); virtual nsresult InitDB(nsIMsgDatabase *db); - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); NS_IMETHODIMP FinishCompact(); diff --git a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp index 33fd24cbade..add6c20c352 100644 --- a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp +++ b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp @@ -96,7 +96,7 @@ nsMsgPrintEngine::OnStartDocumentLoad(nsIDocumentLoader *aLoader, nsIURI *aURL, } NS_IMETHODIMP -nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *request, PRUint32 aStatus) +nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChannel, PRUint32 aStatus) { // Now, fire off the print operation! nsresult rv = NS_ERROR_FAILURE; @@ -107,12 +107,10 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *reque PR_FREEIF(msg); NS_ASSERTION(mDocShell,"can't print, there is no docshell"); - if ( (!mDocShell) || (!request) ) + if ( (!mDocShell) || (!aChannel) ) { return StartNextPrintOperation(); } - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; // Make sure this isn't just "about:blank" finishing.... nsCOMPtr originalURI = nsnull; @@ -160,25 +158,25 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *reque } NS_IMETHODIMP -nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request) +nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIChannel *channel) { return NS_OK; } NS_IMETHODIMP -nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) +nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP -nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIRequest *request, nsString & aMsg) +nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIChannel *channel, nsString & aMsg) { return NS_OK; } NS_IMETHODIMP -nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aStatus) +nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, PRUint32 aStatus) { return NS_OK; } diff --git a/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp b/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp index 177609aed77..5d84e3b9be1 100644 --- a/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp +++ b/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp @@ -245,15 +245,15 @@ NS_IMETHODIMP nsMsgStatusFeedback::SetDocShell(nsIDocShell *shell, nsIDOMWindowI return NS_OK; } -NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIRequest *request, nsISupports* ctxt, +NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIChannel* channel, nsISupports* ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { // XXX: What should the nsIWebProgress be? - return OnProgressChange(nsnull, request, aProgress, aProgressMax, + return OnProgressChange(nsnull, channel, aProgress, aProgressMax, aProgress /* current total progress */, aProgressMax /* max total progress */); } -NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, nsISupports* ctxt, +NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIChannel* channel, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; diff --git a/mozilla/mailnews/base/src/nsMsgWindow.cpp b/mozilla/mailnews/base/src/nsMsgWindow.cpp index ec0b742cc52..51d366b3951 100644 --- a/mozilla/mailnews/base/src/nsMsgWindow.cpp +++ b/mozilla/mailnews/base/src/nsMsgWindow.cpp @@ -398,7 +398,7 @@ NS_IMETHODIMP nsMsgWindow::GetProtocolHandler(nsIURI * /* aURI */, nsIProtocolHa } NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, - nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) + nsIChannel *aChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { if (aContentType) { @@ -408,9 +408,6 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand nsCOMPtr ctnListener = do_QueryInterface(messageWindowDocShell); if (ctnListener) { - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; - // get the url for the channel...let's hope it is a mailnews url so we can set our msg hdr sink on it.. // right now, this is the only way I can think of to force the msg hdr sink into the mime converter so it can // get too it later... @@ -422,7 +419,7 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand if (mailnewsUrl) mailnewsUrl->SetMsgWindow(this); } - return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, request, aContentHandler, aAbortProcess); + return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, aChannel, aContentHandler, aAbortProcess); } } return NS_OK; diff --git a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp index d0dfcfed6d4..d2bcb652d5a 100644 --- a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp @@ -35,8 +35,6 @@ #include "nsLocalFolderSummarySpec.h" #include "nsIFileStream.h" #include "nsIChannel.h" -#include "nsITransport.h" -#include "nsIFileTransportService.h" #include "nsIMsgFolderCompactor.h" #if defined(XP_OS2) #define MAX_FILE_LENGTH_WITHOUT_EXTENSION 8 @@ -589,12 +587,10 @@ nsresult nsMsgDBFolder::GetOfflineStoreInputStream(nsIInputStream **stream) return rv; } -NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *offset, PRUint32 *size, nsITransport **aFileChannel) +NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel) { NS_ENSURE_ARG(aFileChannel); - *offset = *size = 0; - nsresult rv; rv = nsComponentManager::CreateInstance(NS_LOCALFILECHANNEL_CONTRACTID, nsnull, @@ -608,14 +604,7 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 * rv = NS_NewLocalFile(nativePath, PR_TRUE, getter_AddRefs(localStore)); if (NS_SUCCEEDED(rv) && localStore) { - NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); - NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); - - if (NS_FAILED(rv)) - return rv; - - rv = fts->CreateTransport(localStore, PR_RDWR | PR_CREATE_FILE, 0664, aFileChannel); - + rv = (*aFileChannel)->Init(localStore, PR_CREATE_FILE | PR_RDWR, 0); if (NS_SUCCEEDED(rv)) { @@ -623,8 +612,12 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 * rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(hdr)); if (hdr && NS_SUCCEEDED(rv)) { - hdr->GetMessageOffset(offset); - hdr->GetOfflineMessageSize(size); + PRUint32 messageOffset; + PRUint32 messageSize; + hdr->GetMessageOffset(&messageOffset); + hdr->GetOfflineMessageSize(&messageSize); + (*aFileChannel)->SetTransferOffset(messageOffset); + (*aFileChannel)->SetTransferCount(messageSize); } } } @@ -644,6 +637,11 @@ nsresult nsMsgDBFolder::GetOfflineStoreOutputStream(nsIOutputStream **outputStre nsCOMPtr fileChannel = do_CreateInstance(NS_LOCALFILECHANNEL_CONTRACTID); if (fileChannel) { + PRUint32 fileSize = 0; + nsXPIDLCString nativePath; + mPath->GetNativePath(getter_Copies(nativePath)); + + mPath->GetFileSize(&fileSize); nsCOMPtr localStore; rv = NS_NewLocalFile(nativePath, PR_TRUE, getter_AddRefs(localStore)); if (NS_SUCCEEDED(rv) && localStore) @@ -651,7 +649,8 @@ nsresult nsMsgDBFolder::GetOfflineStoreOutputStream(nsIOutputStream **outputStre rv = fileChannel->Init(localStore, PR_CREATE_FILE | PR_RDWR, 0); if (NS_FAILED(rv)) return rv; - rv = fileChannel->Open(outputStream); + fileChannel->SetTransferOffset(fileSize); + rv = fileChannel->OpenOutputStream(outputStream); if (NS_FAILED(rv)) return rv; } @@ -697,6 +696,7 @@ nsresult nsMsgDBFolder::CreatePlatformLeafNameForDisk(const char *userLeafName, // (c) does not already exist on the disk // then we simply return nsCRT::strdup(userLeafName) // Otherwise we mangle it + // mangledPath is the entire path to the newly mangled leaf name nsCAutoString mangledLeaf(userLeafName); diff --git a/mozilla/mailnews/base/util/nsMsgDBFolder.h b/mozilla/mailnews/base/util/nsMsgDBFolder.h index 87ab859fba0..7c43ceda81e 100644 --- a/mozilla/mailnews/base/util/nsMsgDBFolder.h +++ b/mozilla/mailnews/base/util/nsMsgDBFolder.h @@ -33,7 +33,7 @@ #include "nsIUrlListener.h" #include "nsIMsgHdr.h" #include "nsIOutputStream.h" -#include "nsITransport.h" + class nsIMsgFolderCacheElement; /* @@ -93,7 +93,7 @@ public: NS_IMETHOD SetGettingNewMessages(PRBool gettingNewMessages); NS_IMETHOD ShouldStoreMsgOffline(nsMsgKey msgKey, PRBool *result); - NS_IMETHOD GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *offset, PRUint32 *size, nsITransport **_retval); + NS_IMETHOD GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel); NS_IMETHOD HasMsgOffline(nsMsgKey msgKey, PRBool *result); NS_IMETHOD DownloadMessagesForOffline(nsISupportsArray *messages); NS_IMETHOD DownloadAllForOffline(nsIUrlListener *listener, nsIMsgWindow *msgWindow); diff --git a/mozilla/mailnews/base/util/nsMsgFolder.cpp b/mozilla/mailnews/base/util/nsMsgFolder.cpp index ced1753a696..e138956e900 100644 --- a/mozilla/mailnews/base/util/nsMsgFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgFolder.cpp @@ -2456,7 +2456,6 @@ NS_IMETHODIMP nsMsgFolder::EnableNotifications(PRInt32 notificationType, PRBool // we're probably doing something that should be batched. nsCOMPtr database; - nsresult rv = GetMsgDatabase(nsnull, getter_AddRefs(database)); if(enable) { diff --git a/mozilla/mailnews/base/util/nsMsgProtocol.cpp b/mozilla/mailnews/base/util/nsMsgProtocol.cpp index 89148e7b9f3..409c2bdb288 100644 --- a/mozilla/mailnews/base/util/nsMsgProtocol.cpp +++ b/mozilla/mailnews/base/util/nsMsgProtocol.cpp @@ -28,9 +28,7 @@ #include "nsSpecialSystemDirectory.h" #include "nsILoadGroup.h" #include "nsIIOService.h" -#include "nsNetUtil.h" #include "nsFileStream.h" -#include "nsIFileTransportService.h" #include "nsINetSupportDialogService.h" #include "nsIDNSService.h" #include "nsIMsgWindow.h" @@ -39,11 +37,7 @@ static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID); static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); -NS_IMPL_ISUPPORTS4(nsMsgProtocol, - nsIStreamListener, - nsIStreamObserver, - nsIChannel, - nsIRequest) +NS_IMPL_ISUPPORTS3(nsMsgProtocol, nsIStreamListener, nsIStreamObserver, nsIChannel) nsMsgProtocol::nsMsgProtocol(nsIURI * aURL) { @@ -89,7 +83,7 @@ nsresult nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName, PRInt3 m_readCount = -1; // with socket connections we want to read as much data as arrives m_startPosition = 0; - rv = socketService->CreateTransportOfType(connectionType, aHostName, aGetPort, nsnull, -1, 0, 0, getter_AddRefs(m_transport)); + rv = socketService->CreateTransportOfType(connectionType, aHostName, aGetPort, nsnull, -1, 0, 0, getter_AddRefs(m_channel)); if (NS_FAILED(rv)) return rv; m_socketIsOpen = PR_FALSE; @@ -126,28 +120,11 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSp aURL->GetPath(getter_Copies(filePath)); char * urlSpec = PR_smprintf("file://%s", (const char *) filePath); -// dougt - there should be an easier way! - nsCOMPtr aIURI; - if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(aIURI), urlSpec))) - return(PR_FALSE); - if (!aIURI) return(PR_FALSE); - - nsCOMPtr fileURL = do_QueryInterface(aIURI); - if (!fileURL) return(PR_FALSE); - - nsCOMPtr file; - rv = fileURL->GetFile(getter_AddRefs(file)); - if (NS_FAILED(rv)) return(PR_FALSE); -// dougt - - NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); - NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); - if (NS_FAILED(rv)) return PR_FALSE; - - rv = fts->CreateTransport(file, PR_RDWR | PR_CREATE_FILE, - 0664, getter_AddRefs(m_transport)); + rv = netService->NewChannel(urlSpec, + nsnull, // null base URI + getter_AddRefs(m_channel)); PR_FREEIF(urlSpec); - m_socketIsOpen = PR_FALSE; + m_socketIsOpen = PR_FALSE; } return rv; @@ -157,9 +134,9 @@ nsresult nsMsgProtocol::SetupTransportState() { nsresult rv = NS_OK; - if (!m_socketIsOpen && m_transport) + if (!m_socketIsOpen && m_channel) { - rv = m_transport->OpenOutputStream(0, -1, 0, getter_AddRefs(m_outputStream)); + rv = m_channel->OpenOutputStream(getter_AddRefs(m_outputStream)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create an output stream"); // we want to open the stream @@ -177,11 +154,10 @@ nsresult nsMsgProtocol::CloseSocket() m_outputStream = null_nsCOMPtr(); // we need to call Cancel so that we remove the socket transport from the mActiveTransportList. see bug #30648 - if (m_request) { - rv = m_request->Cancel(NS_BINDING_ABORTED); + if (m_channel) { + rv = m_channel->Cancel(NS_BINDING_ABORTED); } - m_request = 0; - m_transport = 0; + m_channel = null_nsCOMPtr(); return rv; } @@ -211,14 +187,14 @@ PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool a // Whenever data arrives from the connection, core netlib notifices the protocol by calling // OnDataAvailable. We then read and process the incoming data from the input stream. -NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) +NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { // right now, this really just means turn around and churn through the state machine nsCOMPtr uri = do_QueryInterface(ctxt); return ProcessProtocolState(uri, inStr, sourceOffset, count); } -NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) { nsresult rv = NS_OK; nsCOMPtr aMsgUrl = do_QueryInterface(ctxt, &rv); @@ -226,7 +202,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ct { rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK); if (m_loadGroup) - m_loadGroup->AddRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull /* context isupports */); + m_loadGroup->AddChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull /* context isupports */); } // if we are set up as a channel, we should notify our channel listener that we are starting... @@ -243,7 +219,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ct } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -258,7 +234,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctx { rv = msgUrl->SetUrlState(PR_FALSE, aStatus); if (m_loadGroup) - m_loadGroup->RemoveRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull, aStatus, nsnull); + m_loadGroup->RemoveChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull, aStatus, nsnull); // !NS_BINDING_ABORTED because we don't want to see an alert if the user // cancelled the operation. also, we'll get here because we call Cancel() @@ -336,10 +312,19 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer) if (!m_socketIsOpen) { nsCOMPtr urlSupports = do_QueryInterface(aURL); - if (m_transport) + if (m_channel) { + // XXX should these errors be returned?: + if (m_startPosition > 0) + { + rv = m_channel->SetTransferOffset(m_startPosition); + NS_ASSERTION(NS_SUCCEEDED(rv), "SetTransferOffset failed"); + } + rv = m_channel->SetTransferCount(m_readCount); + NS_ASSERTION(NS_SUCCEEDED(rv), "SetTransferCount failed"); + // put us in a state where we are always notified of incoming data - rv = m_transport->AsyncRead(this, urlSupports, m_startPosition, m_readCount, 0, getter_AddRefs(m_request)); + rv = m_channel->AsyncRead(this /* stream observer */, urlSupports); NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed"); m_socketIsOpen = PR_TRUE; // mark the channel as open } @@ -393,13 +378,19 @@ NS_IMETHODIMP nsMsgProtocol::SetURI(nsIURI* aURI) return NS_OK; } -NS_IMETHODIMP nsMsgProtocol::Open(nsIInputStream **_retval) +NS_IMETHODIMP nsMsgProtocol::OpenInputStream(nsIInputStream **_retval) { - NS_NOTREACHED("Open"); + NS_NOTREACHED("OpenInputStream"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsMsgProtocol::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsMsgProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { // set the stream listener and then load the url m_channelContext = ctxt; @@ -426,6 +417,12 @@ NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports return LoadUrl(m_url, nsnull); } +NS_IMETHODIMP nsMsgProtocol::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +{ + NS_NOTREACHED("AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsMsgProtocol::GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = mLoadAttributes; @@ -464,18 +461,6 @@ NS_IMETHODIMP nsMsgProtocol::GetContentLength(PRInt32 * aContentLength) return NS_OK; } -NS_IMETHODIMP nsMsgProtocol::GetSecurityInfo(nsISupports * *aSecurityInfo) -{ - *aSecurityInfo = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsMsgProtocol::GetName(PRUnichar * *aName) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - - NS_IMETHODIMP nsMsgProtocol::SetContentLength(PRInt32 aContentLength) { @@ -483,6 +468,83 @@ nsMsgProtocol::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsMsgProtocol::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::GetLocalFile(nsIFile* *file) +{ + NS_NOTREACHED("GetLocalFile"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMsgProtocol::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsMsgProtocol::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsMsgProtocol::GetOwner(nsISupports * *aPrincipal) { *aPrincipal = mOwner; @@ -529,10 +591,26 @@ nsMsgProtocol::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCall return NS_OK; } + +NS_IMETHODIMP +nsMsgProtocol::GetSecurityInfo(nsISupports * *aSecurityInfo) +{ + *aSecurityInfo = nsnull; + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // From nsIRequest //////////////////////////////////////////////////////////////////////////////// +NS_IMETHODIMP nsMsgProtocol::GetName(PRUnichar* *result) +{ + if (m_channel) + return m_channel->GetName(result); + NS_NOTREACHED("nsMsgProtocol::GetName"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsMsgProtocol::IsPending(PRBool *result) { *result = PR_TRUE; @@ -541,8 +619,8 @@ NS_IMETHODIMP nsMsgProtocol::IsPending(PRBool *result) NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status) { - if (m_request) - return m_request->GetStatus(status); + if (m_channel) + return m_channel->GetStatus(status); *status = NS_ERROR_FAILURE; return *status; @@ -550,12 +628,12 @@ NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status) NS_IMETHODIMP nsMsgProtocol::Cancel(nsresult status) { - NS_ASSERTION(m_request,"no channel"); - if (!m_request) { + NS_ASSERTION(m_channel,"no channel"); + if (!m_channel) { return NS_ERROR_FAILURE; } - return m_request->Cancel(status); + return m_channel->Cancel(status); } NS_IMETHODIMP nsMsgProtocol::Suspend() diff --git a/mozilla/mailnews/base/util/nsMsgProtocol.h b/mozilla/mailnews/base/util/nsMsgProtocol.h index cce8339153e..abe2ac0cf75 100644 --- a/mozilla/mailnews/base/util/nsMsgProtocol.h +++ b/mozilla/mailnews/base/util/nsMsgProtocol.h @@ -33,7 +33,7 @@ #include "nsIFileSpec.h" #include "nsIInterfaceRequestor.h" #include "nsIProgressEventSink.h" -#include "nsITransport.h" + class nsIPrompt; class nsIMsgMailNewsUrl; @@ -42,9 +42,7 @@ class nsIMsgMailNewsUrl; // it unifies the core networking code for the protocols. My hope is that // this will make unification with Necko easier as we'll only have to change // this class and not all of the mailnews protocols. -class NS_MSG_BASE nsMsgProtocol -: public nsIStreamListener, - public nsIChannel +class NS_MSG_BASE nsMsgProtocol : public nsIStreamListener, public nsIChannel { public: nsMsgProtocol(nsIURI * aURL); @@ -103,10 +101,8 @@ protected: virtual nsresult InitFromURI(nsIURI *aUrl); // Ouput stream for writing commands to the socket - nsCOMPtr m_transport; - nsCOMPtr m_request; - - nsCOMPtr m_outputStream; // this will be obtained from the transport interface + nsCOMPtr m_channel; + nsCOMPtr m_outputStream; // this will be obtained from the transport interface PRBool m_socketIsOpen; // mscott: we should look into keeping this state in the nsSocketTransport... // I'm using it to make sure I open the socket the first time a URL is loaded into the connection diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.cpp b/mozilla/mailnews/compose/src/nsMsgCompose.cpp index 904b2a0e23e..e0f0fffd97d 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -1168,12 +1168,12 @@ QuotingOutputStreamListener::ConvertToPlainText(PRBool formatflowed /* = PR_FALS return rv; } -NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIRequest *request, nsISupports * /* ctxt */) +NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */) { return NS_OK; } -NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */) +NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */) { nsresult rv = NS_OK; nsAutoString aCharset; @@ -1369,7 +1369,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns return rv; } -NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIRequest *request, +NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { diff --git a/mozilla/mailnews/compose/src/nsMsgComposeContentHandler.cpp b/mozilla/mailnews/compose/src/nsMsgComposeContentHandler.cpp index 8e92c30f8c6..2b054dd0593 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeContentHandler.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeContentHandler.cpp @@ -42,18 +42,15 @@ nsMsgComposeContentHandler::~nsMsgComposeContentHandler() } NS_IMETHODIMP nsMsgComposeContentHandler::HandleContent(const char * aContentType, const char * aCommand, - const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request) + const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel) { nsresult rv = NS_OK; - if (!request) + if (!aChannel) return NS_ERROR_NULL_POINTER; // First of all, get the content type and make sure it is a content type we know how to handle! if (nsCRT::strcasecmp(aContentType, "x-application-mailto") == 0) { nsCOMPtr aUri; - nsCOMPtr aChannel = do_QueryInterface(request); - if(!aChannel) return NS_ERROR_FAILURE; - rv = aChannel->GetURI(getter_AddRefs(aUri)); if (aUri) { diff --git a/mozilla/mailnews/compose/src/nsMsgQuote.cpp b/mozilla/mailnews/compose/src/nsMsgQuote.cpp index 81c6b1cbdc2..0dddb0a4038 100644 --- a/mozilla/mailnews/compose/src/nsMsgQuote.cpp +++ b/mozilla/mailnews/compose/src/nsMsgQuote.cpp @@ -220,7 +220,7 @@ nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, PRBool quoteHeaders, nsIStream if (NS_FAILED(rv)) return rv; // now try to open the channel passing in our display consumer as the listener - rv = mQuoteChannel->AsyncOpen(convertedListener, ctxt); + rv = mQuoteChannel->AsyncRead(convertedListener, ctxt); ReleaseMessageServiceFromURI(aMsgUri, msgService); return rv; diff --git a/mozilla/mailnews/compose/src/nsMsgSendLater.cpp b/mozilla/mailnews/compose/src/nsMsgSendLater.cpp index cbd8f6c91de..f2252e86c35 100644 --- a/mozilla/mailnews/compose/src/nsMsgSendLater.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSendLater.cpp @@ -141,7 +141,7 @@ nsMsgSendLater::~nsMsgSendLater() // Stream is done...drive on! nsresult -nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) +nsMsgSendLater::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsresult rv; @@ -179,9 +179,6 @@ nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult s } else { - nsCOMPtr channel = do_QueryInterface(request); - if(!channel) return NS_ERROR_FAILURE; - // extract the prompt object to use for the alert from the url.... nsCOMPtr uri; nsCOMPtr promptObject; @@ -263,7 +260,7 @@ nsMsgSendLater::BuildNewBuffer(const char* aBuf, PRUint32 aCount, PRUint32 *tota // Got data? nsresult -nsMsgSendLater::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) +nsMsgSendLater::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { // This is a little bit tricky since we have to chop random // buffers into lines and deliver the lines...plus keeping the @@ -319,7 +316,7 @@ nsMsgSendLater::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInput } nsresult -nsMsgSendLater::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +nsMsgSendLater::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsSmtpProtocol.cpp b/mozilla/mailnews/compose/src/nsSmtpProtocol.cpp index 85422ecf773..334a77bc649 100644 --- a/mozilla/mailnews/compose/src/nsSmtpProtocol.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpProtocol.cpp @@ -391,7 +391,7 @@ const char * nsSmtpProtocol::GetUserDomainName() //////////////////////////////////////////////////////////////////////////////////////////// // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { nsMsgProtocol::OnStopRequest(nsnull, ctxt, aStatus, aMsg); @@ -765,8 +765,7 @@ PRInt32 nsSmtpProtocol::SendTLSResponse() { nsCOMPtr secInfo; - nsCOMPtr channel = do_QueryInterface(m_request); - rv = channel->GetSecurityInfo(getter_AddRefs(secInfo)); + rv = m_channel->GetSecurityInfo(getter_AddRefs(secInfo)); if (NS_SUCCEEDED(rv) && secInfo) { nsCOMPtr sslControl = do_QueryInterface(secInfo, &rv); diff --git a/mozilla/mailnews/compose/src/nsSmtpProtocol.h b/mozilla/mailnews/compose/src/nsSmtpProtocol.h index 8723b53db60..6e5c961aa0f 100644 --- a/mozilla/mailnews/compose/src/nsSmtpProtocol.h +++ b/mozilla/mailnews/compose/src/nsSmtpProtocol.h @@ -117,7 +117,7 @@ public: //////////////////////////////////////////////////////////////////////////////////////// // stop binding is a "notification" informing us that the stream associated with aURL is going away. - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); private: // logon redirection related variables and methods diff --git a/mozilla/mailnews/compose/src/nsSmtpService.cpp b/mozilla/mailnews/compose/src/nsSmtpService.cpp index 6841c2cabd6..7065f478e1c 100644 --- a/mozilla/mailnews/compose/src/nsSmtpService.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpService.cpp @@ -251,7 +251,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSICHANNEL NS_DECL_NSIREQUEST - + nsMailtoChannel(nsIURI * aURI); virtual ~nsMailtoChannel(); @@ -293,6 +293,13 @@ NS_IMETHODIMP nsMailtoChannel::SetNotificationCallbacks(nsIInterfaceRequestor* a return NS_OK; // don't fail when trying to set this } +NS_IMETHODIMP +nsMailtoChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +{ + *aSecurityInfo = nsnull; + return NS_OK; +} + NS_IMETHODIMP nsMailtoChannel::GetOriginalURI(nsIURI* *aURI) { *aURI = nsnull; @@ -317,17 +324,29 @@ NS_IMETHODIMP nsMailtoChannel::SetURI(nsIURI* aURI) return NS_OK; } -NS_IMETHODIMP nsMailtoChannel::Open(nsIInputStream **_retval) +NS_IMETHODIMP nsMailtoChannel::OpenInputStream(nsIInputStream **_retval) { - NS_NOTREACHED("Open"); + NS_NOTREACHED("OpenInputStream"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsMailtoChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsMailtoChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsMailtoChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { return listener->OnStartRequest(this, ctxt); } +NS_IMETHODIMP nsMailtoChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +{ + NS_NOTREACHED("AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsMailtoChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) { return NS_ERROR_NOT_IMPLEMENTED; @@ -363,6 +382,83 @@ nsMailtoChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsMailtoChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::GetLocalFile(nsIFile* *file) +{ + NS_NOTREACHED("GetLocalFile"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMailtoChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsMailtoChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsMailtoChannel::GetOwner(nsISupports * *aPrincipal) { NS_NOTREACHED("GetOwner"); @@ -375,19 +471,13 @@ NS_IMETHODIMP nsMailtoChannel::SetOwner(nsISupports * aPrincipal) return NS_ERROR_NOT_IMPLEMENTED; } -/* readonly attribute nsISupports securityInfo; */ -NS_IMETHODIMP nsMailtoChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - //////////////////////////////////////////////////////////////////////////////// // From nsIRequest //////////////////////////////////////////////////////////////////////////////// -/* readonly attribute wstring name; */ -NS_IMETHODIMP nsMailtoChannel::GetName(PRUnichar * *aName) +NS_IMETHODIMP nsMailtoChannel::GetName(PRUnichar* *result) { + NS_NOTREACHED("nsMailtoChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } @@ -421,6 +511,7 @@ NS_IMETHODIMP nsMailtoChannel::Resume() return NS_ERROR_NOT_IMPLEMENTED; } + // the smtp service is also the protocol handler for mailto urls.... NS_IMETHODIMP nsSmtpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval) @@ -778,7 +869,7 @@ nsSmtpService::findServerByHostname(nsISupports *element, void *aData) rv = server->GetHostname(getter_Copies(hostname)); if (NS_FAILED(rv)) return PR_TRUE; - nsXPIDLCString username; + nsXPIDLCString username; rv = server->GetUsername(getter_Copies(username)); if (NS_FAILED(rv)) return PR_TRUE; diff --git a/mozilla/mailnews/compose/src/nsURLFetcher.cpp b/mozilla/mailnews/compose/src/nsURLFetcher.cpp index 984bf09e322..23817cd4c80 100644 --- a/mozilla/mailnews/compose/src/nsURLFetcher.cpp +++ b/mozilla/mailnews/compose/src/nsURLFetcher.cpp @@ -162,7 +162,7 @@ NS_IMETHODIMP nsURLFetcher::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIRequest *request, + nsIChannel * aOpenedChannel, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { @@ -230,7 +230,7 @@ nsURLFetcher::StillRunning(PRBool *running) // Methods for nsIStreamListener... nsresult -nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream, +nsURLFetcher::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { PRUint32 readLen = aLength; @@ -263,13 +263,13 @@ nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputS // Methods for nsIStreamObserver nsresult -nsURLFetcher::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +nsURLFetcher::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt) { return NS_OK; } nsresult -nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) +nsURLFetcher::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) { #ifdef NS_DEBUG_rhp printf("nsURLFetcher::OnStopRequest()\n"); @@ -294,30 +294,29 @@ nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsres mOutStream = nsnull; } - // Check the content type! - char *contentType = nsnull; - char *charset = nsnull; - - nsCOMPtr aChannel = do_QueryInterface(request); - if(!aChannel) return NS_ERROR_FAILURE; - - if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType) + if (aChannel) { - if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE)) - { - mContentType = contentType; - } - } + char *contentType = nsnull; + char *charset = nsnull; - nsCOMPtr httpChannel = do_QueryInterface(aChannel); - if (httpChannel) - { - if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset) + if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType) { - mCharset = charset; + if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE)) + { + mContentType = contentType; + } } - } + + nsCOMPtr httpChannel = do_QueryInterface(aChannel); + if (httpChannel) + { + if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset) + { + mCharset = charset; + } + } + } // Now if there is a callback, we need to call it... if (mCallback) @@ -403,7 +402,10 @@ nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, // the url.... if (NS_FAILED(aStatus)) - OnStopRequest(aRequest, nsnull, aStatus, nsnull); + { + nsCOMPtr channel (do_QueryInterface(aRequest)); + OnStopRequest(channel, nsnull, aStatus, nsnull); + } return NS_OK; } diff --git a/mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp b/mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp index 933d512eb85..e5c146ef7c4 100644 --- a/mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp +++ b/mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp @@ -28,7 +28,7 @@ #include "nsHashtable.h" #include "nsMimeTypes.h" #include "nsIPref.h" -#include "nsITransport.h" + static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); diff --git a/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp b/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp index 874ff15ffdb..e483c54d7d9 100644 --- a/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp @@ -478,10 +478,7 @@ nsImapIncomingServer::LoadNextQueuedUrl(PRBool *aResult) if (NS_SUCCEEDED(aImapUrl->GetMockChannel(getter_AddRefs(mockChannel))) && mockChannel) { - nsCOMPtr request = do_QueryInterface(mockChannel); - if (!request) - return NS_ERROR_FAILURE; - request->GetStatus(&rv); + mockChannel->GetStatus(&rv); if (!NS_SUCCEEDED(rv)) { nsresult res; diff --git a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp index 7a8f30ec70f..02db955069c 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -1033,7 +1033,7 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *msgWindow, if (empytingOnExit) { nsCOMPtr imapServer; - rv = GetImapIncomingServer(getter_AddRefs(imapServer)); + nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer)); if (NS_SUCCEEDED(rv) && imapServer) { @@ -3644,18 +3644,18 @@ nsImapMailFolder::SetContentModified(nsIImapUrl *aImapUrl, nsImapContentModified // to hook up the mock channel and other stuff when downloading messages for offline use. // But we don't really need to do anything with these notifications because we use // the nsIImapMesageSink interfaces ParseAdoptedMessageLine and NormalEndMsgWriteStream -NS_IMETHODIMP nsImapMailFolder::OnDataAvailable(nsIRequest * /* request */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) +NS_IMETHODIMP nsImapMailFolder::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { nsresult rv = NS_OK; return rv; } -NS_IMETHODIMP nsImapMailFolder::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +NS_IMETHODIMP nsImapMailFolder::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) { return NS_OK; } -NS_IMETHODIMP nsImapMailFolder::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsImapMailFolder::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { return NS_OK; } @@ -4207,9 +4207,7 @@ nsresult nsImapMailFolder::DisplayStatusMsg(nsIImapUrl *aImapUrl, const PRUnicha mockChannel->GetProgressEventSink(getter_AddRefs(progressSink)); if (progressSink) { - nsCOMPtr request = do_QueryInterface(mockChannel); - if (!request) return NS_ERROR_FAILURE; - progressSink->OnStatus(request, nsnull, NS_OK, msg); // XXX i18n message + progressSink->OnStatus(mockChannel, nsnull, NS_OK, msg); // XXX i18n message } } return NS_OK; @@ -4272,12 +4270,9 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol, mockChannel->GetProgressEventSink(getter_AddRefs(progressSink)); if (progressSink) { - nsCOMPtr request = do_QueryInterface(mockChannel); - if (!request) return NS_ERROR_FAILURE; - - progressSink->OnProgress(request, nsnull, aInfo->currentProgress, aInfo->maxProgress); + progressSink->OnProgress(mockChannel, nsnull, aInfo->currentProgress, aInfo->maxProgress); if (aInfo->message) - progressSink->OnStatus(request, nsnull, NS_OK, aInfo->message); // XXX i18n message + progressSink->OnStatus(mockChannel, nsnull, NS_OK, aInfo->message); // XXX i18n message } diff --git a/mozilla/mailnews/imap/src/nsImapProtocol.cpp b/mozilla/mailnews/imap/src/nsImapProtocol.cpp index b8a68e7f2b3..1a272313af7 100644 --- a/mozilla/mailnews/imap/src/nsImapProtocol.cpp +++ b/mozilla/mailnews/imap/src/nsImapProtocol.cpp @@ -602,7 +602,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer) rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, -1, 0, 0, getter_AddRefs(m_channel)); if (NS_SUCCEEDED(rv)) - rv = m_channel->OpenOutputStream(0, -1, 0, getter_AddRefs(m_outputStream)); + rv = m_channel->OpenOutputStream(getter_AddRefs(m_outputStream)); } } // if m_runningUrl @@ -616,12 +616,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer) // Copy over the notification callbacks object from the mock channel nsCOMPtr callbacks; m_mockChannel->GetNotificationCallbacks(getter_AddRefs(callbacks)); - if (callbacks) { - nsCOMPtr progressSink; - (void)callbacks->GetInterface(NS_GET_IID(nsIProgressEventSink), - getter_AddRefs(progressSink)); - m_channel->SetProgressEventSink(progressSink); - } + m_channel->SetNotificationCallbacks(callbacks); // and if we have a cache entry that we are saving the message to, set the security info on it too. // since imap only uses the memory cache, passing this on is the right thing to do. @@ -1009,8 +1004,7 @@ PRBool nsImapProtocol::ProcessCurrentURL() if (!TestFlag(IMAP_CONNECTION_IS_OPEN) && m_channel) { - nsCOMPtr request; - m_channel->AsyncRead(this /* stream observer */, nsnull, 0,-1,0, getter_AddRefs(request)); + m_channel->AsyncRead(this /* stream observer */, nsnull); SetFlag(IMAP_CONNECTION_IS_OPEN); } #ifdef DEBUG_bienvenu @@ -1042,10 +1036,9 @@ PRBool nsImapProtocol::ProcessCurrentURL() // if we are set up as a channel, we should notify our channel listener that we are starting... // so pass in ourself as the channel and not the underlying socket or file channel the protocol // happens to be using - if (m_channelListener) { - nsCOMPtr request = do_QueryInterface(m_mockChannel); - m_channelListener->OnStartRequest(request, m_channelContext); - } + if (m_channelListener) + m_channelListener->OnStartRequest(m_mockChannel, m_channelContext); + // mscott - I believe whenever we get here that we will also have // a connection. Why? Because when we load the url we open the // connection if it isn't open already....However, if we haven't received @@ -1130,13 +1123,9 @@ PRBool nsImapProtocol::ProcessCurrentURL() // if we are set up as a channel, we should notify our channel listener that we are starting... // so pass in ourself as the channel and not the underlying socket or file channel the protocol // happens to be using - if (m_channelListener) - { - nsCOMPtr request = do_QueryInterface(m_mockChannel); - if (!request) return NS_ERROR_FAILURE; + if (m_channelListener) + rv = m_channelListener->OnStopRequest(m_mockChannel, m_channelContext, NS_OK, nsnull); - rv = m_channelListener->OnStopRequest(request, m_channelContext, NS_OK, nsnull); - } m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp SetFlag(IMAP_CLEAN_UP_URL_STATE); if (NS_SUCCEEDED(rv) && GetConnectionStatus() >= 0 && GetServerStateParser().LastCommandSuccessful() @@ -1200,7 +1189,7 @@ void nsImapProtocol::ParseIMAPandCheckForNewMail(const char* commandString, PRBo ///////////////////////////////////////////////////////////////////////////////////////////// // we suppport the nsIStreamListener interface //////////////////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) +NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { nsresult res = NS_OK; @@ -1224,7 +1213,7 @@ NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIRequest *request, nsISupports * return res; } -NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt) { // we used to change the url state here......but OnStartRequest only gets called // once....when the connnection is first build from necko...So we'll set the url @@ -1241,7 +1230,7 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIRequest *request, nsISupports *c } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) { PRBool killThread = PR_FALSE; @@ -2820,11 +2809,8 @@ nsImapProtocol::PostLineDownLoadEvent(msg_line_info *downloadLineDontDelete) { nsresult rv = m_channelOutputStream->Write(line, PL_strlen(line), &count); if (NS_SUCCEEDED(rv)) - { - nsCOMPtr request = do_QueryInterface(m_mockChannel); - m_channelListener->OnDataAvailable(request, m_channelContext, m_channelInputStream, 0, count); - } - // here is where we should echo the line to the local folder copy of an online message + m_channelListener->OnDataAvailable(m_mockChannel, m_channelContext, m_channelInputStream, 0, count); + // here is where we should echo the line to the local folder copy of an online message } if (m_imapMessageSink) m_imapMessageSink->GetNotifyDownloadedLines(&echoLineToMessageSink); @@ -3523,11 +3509,8 @@ PRBool nsImapProtocol::DeathSignalReceived() // ignore mock channel status if we've been pseudo interrupted // ### need to make sure we clear pseudo interrupted status appropriately. if (!GetPseudoInterrupted() && m_mockChannel) - { - nsCOMPtr request = do_QueryInterface(m_mockChannel); - if (request) - request->GetStatus(&returnValue); - } + m_mockChannel->GetStatus(&returnValue); + if (NS_SUCCEEDED(returnValue)) // check the other way of cancelling. { PR_EnterMonitor(m_threadDeathMonitor); @@ -6726,23 +6709,23 @@ nsresult nsImapCacheStreamListener::Init(nsIStreamListener * aStreamListener, ns } NS_IMETHODIMP -nsImapCacheStreamListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) +nsImapCacheStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) { nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->AddRequest(request, nsnull /* context isupports */); - return mListener->OnStartRequest(request, aCtxt); + loadGroup->AddChannel(mChannelToUse, nsnull /* context isupports */); + return mListener->OnStartRequest(mChannelToUse, aCtxt); } NS_IMETHODIMP -nsImapCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) +nsImapCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = mListener->OnStopRequest(request, aCtxt, aStatus, aMsg); + nsresult rv = mListener->OnStopRequest(mChannelToUse, aCtxt, aStatus, aMsg); nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->RemoveRequest(request, nsnull, aStatus, nsnull); + loadGroup->RemoveChannel(mChannelToUse, nsnull, aStatus, nsnull); mListener = nsnull; mChannelToUse = nsnull; @@ -6750,9 +6733,9 @@ nsImapCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtx } NS_IMETHODIMP -nsImapCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) +nsImapCacheStreamListener::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) { - return mListener->OnDataAvailable(request, aCtxt, aInStream, aSourceOffset, aCount); + return mListener->OnDataAvailable(mChannelToUse, aCtxt, aInStream, aSourceOffset, aCount); } NS_IMPL_THREADSAFE_ADDREF(nsImapMockChannel) @@ -6784,6 +6767,12 @@ NS_IMETHODIMP nsImapMockChannel::Close() return NS_OK; } +NS_IMETHODIMP nsImapMockChannel::SetSecurityInfo(nsISupports * aSecurityInfo) +{ + mSecurityInfo = aSecurityInfo; + return NS_OK; +} + NS_IMETHODIMP nsImapMockChannel::GetProgressEventSink(nsIProgressEventSink ** aProgressEventSink) { *aProgressEventSink = mProgressEventSink; @@ -6866,13 +6855,19 @@ NS_IMETHODIMP nsImapMockChannel::SetURI(nsIURI* aURI) return NS_OK; } -NS_IMETHODIMP nsImapMockChannel::Open(nsIInputStream **_retval) +NS_IMETHODIMP nsImapMockChannel::OpenInputStream(nsIInputStream **_retval) { - NS_NOTREACHED("nsImapMockChannel::Open"); + NS_NOTREACHED("nsImapMockChannel::OpenInputStream"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsImapMockChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("nsImapMockChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { nsCOMPtr cacheEntry; PRUint32 contentLength = 0; @@ -6940,16 +6935,15 @@ NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISuppo if (NS_SUCCEEDED(rv) && annotationLength == nsCRT::strlen("Not Modified") && annotation && !nsCRT::strncmp(annotation, "Not Modified", annotationLength)) { - nsCOMPtr cacheChannel; - rv = cacheEntry->NewTransport(m_loadGroup, getter_AddRefs(cacheChannel)); + nsCOMPtr cacheChannel; + rv = cacheEntry->NewChannel(m_loadGroup, getter_AddRefs(cacheChannel)); if (NS_SUCCEEDED(rv)) { // if we are going to read from the cache, then create a mock stream listener class and use it nsImapCacheStreamListener * cacheListener = new nsImapCacheStreamListener(); NS_ADDREF(cacheListener); cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this)); - nsCOMPtr request; - rv = cacheChannel->AsyncRead(cacheListener, m_channelContext, 0, -1, 0, getter_AddRefs(request)); + rv = cacheChannel->AsyncRead(cacheListener, m_channelContext); NS_RELEASE(cacheListener); if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return @@ -6966,6 +6960,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISuppo nsCOMPtr securityInfo; cacheEntry->GetSecurityInfo(getter_AddRefs(securityInfo)); SetSecurityInfo(securityInfo); + return rv; } } @@ -6984,17 +6979,14 @@ NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISuppo if (folder && NS_SUCCEEDED(rv)) { // we want to create a file channel and read the msg from there. - nsCOMPtr fileChannel; + nsCOMPtr fileChannel; nsMsgKey msgKey = atoi(messageIdString); - PRUint32 size, offset; - rv = folder->GetOfflineFileTransport(msgKey, &offset, &size, getter_AddRefs(fileChannel)); + rv = folder->GetOfflineFileChannel(msgKey, getter_AddRefs(fileChannel)); // get the file channel from the folder, somehow (through the message or // folder sink?) We also need to set the transfer offset to the message offset if (fileChannel && NS_SUCCEEDED(rv)) { - // dougt - This may break the ablity to "cancel" a read from offline mail reading. - // fileChannel->SetLoadGroup(m_loadGroup); - + fileChannel->SetLoadGroup(m_loadGroup); // force the url to remove its reference on the mock channel...this is to solve // a nasty reference counting problem... imapUrl->SetMockChannel(nsnull); @@ -7003,8 +6995,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISuppo nsImapCacheStreamListener * cacheListener = new nsImapCacheStreamListener(); NS_ADDREF(cacheListener); cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this)); - nsCOMPtr request; - rv = fileChannel->AsyncRead(cacheListener, m_channelContext, offset, size, 0, getter_AddRefs(request)); + rv = fileChannel->AsyncRead(cacheListener, m_channelContext); NS_RELEASE(cacheListener); if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return @@ -7040,6 +7031,12 @@ NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISuppo return rv; } +NS_IMETHODIMP nsImapMockChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +{ + NS_NOTREACHED("nsImapMockChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsImapMockChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) { //*aLoadAttributes = nsIChannel::LOAD_NORMAL; @@ -7081,6 +7078,83 @@ nsImapMockChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsImapMockChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsImapMockChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsImapMockChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsImapMockChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsImapMockChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsImapMockChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsImapMockChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsImapMockChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsImapMockChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::GetLocalFile(nsIFile* *file) +{ + NS_NOTREACHED("GetLocalFile"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsImapMockChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsImapMockChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsImapMockChannel::GetOwner(nsISupports * *aPrincipal) { *aPrincipal = mOwner; @@ -7094,22 +7168,13 @@ NS_IMETHODIMP nsImapMockChannel::SetOwner(nsISupports * aPrincipal) return NS_OK; } -NS_IMETHODIMP nsImapMockChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsImapMockChannel::SetSecurityInfo(nsISupports *aSecurityInfo) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - //////////////////////////////////////////////////////////////////////////////// // From nsIRequest //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsImapMockChannel::GetName(PRUnichar* *result) { + NS_NOTREACHED("nsImapMockChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } @@ -7169,3 +7234,10 @@ nsImapMockChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification return NS_OK; } +NS_IMETHODIMP +nsImapMockChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +{ + *aSecurityInfo = mSecurityInfo; + NS_IF_ADDREF(*aSecurityInfo); + return NS_OK; +} diff --git a/mozilla/mailnews/imap/src/nsImapProtocol.h b/mozilla/mailnews/imap/src/nsImapProtocol.h index fd490484520..31c54261f94 100644 --- a/mozilla/mailnews/imap/src/nsImapProtocol.h +++ b/mozilla/mailnews/imap/src/nsImapProtocol.h @@ -35,7 +35,6 @@ #include "nsString.h" #include "nsIProgressEventSink.h" #include "nsIInterfaceRequestor.h" -#include "nsITransport.h" // imap event sinks #include "nsIImapMailFolderSink.h" @@ -316,7 +315,7 @@ private: PRUint32 m_curReadIndex; // current read index // Ouput stream for writing commands to the socket - nsCOMPtr m_channel; + nsCOMPtr m_channel; nsCOMPtr m_outputStream; // this will be obtained from the transport interface nsCOMPtr m_inputStream; diff --git a/mozilla/mailnews/imap/src/nsImapService.cpp b/mozilla/mailnews/imap/src/nsImapService.cpp index bab084f2bb0..4fd8b105357 100644 --- a/mozilla/mailnews/imap/src/nsImapService.cpp +++ b/mozilla/mailnews/imap/src/nsImapService.cpp @@ -671,8 +671,8 @@ nsresult nsImapService::FetchMimePart(nsIImapUrl * aImapUrl, if (NS_FAILED(rv)) return rv; nsCOMPtr aCtxt = do_QueryInterface(url); - // now try to open the channel passing in our display consumer as the listener - rv = aChannel->AsyncOpen(aStreamListener, aCtxt); + // now try to open the channel passing in our display consumer as the listener + rv = aChannel->AsyncRead(aStreamListener, aCtxt); } else // do what we used to do before { @@ -1035,7 +1035,7 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl, nsCOMPtr aCtxt = do_QueryInterface(url); // now try to open the channel passing in our display consumer as the listener - rv = aChannel->AsyncOpen(aStreamListener, aCtxt); + rv = aChannel->AsyncRead(aStreamListener, aCtxt); } else // do what we used to do before { diff --git a/mozilla/mailnews/imap/src/nsImapUrl.cpp b/mozilla/mailnews/imap/src/nsImapUrl.cpp index 04a29bc2863..42658b31dd6 100644 --- a/mozilla/mailnews/imap/src/nsImapUrl.cpp +++ b/mozilla/mailnews/imap/src/nsImapUrl.cpp @@ -1132,8 +1132,7 @@ NS_IMETHODIMP nsImapUrl::AddChannelToLoadGroup() if (loadGroup) { - nsCOMPtr request = do_QueryInterface(m_mockChannel); - loadGroup->AddRequest(request, nsnull /* context isupports */); + loadGroup->AddChannel(m_mockChannel, nsnull /* context isupports */); } } return NS_OK; @@ -1151,8 +1150,7 @@ NS_IMETHODIMP nsImapUrl::RemoveChannel(nsresult status) GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) { - nsCOMPtr request = do_QueryInterface(m_mockChannel); - loadGroup->RemoveRequest(request, nsnull, status, nsnull); + loadGroup->RemoveChannel(m_mockChannel, nsnull, status, nsnull); } // break deadly embrace between mock channel and url SetMockChannel(nsnull); diff --git a/mozilla/mailnews/local/src/nsMailboxProtocol.cpp b/mozilla/mailnews/local/src/nsMailboxProtocol.cpp index 2ddb2af3415..16f0b922836 100644 --- a/mozilla/mailnews/local/src/nsMailboxProtocol.cpp +++ b/mozilla/mailnews/local/src/nsMailboxProtocol.cpp @@ -82,13 +82,11 @@ NS_IMETHODIMP nsMailboxProtocol::GetContentLength(PRInt32 * aContentLength) { // our file transport knows the entire length of the berkley mail folder // so get it from there. - if (!m_request) + if (m_channel) + return m_channel->GetContentLength(aContentLength); + else return NS_OK; - nsCOMPtr info = do_QueryInterface(m_request); - if (info) info->GetContentLength(aContentLength); - return NS_OK; - } else if (m_runningUrl) { @@ -146,7 +144,7 @@ void nsMailboxProtocol::Initialize(nsIURI * aURL) // we suppport the nsIStreamListener interface //////////////////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) { // extract the appropriate event sinks from the url and initialize them in our protocol data // the URL should be queried for a nsINewsURL. If it doesn't support a news URL interface then @@ -154,19 +152,19 @@ NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIRequest *request, nsISupports if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser) { // we need to inform our mailbox parser that it's time to start... - m_mailboxParser->OnStartRequest(request, ctxt); + m_mailboxParser->OnStartRequest(aChannel, ctxt); } - return nsMsgProtocol::OnStartRequest(request, ctxt); + return nsMsgProtocol::OnStartRequest(aChannel, ctxt); } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser) { // we need to inform our mailbox parser that there is no more incoming data... - m_mailboxParser->OnStopRequest(request, ctxt, aStatus, nsnull); + m_mailboxParser->OnStopRequest(aChannel, ctxt, aStatus, nsnull); } else if (m_nextState == MAILBOX_READ_MESSAGE) { @@ -198,7 +196,7 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, nsISupports */ if (aStatus == NS_BINDING_ABORTED) aStatus = NS_OK; - nsMsgProtocol::OnStopRequest(request, ctxt, aStatus, aMsg); + nsMsgProtocol::OnStopRequest(aChannel, ctxt, aStatus, aMsg); return CloseSocket(); } @@ -481,8 +479,8 @@ nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * case MAILBOX_DONE: case MAILBOX_ERROR_DONE: { - nsCOMPtr anotherUrl = do_QueryInterface(m_runningUrl); - anotherUrl->SetUrlState(PR_FALSE, m_nextState == MAILBOX_DONE ? + nsCOMPtr url = do_QueryInterface(m_runningUrl); + url->SetUrlState(PR_FALSE, m_nextState == MAILBOX_DONE ? NS_OK : NS_ERROR_FAILURE); m_nextState = MAILBOX_FREE; } diff --git a/mozilla/mailnews/local/src/nsMailboxProtocol.h b/mozilla/mailnews/local/src/nsMailboxProtocol.h index 18e1bc35cf2..236682848c0 100644 --- a/mozilla/mailnews/local/src/nsMailboxProtocol.h +++ b/mozilla/mailnews/local/src/nsMailboxProtocol.h @@ -76,8 +76,8 @@ public: // we suppport the nsIStreamListener interface //////////////////////////////////////////////////////////////////////////////////////// - NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg); + NS_IMETHOD OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt); + NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg); NS_IMETHOD GetContentLength(PRInt32 * aContentLength); private: @@ -127,9 +127,3 @@ private: }; #endif // nsMailboxProtocol_h___ - - - - - - diff --git a/mozilla/mailnews/local/src/nsParseMailbox.cpp b/mozilla/mailnews/local/src/nsParseMailbox.cpp index 3b1580aaba9..571414e65da 100644 --- a/mozilla/mailnews/local/src/nsParseMailbox.cpp +++ b/mozilla/mailnews/local/src/nsParseMailbox.cpp @@ -62,7 +62,7 @@ NS_IMPL_ISUPPORTS_INHERITED(nsMsgMailboxParser, nsParseMailMessageState, nsIStre // Whenever data arrives from the connection, core netlib notifices the protocol by calling // OnDataAvailable. We then read and process the incoming data from the input stream. -NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, +NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { // right now, this really just means turn around and process the url @@ -73,7 +73,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIRequest *request, nsISuppor return rv; } -NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt) { nsTime currentTime; m_startTime = currentTime; @@ -143,7 +143,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIRequest *request, nsISupport } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { DoneParsingFolder(aStatus); // what can we do? we can close the stream? diff --git a/mozilla/mailnews/local/src/nsPop3Protocol.cpp b/mozilla/mailnews/local/src/nsPop3Protocol.cpp index e60d1d7ba4e..c68b9afa4a6 100644 --- a/mozilla/mailnews/local/src/nsPop3Protocol.cpp +++ b/mozilla/mailnews/local/src/nsPop3Protocol.cpp @@ -567,9 +567,9 @@ nsresult nsPop3Protocol::GetPassword(char ** aPassword, PRBool *okayValue) } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = nsMsgProtocol::OnStopRequest(request, aContext, aStatus, aMsg); + nsresult rv = nsMsgProtocol::OnStopRequest(aChannel, aContext, aStatus, aMsg); // turn off the server busy flag on stop request - we know we're done, right? if (m_pop3Server) { diff --git a/mozilla/mailnews/local/src/nsPop3Protocol.h b/mozilla/mailnews/local/src/nsPop3Protocol.h index 06805c280b5..016b7f0b91b 100644 --- a/mozilla/mailnews/local/src/nsPop3Protocol.h +++ b/mozilla/mailnews/local/src/nsPop3Protocol.h @@ -258,7 +258,7 @@ public: nsresult GetPassword(char ** aPassword, PRBool *okayValue); - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg); NS_IMETHOD Cancel(nsresult status); // for nsMsgLineBuffer virtual PRInt32 HandleLine(char *line, PRUint32 line_length); diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp index 27f476105bd..61927cd5b5c 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp @@ -268,10 +268,7 @@ NS_IMETHODIMP nsMimeBaseEmitter::OnFull(nsIOutputStream* out) PRUint32 bytesAvailable = 0; rv = mInputStream->Available(&bytesAvailable); NS_ASSERTION(NS_SUCCEEDED(rv), "Available failed"); - - nsCOMPtr request = do_QueryInterface(mChannel); - rv = mOutListener->OnDataAvailable(request, mURL, mInputStream, 0, bytesAvailable); - + rv = mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, bytesAvailable); } else rv = NS_ERROR_NULL_POINTER; @@ -286,7 +283,7 @@ NS_IMETHODIMP nsMimeBaseEmitter::OnClose(nsIInputStream* in) /////////////////////////////////////////////////////////////////////////// // nsMimeBaseEmitter Interface -/////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsMimeBaseEmitter::SetPipe(nsIInputStream * aInputStream, nsIOutputStream *outStream) { @@ -865,8 +862,7 @@ nsMimeBaseEmitter::Complete() PRUint32 bytesInStream; nsresult rv2 = mInputStream->Available(&bytesInStream); NS_ASSERTION(NS_SUCCEEDED(rv2), "Available failed"); - nsCOMPtr request = do_QueryInterface(mChannel); - rv2 = mOutListener->OnDataAvailable(request, mURL, mInputStream, 0, bytesInStream); + rv2 = mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, bytesInStream); NS_ASSERTION(NS_SUCCEEDED(rv2), "OnDataAvailable failed"); } diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.h b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.h index a24cb06bf9e..29ba3f8d342 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.h +++ b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.h @@ -122,7 +122,7 @@ protected: nsIOutputStream *mOutStream; nsIInputStream *mInputStream; nsIStreamListener *mOutListener; - nsIChannel *mChannel; + nsIChannel *mChannel; // For gathering statistics on processing... PRUint32 mTotalWritten; diff --git a/mozilla/mailnews/mime/src/mimemoz2.cpp b/mozilla/mailnews/mime/src/mimemoz2.cpp index a823b877bdd..afc1b9cd1bd 100644 --- a/mozilla/mailnews/mime/src/mimemoz2.cpp +++ b/mozilla/mailnews/mime/src/mimemoz2.cpp @@ -59,6 +59,7 @@ #include "nsICharsetConverterManager.h" #include "nsICharsetAlias.h" #include "nsMimeTypes.h" + #include "nsIIOService.h" #include "nsIURI.h" #include "nsIMsgWindow.h" diff --git a/mozilla/mailnews/mime/src/nsStreamConverter.cpp b/mozilla/mailnews/mime/src/nsStreamConverter.cpp index 334df5c7020..43f3e59a533 100644 --- a/mozilla/mailnews/mime/src/nsStreamConverter.cpp +++ b/mozilla/mailnews/mime/src/nsStreamConverter.cpp @@ -49,7 +49,6 @@ #include "mozITXTToHTMLConv.h" #include "nsIMsgMailNewsUrl.h" #include "nsIMsgWindow.h" -#include "nsStreamConverter.h" #define PREF_MAIL_DISPLAY_GLYPH "mail.display_glyph" #define PREF_MAIL_DISPLAY_STRUCT "mail.display_struct" @@ -611,7 +610,6 @@ NS_IMETHODIMP nsStreamConverter::Init(nsIURI *aURI, nsIStreamListener * aOutList GetContentType(getter_Copies(contentTypeToUse)); // mscott --> my theory is that we don't need this fake outgoing channel. Let's use the // original channel and just set our content type ontop of the original channel... - aChannel->SetContentType(contentTypeToUse); //rv = NS_NewInputStreamChannel(getter_AddRefs(mOutgoingChannel), aURI, nsnull, contentTypeToUse, -1); @@ -818,7 +816,7 @@ nsStreamConverter::SetIdentity(nsIMsgIdentity * aIdentity) // networking library... // nsresult -nsStreamConverter::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +nsStreamConverter::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) @@ -889,7 +887,7 @@ char *output = "\ // called only once, at the beginning of a URL load. // nsresult -nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) { #ifdef DEBUG_rhp printf("nsStreamConverter::OnStartRequest()\n"); @@ -902,21 +900,25 @@ nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt) // here's a little bit of hackery.... // since the mime converter is now between the channel // and the - if (request) + nsresult rv = NS_OK; + if (aChannel) { - nsCOMPtr channel = do_QueryInterface(request); - if (channel) - { - nsXPIDLCString contentType; - GetContentType(getter_Copies(contentType)); - - channel->SetContentType(contentType); - } + nsXPIDLCString contentType; + GetContentType(getter_Copies(contentType)); + aChannel->SetContentType(contentType); } - // forward the start rquest to any listeners + // forward the start request to any listeners if (mOutListener) - mOutListener->OnStartRequest(request, ctxt); + if (mOutputType == nsMimeOutput::nsMimeMessageRaw) + { + //we need to delay the on start request until we have figure out the real content type + mPendingChannel = aChannel; + mPendingContext = ctxt; + } + else + mOutListener->OnStartRequest(aChannel, ctxt); + return NS_OK; } @@ -925,7 +927,7 @@ nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt) // called once when the networking library has finished processing the // nsresult -nsStreamConverter::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) +nsStreamConverter::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { #ifdef DEBUG_rhp printf("nsStreamConverter::OnStopRequest()\n"); @@ -1004,7 +1006,7 @@ nsStreamConverter::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresul // forward on top request to any listeners if (mOutListener) - mOutListener->OnStopRequest(request, ctxt, status, errorMsg); + mOutListener->OnStopRequest(/* mOutgoingChannel */ aChannel, ctxt, status, errorMsg); mAlreadyKnowOutputType = PR_FALSE; @@ -1068,6 +1070,7 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const PRUnichar *aFromType, co nsCOMPtr aUri; aChannel->GetURI(getter_AddRefs(aUri)); + return Init(aUri, aListener, aChannel); } diff --git a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp index 226d6fcdafd..e842d08f674 100644 --- a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp @@ -694,9 +694,9 @@ public: nsNntpCacheStreamListener (); virtual ~nsNntpCacheStreamListener(); - nsresult Init(nsIStreamListener * aStreamListener, nsIChannel* channel, nsIMsgMailNewsUrl *aRunningUrl); + nsresult Init(nsIStreamListener * aStreamListener, nsIChannel * aChannelToUse, nsIMsgMailNewsUrl *aRunningUrl); protected: - nsCOMPtr mChannelToUse; + nsCOMPtr mChannelToUse; nsCOMPtr mListener; nsCOMPtr mRunningUrl; }; @@ -718,37 +718,36 @@ nsNntpCacheStreamListener::nsNntpCacheStreamListener() nsNntpCacheStreamListener::~nsNntpCacheStreamListener() {} -nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel* channel, +nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel * aChannelToUse, nsIMsgMailNewsUrl *aRunningUrl) { NS_ENSURE_ARG(aStreamListener); - NS_ENSURE_ARG(channel); - - mChannelToUse = channel; + NS_ENSURE_ARG(aChannelToUse); + mChannelToUse = aChannelToUse; mListener = aStreamListener; mRunningUrl = aRunningUrl; return NS_OK; } NS_IMETHODIMP -nsNntpCacheStreamListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) +nsNntpCacheStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) { nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->AddRequest(request, nsnull /* context isupports */); - return mListener->OnStartRequest(request, aCtxt); + loadGroup->AddChannel(mChannelToUse, nsnull /* context isupports */); + return mListener->OnStartRequest(mChannelToUse, aCtxt); } NS_IMETHODIMP -nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) +nsNntpCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = mListener->OnStopRequest(request, aCtxt, aStatus, aMsg); + nsresult rv = mListener->OnStopRequest(mChannelToUse, aCtxt, aStatus, aMsg); nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->RemoveRequest(request, nsnull, aStatus, nsnull); + loadGroup->RemoveChannel(mChannelToUse, nsnull, aStatus, nsnull); // clear out mem cache entry so we're not holding onto it. if (mRunningUrl) @@ -760,13 +759,13 @@ nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtx } NS_IMETHODIMP -nsNntpCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) +nsNntpCacheStreamListener::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) { - return mListener->OnDataAvailable(request, aCtxt, aInStream, aSourceOffset, aCount); + return mListener->OnDataAvailable(mChannelToUse, aCtxt, aInStream, aSourceOffset, aCount); } -NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; nsCOMPtr mailnewsUrl = do_QueryInterface(m_runningURL, &rv); @@ -794,22 +793,18 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports // we want to create a file channel and read the msg from there. nsMsgKey key = nsMsgKey_None; rv = m_runningURL->GetMessageKey(&key); - nsCOMPtr fileChannel; - PRUint32 offset=0, size=0; - rv = folder->GetOfflineFileTransport(key, &offset, &size, getter_AddRefs(fileChannel)); + nsCOMPtr fileChannel; + rv = folder->GetOfflineFileChannel(key, getter_AddRefs(fileChannel)); // get the file channel from the folder, somehow (through the message or // folder sink?) We also need to set the transfer offset to the message offset if (fileChannel && NS_SUCCEEDED(rv)) { - // dougt - This may break the ablity to "cancel" a read from offline mail reading. - // fileChannel->SetLoadGroup(m_loadGroup); - + fileChannel->SetLoadGroup(m_loadGroup); m_typeWanted = ARTICLE_WANTED; nsNntpCacheStreamListener * cacheListener = new nsNntpCacheStreamListener(); NS_ADDREF(cacheListener); cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this), mailnewsUrl); - nsCOMPtr request; - rv = fileChannel->AsyncRead(cacheListener, m_channelContext, offset, size, 0, getter_AddRefs(request)); + rv = fileChannel->AsyncRead(cacheListener, m_channelContext); NS_RELEASE(cacheListener); MarkCurrentMsgRead(); @@ -845,11 +840,10 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports { // we're going to fill up this cache entry, // do we have a listener here? - nsIStreamListener *anotherListener = m_channelListener; - rv = cacheEntry->InterceptAsyncRead(anotherListener, 0, getter_AddRefs(m_channelListener)); - nsCOMPtr request; + nsIStreamListener *listener = m_channelListener; + rv = cacheEntry->InterceptAsyncRead(listener, 0, getter_AddRefs(m_channelListener)); if (NS_SUCCEEDED(rv)) - return nsMsgProtocol::AsyncOpen(m_channelListener, ctxt); + return nsMsgProtocol::AsyncRead(m_channelListener, ctxt); } } } @@ -857,8 +851,8 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports // to really load the msg with a protocol connection... if (cacheEntry && contentLength > 0 && !partialFlag) { - nsCOMPtr cacheChannel; - rv = cacheEntry->NewTransport(m_loadGroup, getter_AddRefs(cacheChannel)); + nsCOMPtr cacheChannel; + rv = cacheEntry->NewChannel(m_loadGroup, getter_AddRefs(cacheChannel)); if (NS_SUCCEEDED(rv)) { nsNntpCacheStreamListener * cacheListener = new nsNntpCacheStreamListener(); @@ -866,8 +860,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports SetLoadGroup(m_loadGroup); m_typeWanted = ARTICLE_WANTED; cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this), mailnewsUrl); - nsCOMPtr request; - rv = cacheChannel->AsyncRead(cacheListener, m_channelContext, 0, -1, 0, getter_AddRefs(request)); + rv = cacheChannel->AsyncRead(cacheListener, m_channelContext); NS_RELEASE(cacheListener); MarkCurrentMsgRead(); @@ -882,8 +875,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports } } - nsCOMPtr parentRequest; - return nsMsgProtocol::AsyncOpen(listener, ctxt); + return nsMsgProtocol::AsyncRead(listener, ctxt); } nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer) @@ -1219,9 +1211,9 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer) } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) { - nsMsgProtocol::OnStopRequest(request, aContext, aStatus, aMsg); + nsMsgProtocol::OnStopRequest(aChannel, aContext, aStatus, aMsg); // nsMsgProtocol::OnStopRequest() has called m_channelListener. There is // no need to be called again in CloseSocket(). Let's clear it here. @@ -5417,7 +5409,7 @@ nsresult nsNNTPProtocol::CleanupAfterRunningUrl() rv = m_channelListener->OnStopRequest(this, m_channelContext, NS_OK, nsnull); if (m_loadGroup) - m_loadGroup->RemoveRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull, NS_OK, nsnull); + m_loadGroup->RemoveChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull, NS_OK, nsnull); if (m_newsgroupList) { int status; diff --git a/mozilla/mailnews/news/src/nsNNTPProtocol.h b/mozilla/mailnews/news/src/nsNNTPProtocol.h index 03611f042cf..87ca654f68f 100644 --- a/mozilla/mailnews/news/src/nsNNTPProtocol.h +++ b/mozilla/mailnews/news/src/nsNNTPProtocol.h @@ -162,13 +162,13 @@ public: virtual ~nsNNTPProtocol(); // stop binding is a "notification" informing us that the stream associated with aURL is going away. - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg); char * m_ProxyServer; /* proxy server hostname */ NS_IMETHOD Cancel(nsresult status); // handle stop button NS_IMETHOD GetContentType(char * *aContentType); - NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt); + NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt); nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer); private: diff --git a/mozilla/mailnews/news/src/nsNntpService.cpp b/mozilla/mailnews/news/src/nsNntpService.cpp index 4aa7bbbcd01..83a241c7d7a 100644 --- a/mozilla/mailnews/news/src/nsNntpService.cpp +++ b/mozilla/mailnews/news/src/nsNntpService.cpp @@ -1610,12 +1610,9 @@ NS_IMETHODIMP nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask) NS_IMETHODIMP -nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request) +nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel) { nsresult rv = NS_OK; - if (!request) return NS_ERROR_NULL_POINTER; - - nsCOMPtr aChannel = do_QueryInterface(request); if (!aChannel) return NS_ERROR_NULL_POINTER; if (nsCRT::strcasecmp(aContentType, "x-application-newsgroup") == 0) { diff --git a/mozilla/modules/libjar/nsJARChannel.cpp b/mozilla/modules/libjar/nsJARChannel.cpp index 2249ba9d601..5ef89b162d8 100644 --- a/mozilla/modules/libjar/nsJARChannel.cpp +++ b/mozilla/modules/libjar/nsJARChannel.cpp @@ -31,7 +31,6 @@ #include "nsMimeTypes.h" #include "nsScriptSecurityManager.h" #include "nsIAggregatePrincipal.h" -#include "nsIProgressEventSink.h" #include "nsXPIDLString.h" static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); @@ -61,9 +60,13 @@ PRLogModuleInfo* gJarProtocolLog = nsnull; nsJARChannel::nsJARChannel() : mLoadAttributes(LOAD_NORMAL), + mStartPosition(0), + mReadCount(-1), mContentType(nsnull), mContentLength(-1), mJAREntry(nsnull), + mBufferSegmentSize(NS_DEFAULT_JAR_BUFFER_SEGMENT_SIZE), + mBufferMaxSize(NS_DEFAULT_JAR_BUFFER_MAX_SIZE), mStatus(NS_OK), mMonitor(nsnull) { @@ -252,12 +255,12 @@ nsJARChannel::OpenJARElement() rv = Open(nsnull, nsnull); if (NS_SUCCEEDED(rv)) rv = GetInputStream(getter_AddRefs(mSynchronousInputStream)); - mon.Notify(); // wake up nsIChannel::Open + mon.Notify(); // wake up OpenInputStream return rv; } NS_IMETHODIMP -nsJARChannel::Open(nsIInputStream* *result) +nsJARChannel::OpenInputStream(nsIInputStream* *result) { nsAutoCMonitor mon(this); nsresult rv; @@ -270,7 +273,7 @@ nsJARChannel::Open(nsIInputStream* *result) { *result = mSynchronousInputStream; // Result of GetInputStream called on transport thread NS_ADDREF(*result); - mSynchronousInputStream = 0; + mSynchronousInputStream = null_nsCOMPtr(); return NS_OK; } else @@ -278,7 +281,14 @@ nsJARChannel::Open(nsIInputStream* *result) } NS_IMETHODIMP -nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt) +nsJARChannel::OpenOutputStream(nsIOutputStream* *result) +{ + NS_NOTREACHED("nsJARChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsJARChannel::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) { nsresult rv; mUserContext = ctxt; @@ -300,7 +310,7 @@ nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt) } } } - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -332,7 +342,7 @@ nsJARChannel::EnsureJARFileAvailable() rv = NS_NewDownloader(getter_AddRefs(mDownloader), mJARBaseURI, this, nsnull, mSynchronousRead, mLoadGroup, mCallbacks, - mLoadAttributes); + mLoadAttributes, mBufferSegmentSize, mBufferMaxSize); // if DownloadComplete() was called early, need to release the reference. if (mSynchronousRead && mSynchronousInputStream) @@ -340,7 +350,7 @@ nsJARChannel::EnsureJARFileAvailable() error: if (NS_FAILED(rv) && mLoadGroup) { - nsresult rv2 = mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); + nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } return rv; @@ -356,16 +366,20 @@ nsJARChannel::AsyncReadJARElement() NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr jarTransport; - rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport)); + rv = fts->CreateTransportFromStreamIO(this, + getter_AddRefs(mJarExtractionTransport)); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetBufferSegmentSize(mBufferSegmentSize); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetBufferMaxSize(mBufferMaxSize); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetTransferOffset(mStartPosition); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetTransferCount(mReadCount); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - jarTransport->SetProgressEventSink(sink); - } - #ifdef PR_LOGGING nsXPIDLCString jarURLStr; mURI->GetSpec(getter_Copies(jarURLStr)); @@ -373,10 +387,18 @@ nsJARChannel::AsyncReadJARElement() ("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr)); #endif - rv = jarTransport->AsyncRead(this, nsnull, 0, -1, 0, getter_AddRefs(mJarExtractionTransport)); + rv = mJarExtractionTransport->AsyncRead(this, nsnull); return rv; } +NS_IMETHODIMP +nsJARChannel::AsyncWrite(nsIStreamProvider* provider, + nsISupports* ctxt) +{ + NS_NOTREACHED("nsJARChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJARChannel::GetLoadAttributes(PRUint32* aLoadFlags) { @@ -469,6 +491,83 @@ nsJARChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsJARChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mStartPosition; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + mStartPosition = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mReadCount; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetTransferCount(PRInt32 aTransferCount) +{ + mReadCount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -568,7 +667,7 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu else rv = AsyncReadJARElement(); } - mDownloader = 0; + mDownloader = null_nsCOMPtr(); return rv; } @@ -576,14 +675,14 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu // nsIStreamObserver methods: NS_IMETHODIMP -nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport, +nsJARChannel::OnStartRequest(nsIChannel* jarExtractionTransport, nsISupports* context) { return mUserListener->OnStartRequest(this, mUserContext); } NS_IMETHODIMP -nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context, +nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -602,7 +701,7 @@ nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* con if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } @@ -616,7 +715,7 @@ nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* con // nsIStreamListener methods: NS_IMETHODIMP -nsJARChannel::OnDataAvailable(nsIRequest* jarCacheTransport, +nsJARChannel::OnDataAvailable(nsIChannel* jarCacheTransport, nsISupports* context, nsIInputStream *inStr, PRUint32 sourceOffset, diff --git a/mozilla/modules/libjar/nsJARChannel.h b/mozilla/modules/libjar/nsJARChannel.h index e8d08e93c06..9bfdf71c3c4 100644 --- a/mozilla/modules/libjar/nsJARChannel.h +++ b/mozilla/modules/libjar/nsJARChannel.h @@ -89,6 +89,8 @@ protected: nsLoadFlags mLoadAttributes; nsCOMPtr mOwner; + PRUint32 mStartPosition; + PRInt32 mReadCount; nsCOMPtr mUserContext; nsCOMPtr mUserListener; @@ -98,13 +100,15 @@ protected: char* mJAREntry; nsCOMPtr mJAR; nsCOMPtr mDownloadedJARFile; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; nsresult mStatus; PRBool mSynchronousRead; nsCOMPtr mSynchronousInputStream; PRMonitor* mMonitor; nsCOMPtr mDownloader; - nsCOMPtr mJarExtractionTransport; + nsCOMPtr mJarExtractionTransport; }; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 68085662487..c300838f203 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -953,7 +953,7 @@ public: private: nsresult SetUpCache(nsIURI* aURL); - nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL); + nsresult SetUpStreamListener(nsIChannel *channel, nsIURI* aURL); nsIURI *mURL; nsIPluginInstanceOwner *mOwner; @@ -1014,13 +1014,13 @@ nsPluginCacheListener::~nsPluginCacheListener() NS_IMPL_ISUPPORTS(nsPluginCacheListener, kIStreamListenerIID); NS_IMETHODIMP -nsPluginCacheListener::OnStartRequest(nsIRequest *request, nsISupports* ctxt) +nsPluginCacheListener::OnStartRequest(nsIChannel* channel, nsISupports* ctxt) { return NS_OK; } NS_IMETHODIMP -nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt, +nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt, nsIInputStream* aIStream, PRUint32 sourceOffset, PRUint32 aLength) @@ -1043,7 +1043,7 @@ nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt, } NS_IMETHODIMP -nsPluginCacheListener::OnStopRequest(nsIRequest *request, +nsPluginCacheListener::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) @@ -1211,15 +1211,10 @@ nsresult nsPluginStreamListenerPeer::InitializeFullPage(nsIPluginInstance *aInst NS_IMETHODIMP -nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aContext) +nsPluginStreamListenerPeer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { nsresult rv = NS_OK; - nsCOMPtr channel = do_QueryInterface(request); - - if (!channel) - return NS_ERROR_FAILURE; - char* aContentType = nsnull; rv = channel->GetContentType(&aContentType); if (NS_FAILED(rv)) return rv; @@ -1292,14 +1287,14 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo } - rv = SetUpStreamListener(request, aURL); + rv = SetUpStreamListener(channel, aURL); if (NS_FAILED(rv)) return rv; return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) @@ -1308,7 +1303,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) @@ -1316,7 +1311,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest *request, return NS_OK; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIInputStream *aIStream, PRUint32 sourceOffset, @@ -1324,9 +1319,6 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, { nsresult rv = NS_OK; nsCOMPtr aURL; - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; - rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; @@ -1348,7 +1340,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, // if a plugin returns an error, the peer must kill the stream // else the stream and PluginStreamListener leak if (NS_FAILED(rv)) - request->Cancel(rv); + channel->Cancel(rv); } else { @@ -1361,15 +1353,13 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv = NS_OK; nsCOMPtr aURL; - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; @@ -1377,11 +1367,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, { char* urlString; nsCOMPtr localFile; - nsCOMPtr fileChannel = do_QueryInterface(channel); - - if (fileChannel) - rv = fileChannel->GetFile(getter_AddRefs(localFile)); - + rv = channel->GetLocalFile(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; @@ -1436,7 +1422,7 @@ nsresult nsPluginStreamListenerPeer::SetUpCache(nsIURI* aURL) return NS_OpenURI(cacheListener, nsnull, aURL, nsnull); } -nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, +nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, nsIURI* aURL) { nsresult rv = NS_OK; @@ -1468,8 +1454,6 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, nsCOMPtr headerListener = do_QueryInterface(mPStreamListener); if (headerListener) { - - nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener); @@ -1481,8 +1465,6 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, mPluginStreamInfo->SetSeekable(PR_FALSE); // get Last-Modified header for plugin info - - nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr theHTTPChannel = do_QueryInterface(channel); if (theHTTPChannel) { char * lastModified; @@ -3824,7 +3806,8 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, } } - rv = channel->AsyncOpen(listenerPeer, nsnull); + + rv = channel->AsyncRead(listenerPeer, nsnull); } NS_RELEASE(listenerPeer); diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index 2143943f285..dbb7e261423 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -37,7 +37,6 @@ class ns4xPlugin; class nsFileSpec; class nsIComponentManager; class nsIFile; -class nsIChannel; /** * A linked-list of plugin information that is used for diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index e4bc9ddd236..48f61986459 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -157,14 +157,14 @@ public: virtual ~PluginViewerImpl(); - nsresult CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, + nsresult CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult); nsresult MakeWindow(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, const nsRect& aBounds); - nsresult StartLoad(nsIRequest* request, nsIStreamListener*& aResult); + nsresult StartLoad(nsIChannel* channel, nsIStreamListener*& aResult); void ForceRefresh(void); @@ -307,18 +307,15 @@ PluginViewerImpl::Init(nsIWidget* aParentWidget, } nsresult -PluginViewerImpl::StartLoad(nsIRequest* request, nsIStreamListener*& aResult) +PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult) { - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; - NS_IF_RELEASE(mChannel); mChannel = channel; NS_ADDREF(mChannel); #ifdef DEBUG char* contentType; - channel->GetContentType(&contentType); + mChannel->GetContentType(&contentType); printf("PluginViewerImpl::StartLoad: content-type=%s\n", contentType); nsCRT::free(contentType); #endif @@ -334,14 +331,14 @@ PluginViewerImpl::StartLoad(nsIRequest* request, nsIStreamListener*& aResult) { nsRect r; mWindow->GetClientBounds(r); - rv = CreatePlugin(request, host, nsRect(0, 0, r.width, r.height), aResult); + rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult); } return rv; } nsresult -PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, +PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult) { nsresult rv = NS_OK; @@ -375,9 +372,7 @@ PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsCRT::free(spec); char* ct; - - nsCOMPtr channel = do_QueryInterface(request); - channel->GetContentType(&ct); + rv = mChannel->GetContentType(&ct); if (NS_FAILED(rv)) return rv; rv = aHost->InstantiateFullPagePlugin(ct, str, aResult, mOwner); delete[] ct; @@ -697,45 +692,43 @@ PluginListener::~PluginListener() NS_IMPL_ISUPPORTS(PluginListener, kIStreamListenerIID) NS_IMETHODIMP -PluginListener::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +PluginListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { nsresult rv; char* contentType = nsnull; - nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetContentType(&contentType); - if (NS_FAILED(rv)) { return rv; } - rv = mViewer->StartLoad(request, mNextStream); + rv = mViewer->StartLoad(channel, mNextStream); if (NS_FAILED(rv)) { return rv; } if (nsnull == mNextStream) return NS_ERROR_FAILURE; - return mNextStream->OnStartRequest(request, ctxt); + return mNextStream->OnStartRequest(channel, ctxt); } NS_IMETHODIMP -PluginListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +PluginListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStopRequest(request, ctxt, status, errorMsg); + return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); } NS_IMETHODIMP -PluginListener::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +PluginListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); + return mNextStream->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 68085662487..c300838f203 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -953,7 +953,7 @@ public: private: nsresult SetUpCache(nsIURI* aURL); - nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL); + nsresult SetUpStreamListener(nsIChannel *channel, nsIURI* aURL); nsIURI *mURL; nsIPluginInstanceOwner *mOwner; @@ -1014,13 +1014,13 @@ nsPluginCacheListener::~nsPluginCacheListener() NS_IMPL_ISUPPORTS(nsPluginCacheListener, kIStreamListenerIID); NS_IMETHODIMP -nsPluginCacheListener::OnStartRequest(nsIRequest *request, nsISupports* ctxt) +nsPluginCacheListener::OnStartRequest(nsIChannel* channel, nsISupports* ctxt) { return NS_OK; } NS_IMETHODIMP -nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt, +nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt, nsIInputStream* aIStream, PRUint32 sourceOffset, PRUint32 aLength) @@ -1043,7 +1043,7 @@ nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt, } NS_IMETHODIMP -nsPluginCacheListener::OnStopRequest(nsIRequest *request, +nsPluginCacheListener::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) @@ -1211,15 +1211,10 @@ nsresult nsPluginStreamListenerPeer::InitializeFullPage(nsIPluginInstance *aInst NS_IMETHODIMP -nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aContext) +nsPluginStreamListenerPeer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { nsresult rv = NS_OK; - nsCOMPtr channel = do_QueryInterface(request); - - if (!channel) - return NS_ERROR_FAILURE; - char* aContentType = nsnull; rv = channel->GetContentType(&aContentType); if (NS_FAILED(rv)) return rv; @@ -1292,14 +1287,14 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo } - rv = SetUpStreamListener(request, aURL); + rv = SetUpStreamListener(channel, aURL); if (NS_FAILED(rv)) return rv; return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) @@ -1308,7 +1303,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) @@ -1316,7 +1311,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest *request, return NS_OK; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIInputStream *aIStream, PRUint32 sourceOffset, @@ -1324,9 +1319,6 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, { nsresult rv = NS_OK; nsCOMPtr aURL; - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; - rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; @@ -1348,7 +1340,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, // if a plugin returns an error, the peer must kill the stream // else the stream and PluginStreamListener leak if (NS_FAILED(rv)) - request->Cancel(rv); + channel->Cancel(rv); } else { @@ -1361,15 +1353,13 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv = NS_OK; nsCOMPtr aURL; - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; @@ -1377,11 +1367,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, { char* urlString; nsCOMPtr localFile; - nsCOMPtr fileChannel = do_QueryInterface(channel); - - if (fileChannel) - rv = fileChannel->GetFile(getter_AddRefs(localFile)); - + rv = channel->GetLocalFile(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; @@ -1436,7 +1422,7 @@ nsresult nsPluginStreamListenerPeer::SetUpCache(nsIURI* aURL) return NS_OpenURI(cacheListener, nsnull, aURL, nsnull); } -nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, +nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, nsIURI* aURL) { nsresult rv = NS_OK; @@ -1468,8 +1454,6 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, nsCOMPtr headerListener = do_QueryInterface(mPStreamListener); if (headerListener) { - - nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener); @@ -1481,8 +1465,6 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, mPluginStreamInfo->SetSeekable(PR_FALSE); // get Last-Modified header for plugin info - - nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr theHTTPChannel = do_QueryInterface(channel); if (theHTTPChannel) { char * lastModified; @@ -3824,7 +3806,8 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, } } - rv = channel->AsyncOpen(listenerPeer, nsnull); + + rv = channel->AsyncRead(listenerPeer, nsnull); } NS_RELEASE(listenerPeer); diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h index 2143943f285..dbb7e261423 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h @@ -37,7 +37,6 @@ class ns4xPlugin; class nsFileSpec; class nsIComponentManager; class nsIFile; -class nsIChannel; /** * A linked-list of plugin information that is used for diff --git a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp index e4bc9ddd236..48f61986459 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -157,14 +157,14 @@ public: virtual ~PluginViewerImpl(); - nsresult CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, + nsresult CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult); nsresult MakeWindow(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, const nsRect& aBounds); - nsresult StartLoad(nsIRequest* request, nsIStreamListener*& aResult); + nsresult StartLoad(nsIChannel* channel, nsIStreamListener*& aResult); void ForceRefresh(void); @@ -307,18 +307,15 @@ PluginViewerImpl::Init(nsIWidget* aParentWidget, } nsresult -PluginViewerImpl::StartLoad(nsIRequest* request, nsIStreamListener*& aResult) +PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult) { - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; - NS_IF_RELEASE(mChannel); mChannel = channel; NS_ADDREF(mChannel); #ifdef DEBUG char* contentType; - channel->GetContentType(&contentType); + mChannel->GetContentType(&contentType); printf("PluginViewerImpl::StartLoad: content-type=%s\n", contentType); nsCRT::free(contentType); #endif @@ -334,14 +331,14 @@ PluginViewerImpl::StartLoad(nsIRequest* request, nsIStreamListener*& aResult) { nsRect r; mWindow->GetClientBounds(r); - rv = CreatePlugin(request, host, nsRect(0, 0, r.width, r.height), aResult); + rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult); } return rv; } nsresult -PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, +PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult) { nsresult rv = NS_OK; @@ -375,9 +372,7 @@ PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsCRT::free(spec); char* ct; - - nsCOMPtr channel = do_QueryInterface(request); - channel->GetContentType(&ct); + rv = mChannel->GetContentType(&ct); if (NS_FAILED(rv)) return rv; rv = aHost->InstantiateFullPagePlugin(ct, str, aResult, mOwner); delete[] ct; @@ -697,45 +692,43 @@ PluginListener::~PluginListener() NS_IMPL_ISUPPORTS(PluginListener, kIStreamListenerIID) NS_IMETHODIMP -PluginListener::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +PluginListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { nsresult rv; char* contentType = nsnull; - nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetContentType(&contentType); - if (NS_FAILED(rv)) { return rv; } - rv = mViewer->StartLoad(request, mNextStream); + rv = mViewer->StartLoad(channel, mNextStream); if (NS_FAILED(rv)) { return rv; } if (nsnull == mNextStream) return NS_ERROR_FAILURE; - return mNextStream->OnStartRequest(request, ctxt); + return mNextStream->OnStartRequest(channel, ctxt); } NS_IMETHODIMP -PluginListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +PluginListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStopRequest(request, ctxt, status, errorMsg); + return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); } NS_IMETHODIMP -PluginListener::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +PluginListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); + return mNextStream->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/netwerk/base/public/MANIFEST_IDL b/mozilla/netwerk/base/public/MANIFEST_IDL index 5268bb05840..406c7ef9c60 100644 --- a/mozilla/netwerk/base/public/MANIFEST_IDL +++ b/mozilla/netwerk/base/public/MANIFEST_IDL @@ -16,7 +16,6 @@ nsIRequest.idl nsISocketTransportService.idl nsIStreamIO.idl nsIStreamListener.idl -nsITransport.idl nsIStreamLoader.idl nsIDownloader.idl nsIStreamObserver.idl diff --git a/mozilla/netwerk/base/public/Makefile.in b/mozilla/netwerk/base/public/Makefile.in index 69bde7eaa2e..362fa359718 100644 --- a/mozilla/netwerk/base/public/Makefile.in +++ b/mozilla/netwerk/base/public/Makefile.in @@ -55,7 +55,6 @@ XPIDLSRCS = \ nsIStreamListener.idl \ nsIStreamProvider.idl \ nsIStreamLoader.idl \ - nsITransport.idl \ nsISocketTransport.idl \ nsIURI.idl \ nsIURL.idl \ diff --git a/mozilla/netwerk/base/public/makefile.win b/mozilla/netwerk/base/public/makefile.win index d5c249ac6e6..460470b1066 100644 --- a/mozilla/netwerk/base/public/makefile.win +++ b/mozilla/netwerk/base/public/makefile.win @@ -53,13 +53,11 @@ XPIDLSRCS = \ .\nsISocketTransport.idl \ .\nsISocketTransportService.idl \ .\nsIStreamIO.idl \ - .\nsIStreamObserver.idl \ .\nsIStreamListener.idl \ .\nsIStreamProvider.idl \ .\nsIStreamLoader.idl \ - .\nsIStreamProvider.idl \ - .\nsITransport.idl \ .\nsIDownloader.idl \ + .\nsIStreamObserver.idl \ .\nsIURI.idl \ .\nsIURL.idl \ .\nsIURLParser.idl \ diff --git a/mozilla/netwerk/base/public/nsIChannel.idl b/mozilla/netwerk/base/public/nsIChannel.idl index 8ec8b64b3c4..bf5c6e77b33 100644 --- a/mozilla/netwerk/base/public/nsIChannel.idl +++ b/mozilla/netwerk/base/public/nsIChannel.idl @@ -36,24 +36,35 @@ interface nsIStreamIO; typedef unsigned long nsLoadFlags; /** - * The nsIChannel interface allows the user to construct get requests for + * The nsIChannel interface allows the user to construct I/O requests for * specific protocols, and manage them in a uniform way. Once a channel * is created (via nsIIOService::NewChannel), parameters for that request * may be set by using the channel attributes, or by QueryInterfacing to a * subclass of nsIChannel for protocol-specific parameters. Then the actual * request can be issued in one of several ways: * - * - AsyncOpen is used for asynchronous reading, calling back the - * user's stream listener. - * - Open is used for synchronous read on the underlying channel. + * - AsyncRead and AsyncWrite allow for asynchronous requests, calling + * back the user's stream listener or provider, + * - OpenInputStream and OpenOutputStream allow for synchronous reads + * and writes on the underlying channel. * * After a request has been completed, the channel is still valid for * accessing protocol-specific results. For example, QueryInterfacing to * nsIHTTPChannel allows response headers to be retrieved that result from * http transactions. * + * Note that a channel is really only valid for one request. Reusing a channel + * after a request has completed for a subsequent request may have undefined + * results, depending on the channel implementation. + * + * Also of note are a special kind of channel called "transports." Transports + * also implement the nsIChannel interface, but operate at a lower level from + * protocol channels. The socket and file transports are notable implementations + * of transports and allow higher level channels to be implemented. The cache + * may also behave as a transport, and possibly things like sound playing services + * etc. Transports usually operate in a separate thread and often multiplex + * multiple requests for the same kind of service or resources. */ - [scriptable, uuid(1788e79e-f947-11d3-8cda-0060b0fc14a3)] interface nsIChannel : nsIRequest { @@ -81,20 +92,27 @@ interface nsIChannel : nsIRequest attribute nsIURI URI; /** - * Accesses the owner corresponding to the entity that is - * responsible for this channel. Used by security code to grant - * or deny privileges to mobile code loaded from this channel. - * - * Note: This is a strong reference to the owner, so if the owner is also - * holding a pointer to the channel, care must be taken to explicitly drop - * its reference to the channel -- otherwise a leak will result. + * Accesses the start offset from the beginning of the data from/to which + * reads/writes will occur. Users may set the transferOffset before making + * any of the following requests: asyncOpen, asyncRead, asyncWrite, + * openInputStream, openOutputstream. */ - attribute nsISupports owner; + attribute unsigned long transferOffset; /** - * Accesses the load group in which the channel is a currently a member. + * Accesses the count of bytes to be transfered. For openInputStream and + * asyncRead, this specifies the amount to read, for asyncWrite, this + * specifies the amount to write (note that for openOutputStream, the + * end of the data can be signified simply by closing the stream). + * If the transferCount is set after reading has been initiated, the + * amount specified will become the current remaining amount to read + * before the channel is closed (this can be useful if the content + * length is encoded at the start of the stream). + * + * A transferCount value of -1 means the amount is unspecified, i.e. + * read or write all the data that is available. */ - attribute nsILoadGroup loadGroup; + attribute long transferCount; /** * Accesses the load attributes for the channel. E.g. setting the load @@ -105,18 +123,6 @@ interface nsIChannel : nsIRequest */ attribute nsLoadFlags loadAttributes; - /** - * Accesses the capabilities callbacks of the channel. This is set by clients - * who wish to provide a means to receive progress, status and protocol-specific - * notifications. - */ - attribute nsIInterfaceRequestor notificationCallbacks; - - /** - * Any security information about this channel. This can be null. - */ - readonly attribute nsISupports securityInfo; - /** * Returns the content MIME type of the channel if available. Note that the * content type can often be wrongly specified (wrong file extension, wrong @@ -132,17 +138,65 @@ interface nsIChannel : nsIRequest attribute long contentLength; /** - * Open is used for synchronous read on the channel. - **/ - nsIInputStream open(); + * Accesses the owner corresponding to the entity that is + * responsible for this channel. Used by security code to grant + * or deny privileges to mobile code loaded from this channel. + * + * Note: This is a strong reference to the owner, so if the owner is also + * holding a pointer to the channel, care must be taken to explicitly drop + * its reference to the channel -- otherwise a leak will result. + */ + attribute nsISupports owner; - /** AsyncOpen is used for asynchronous reading, calling back the - * user's stream listener. - **/ - void asyncOpen(in nsIStreamListener listener, in nsISupports ctxt); + /** + * Accesses the load group in which the channel is a currently a member. + */ + attribute nsILoadGroup loadGroup; + + /** + * Accesses the capabilities callbacks of the channel. This is set by clients + * who wish to provide a means to receive progress, status and protocol-specific + * notifications. + */ + attribute nsIInterfaceRequestor notificationCallbacks; + + /** + * Any security information about this channel. This can be null. + */ + readonly attribute nsISupports securityInfo; + + /** + * Accesses the buffer segment size. The buffer segment size is used as + * the initial size for any transfer buffers, and the increment size for + * whenever the buffer space needs to be grown. + * (Note this parameter is passed along to any underlying nsIPipe objects.) + * If unspecified, the channel implementation picks a default. + */ + attribute unsigned long bufferSegmentSize; + + /** + * Accesses the buffer maximum size. The buffer maximum size is the limit + * size that buffer will be grown to before suspending the channel. + * (Note this parameter is passed along to any underlying nsIPipe objects.) + * If unspecified, the channel implementation picks a default. + */ + attribute unsigned long bufferMaxSize; + + /** + * Returns a local file to the channel's data if one exists, null otherwise. + */ + readonly attribute nsIFile localFile; + + /** + * Setting pipeliningAllowed causes the load of a URL (issued via + * asyncRead or asyncWrite) to be deferred in order to allow the request to + * be pipelined for greater throughput efficiency. Pipelined requests will + * be forced to load when the first non-pipelined request is issued. + */ + attribute boolean pipeliningAllowed; //////////////////////////////////////////////////////////////////////////// - // Below are Load attribute flags which may be or'd together. + // Load attribute flags. These may be or'd together. //////////////////////////////////////////////////////////////////////////// /** * Note that more will follow for each protocol's implementation of a channel, @@ -233,7 +287,41 @@ interface nsIChannel : nsIRequest */ const unsigned long LOAD_REPLACE = 1 << 16; + //////////////////////////////////////////////////////////////////////////// + // nsIChannel operations + //////////////////////////////////////////////////////////////////////////// + + /** + * Opens a blocking input stream to the URI's specified source. This + * call may block until the input stream is available. + */ + nsIInputStream openInputStream(); + /** + * Opens a blocking output stream to the URI's specified destination. This + * call may block until the output stream is available. + */ + nsIOutputStream openOutputStream(); + + /** + * Reads asynchronously from the URI's specified source. Notifications + * are provided to the stream listener on the calling thread. + * + * @param listener - notification handler. + * @param ctxt - application context passed to methods invoked on listener. + */ + void asyncRead(in nsIStreamListener listener, + in nsISupports ctxt); + + /** + * Writes asynchronously to the URI's specified destination. Notifications + * are provided to the stream provider on the calling thread. + * + * @param provider - notification handler. + * @param ctxt - application context passed to methods invoked on provider. + */ + void asyncWrite(in nsIStreamProvider provider, + in nsISupports ctxt); }; //////////////////////////////////////////////////////////////////////////////// @@ -246,7 +334,8 @@ interface nsIChannel : nsIRequest [scriptable, uuid(308362ce-0d06-11d4-986e-00c04fa0cf4a)] interface nsIStreamIOChannel : nsIChannel { - void init(in nsIURI uri, in nsIStreamIO io); + void init(in nsIURI uri, + in nsIStreamIO io); }; %{C++ diff --git a/mozilla/netwerk/base/public/nsIDownloader.idl b/mozilla/netwerk/base/public/nsIDownloader.idl index 4698b872dec..00e25528285 100644 --- a/mozilla/netwerk/base/public/nsIDownloader.idl +++ b/mozilla/netwerk/base/public/nsIDownloader.idl @@ -48,7 +48,9 @@ interface nsIDownloader : nsISupports in boolean synchronous, in nsILoadGroup loadGroup, in nsIInterfaceRequestor notificationCallbacks, - in nsLoadFlags loadAttributes); + in nsLoadFlags loadAttributes, + in unsigned long bufferSegmentSize, + in unsigned long bufferMaxSize); }; %{C++ diff --git a/mozilla/netwerk/base/public/nsIFileTransportService.idl b/mozilla/netwerk/base/public/nsIFileTransportService.idl index 5891df7fc4f..d7b2f78cb19 100644 --- a/mozilla/netwerk/base/public/nsIFileTransportService.idl +++ b/mozilla/netwerk/base/public/nsIFileTransportService.idl @@ -25,7 +25,7 @@ #include "nsFileSpec.h" %} -interface nsITransport; +interface nsIChannel; interface nsIEventSinkGetter; interface nsIInputStream; interface nsIRunnable; @@ -35,18 +35,18 @@ interface nsIStreamIO; [scriptable, uuid(57211a60-8c45-11d3-93ac-00104ba0fd40)] interface nsIFileTransportService : nsISupports { - nsITransport createTransport(in nsIFile file, - in long ioFlags, - in long perm); + nsIChannel createTransport(in nsIFile file, + in long ioFlags, + in long perm); // This version can be used with an existing input stream to serve // as a data pump: - nsITransport createTransportFromStream(in string name, - in nsIInputStream fromStream, - in string contentType, - in long contentLength); + nsIChannel createTransportFromStream(in string name, + in nsIInputStream fromStream, + in string contentType, + in long contentLength); - nsITransport createTransportFromStreamIO(in nsIStreamIO io); + nsIChannel createTransportFromStreamIO(in nsIStreamIO io); void dispatchRequest(in nsIRunnable runnable); void processPendingRequests(); diff --git a/mozilla/netwerk/base/public/nsIIOService.idl b/mozilla/netwerk/base/public/nsIIOService.idl index 2a8b6589baf..58498496885 100644 --- a/mozilla/netwerk/base/public/nsIIOService.idl +++ b/mozilla/netwerk/base/public/nsIIOService.idl @@ -104,6 +104,15 @@ interface nsIIOService : nsISupports */ attribute boolean offline; + /** + * Consumes all input from the channel, feading data to the specified stream + * listener. The function does not return until either all the data is + * consumed, or an error occurs. + */ + void consumeInput(in nsIChannel channel, + in nsISupports ctxt, + in nsIStreamListener consumer); + //////////////////////////////////////////////////////////////////////////// // URL parsing utilities diff --git a/mozilla/netwerk/base/public/nsILoadGroup.idl b/mozilla/netwerk/base/public/nsILoadGroup.idl index 0e4d69125a1..9c16bafc9fb 100644 --- a/mozilla/netwerk/base/public/nsILoadGroup.idl +++ b/mozilla/netwerk/base/public/nsILoadGroup.idl @@ -23,7 +23,6 @@ #include "nsIRequest.idl" interface nsIChannel; -interface nsIRequest; interface nsISimpleEnumerator; interface nsIStreamObserver; interface nsIStreamListener; @@ -53,35 +52,35 @@ interface nsILoadGroup : nsIRequest /** * Accesses the default load channel for the group. Each time a number - * of request are added to a group, the DefaultLoadChannel may be set - * to indicate that all of the requests are related to a particular URL. + * of channels are added to a group, the DefaultLoadChannel may be set + * to indicate that all of the channels are related to a particular URL. */ - attribute nsIRequest defaultLoadRequest; + attribute nsIChannel defaultLoadChannel; /** - * Adds a new request to the group. This will cause the default load - * attributes to be applied to that request. If the request added is - * the first request in the group, the group's observer's OnStartRequest + * Adds a new channel to the group. This will cause the default load + * attributes to be applied to that channel. If the channel added is + * the first channel in the group, the group's observer's OnStartRequest * method is called. */ - void addRequest(in nsIRequest request, + void addChannel(in nsIChannel channel, in nsISupports ctxt); /** - * Removes a request from the group. If the request removed is - * the last request in the group, the group's observer's OnStopRequest + * Removes a channel from the group. If the channel removed is + * the last channel in the group, the group's observer's OnStopRequest * method is called. */ - void removeRequest(in nsIRequest request, + void removeChannel(in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); /** - * Returns the requests contained directly in this group. - * Enumerator element type: nsIRequest. + * Returns the channels contained directly in this group. + * Enumerator element type: nsIChannel. */ - readonly attribute nsISimpleEnumerator requests; + readonly attribute nsISimpleEnumerator channels; attribute nsIStreamObserver groupObserver; diff --git a/mozilla/netwerk/base/public/nsIProgressEventSink.idl b/mozilla/netwerk/base/public/nsIProgressEventSink.idl index 50ec3c925e9..1260b37d7e5 100644 --- a/mozilla/netwerk/base/public/nsIProgressEventSink.idl +++ b/mozilla/netwerk/base/public/nsIProgressEventSink.idl @@ -23,7 +23,7 @@ #include "nsISupports.idl" interface nsIURI; -interface nsIRequest; +interface nsIChannel; /** * An instance of nsIFfpEventSink should be passed as the eventSink @@ -34,9 +34,9 @@ interface nsIRequest; interface nsIProgressEventSink : nsISupports { /** - * Notify the EventSink that progress has occurred for the URL load.
+ * Notify the EventSink that progress as occurred for the URL load.
*/ - void onProgress(in nsIRequest request, + void onProgress(in nsIChannel channel, in nsISupports ctxt, in unsigned long aProgress, in unsigned long aProgressMax); @@ -52,7 +52,7 @@ interface nsIProgressEventSink : nsISupports * message. Multiple arguments can be passed by delimiting them * with newline ('\n') characters. */ - void onStatus(in nsIRequest request, + void onStatus(in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); diff --git a/mozilla/netwerk/base/public/nsISocketTransport.idl b/mozilla/netwerk/base/public/nsISocketTransport.idl index d4455b83225..54feb3dbc34 100644 --- a/mozilla/netwerk/base/public/nsISocketTransport.idl +++ b/mozilla/netwerk/base/public/nsISocketTransport.idl @@ -20,14 +20,11 @@ * Contributor(s): */ -#include "nsITransport.idl" +#include "nsISupports.idl" [scriptable, uuid(785CA0F0-C39E-11d3-9ED6-0010A4053FD0)] -interface nsISocketTransport : nsITransport +interface nsISocketTransport : nsISupports { - readonly attribute string host; - readonly attribute long port; - /** * */ diff --git a/mozilla/netwerk/base/public/nsISocketTransportService.idl b/mozilla/netwerk/base/public/nsISocketTransportService.idl index 012810223a3..04894ac19de 100644 --- a/mozilla/netwerk/base/public/nsISocketTransportService.idl +++ b/mozilla/netwerk/base/public/nsISocketTransportService.idl @@ -22,9 +22,8 @@ #include "nsISupports.idl" -interface nsITransport; -interface nsIEventSinkGetter; interface nsIChannel; +interface nsIEventSinkGetter; [scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)] interface nsISocketTransportService : nsISupports @@ -37,29 +36,29 @@ interface nsISocketTransportService : nsISupports * etc. The printHost contains the actual hostname (and not the * proxy) for displaying in status messages. */ - nsITransport createTransport(in string host, - in long port, - in string proxyHost, - in long proxyPort, - in unsigned long bufferSegmentSize, - in unsigned long bufferMaxSize); + nsIChannel createTransport(in string host, + in long port, + in string proxyHost, + in long proxyPort, + in unsigned long bufferSegmentSize, + in unsigned long bufferMaxSize); - nsITransport createTransportOfType(in string socketType, - in string host, - in long port, - in string proxyHost, - in long proxyPort, - in unsigned long bufferSegmentSize, - in unsigned long bufferMaxSize); + nsIChannel createTransportOfType(in string socketType, + in string host, + in long port, + in string proxyHost, + in long proxyPort, + in unsigned long bufferSegmentSize, + in unsigned long bufferMaxSize); - nsITransport createTransportOfTypes(in unsigned long typeCount, + nsIChannel createTransportOfTypes(in unsigned long typeCount, [array, size_is(typeCount)] in string socketTypes, - in string host, - in long port, - in string proxyHost, - in long proxyPort, - in unsigned long bufferSegmentSize, - in unsigned long bufferMaxSize); + in string host, + in long port, + in string proxyHost, + in long proxyPort, + in unsigned long bufferSegmentSize, + in unsigned long bufferMaxSize); /** * Returns true if the specified transport is good enough for @@ -67,11 +66,11 @@ interface nsISocketTransportService : nsISupports * include- an error including server resets, an explicit * Connection: close header (for HTTP) and timeouts! */ - boolean reuseTransport(in nsITransport i_Transport); + boolean reuseTransport(in nsIChannel i_Transport); void init (); void shutdown(); - void wakeup (in nsITransport i_Transport); + void wakeup (in nsIChannel i_Transport); /** * Total number of nsSocketTransport objects currently alive diff --git a/mozilla/netwerk/base/public/nsIStreamListener.idl b/mozilla/netwerk/base/public/nsIStreamListener.idl index fae64da5c9d..306941161d0 100644 --- a/mozilla/netwerk/base/public/nsIStreamListener.idl +++ b/mozilla/netwerk/base/public/nsIStreamListener.idl @@ -22,7 +22,7 @@ #include "nsIStreamObserver.idl" -interface nsIRequest; +interface nsIChannel; interface nsIInputStream; interface nsIOutputStream; interface nsIEventQueue; @@ -37,7 +37,7 @@ interface nsIStreamListener : nsIStreamObserver /** * Called when there is data to be read from the channel. * - * @param request - the request returned by AsyncRead + * @param channel - the channel being read * @param ctxt - opaque parameter passed to AsyncRead * @param input - temporary input stream for reading data chunk * @param offset - current stream position (informational) @@ -52,7 +52,7 @@ interface nsIStreamListener : nsIStreamObserver * becomes available. * @return - if failure. */ - void onDataAvailable(in nsIRequest request, + void onDataAvailable(in nsIChannel channel, in nsISupports ctxt, in nsIInputStream input, in unsigned long offset, diff --git a/mozilla/netwerk/base/public/nsIStreamLoader.idl b/mozilla/netwerk/base/public/nsIStreamLoader.idl index 7b5a6aedb43..61749c813be 100644 --- a/mozilla/netwerk/base/public/nsIStreamLoader.idl +++ b/mozilla/netwerk/base/public/nsIStreamLoader.idl @@ -23,7 +23,6 @@ #include "nsISupports.idl" #include "nsIChannel.idl" -interface nsIRequest; interface nsIURI; interface nsILoadGroup; interface nsIStreamObserver; @@ -48,7 +47,9 @@ interface nsIStreamLoader : nsISupports in nsISupports ctxt, in nsILoadGroup loadGroup, in nsIInterfaceRequestor notificationCallbacks, - in nsLoadFlags loadAttributes); + in nsLoadFlags loadAttributes, + in unsigned long bufferSegmentSize, + in unsigned long bufferMaxSize); /** * Gets the number of bytes read so far. @@ -56,9 +57,9 @@ interface nsIStreamLoader : nsISupports readonly attribute unsigned long numBytesRead; /** - * Gets the request that loaded this file + * Gets the channel that loaded this file */ - readonly attribute nsIRequest request; + readonly attribute nsIChannel channel; }; diff --git a/mozilla/netwerk/base/public/nsIStreamObserver.idl b/mozilla/netwerk/base/public/nsIStreamObserver.idl index 0edb6a86b5e..f20f5365402 100644 --- a/mozilla/netwerk/base/public/nsIStreamObserver.idl +++ b/mozilla/netwerk/base/public/nsIStreamObserver.idl @@ -22,7 +22,7 @@ #include "nsISupports.idl" -interface nsIRequest; +interface nsIChannel; interface nsIEventQueue; [scriptable, uuid(fd91e2e0-1481-11d3-9333-00104ba0fd40)] @@ -31,22 +31,22 @@ interface nsIStreamObserver : nsISupports /** * Called to signify the beginning of an asynchronous request. * - * @param request - request being observed + * @param channel - channel being observed * @param ctxt - user specified data passed to AsyncRead/Write */ - void onStartRequest(in nsIRequest request, + void onStartRequest(in nsIChannel channel, in nsISupports ctxt); /** * Called to signify the end of an asynchronous request. This * call is always preceded by a call to onStartRequest. * - * @param request - request being observed + * @param channel - channel being observed * @param ctxt - user specified data passed to AsyncRead/Write * @param statusCode - reason for stopping (NS_OK if completed successfully) * @param statusText - human readable reason for stopping (can be NULL) */ - void onStopRequest(in nsIRequest request, + void onStopRequest(in nsIChannel channel, in nsISupports ctxt, in nsresult statusCode, in wstring statusText); diff --git a/mozilla/netwerk/base/public/nsIStreamProvider.idl b/mozilla/netwerk/base/public/nsIStreamProvider.idl index 9f76787edea..41c3008ea7b 100644 --- a/mozilla/netwerk/base/public/nsIStreamProvider.idl +++ b/mozilla/netwerk/base/public/nsIStreamProvider.idl @@ -37,7 +37,7 @@ interface nsIStreamProvider : nsIStreamObserver /** * Called when data may be written to the channel. * - * @param request - the request returned by AsyncWrite + * @param channel - the channel being written to * @param ctxt - opaque parameter passed to AsyncWrite * @param output - output stream for writing data chunk * @param offset - current stream position (informational) @@ -52,7 +52,7 @@ interface nsIStreamProvider : nsIStreamObserver * becomes available. * @return - if failure. */ - void onDataWritable(in nsIRequest request, + void onDataWritable(in nsIChannel channel, in nsISupports ctxt, in nsIOutputStream output, in unsigned long offset, diff --git a/mozilla/netwerk/base/public/nsITransport.idl b/mozilla/netwerk/base/public/nsITransport.idl index 1ef4c27c6e8..e69de29bb2d 100644 --- a/mozilla/netwerk/base/public/nsITransport.idl +++ b/mozilla/netwerk/base/public/nsITransport.idl @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsISupports.idl" -#include "nsIRequest.idl" - -interface nsIStreamListener; -interface nsIStreamProvider; -interface nsIInputStream; -interface nsIOutputStream; -interface nsIProgressEventSink; - -[scriptable, uuid(fd01f9a4-d492-4cf8-b76e-160ffc8c01e8)] -interface nsITransport : nsISupports -{ - /** - * Get security info for this transport. - */ - readonly attribute nsISupports securityInfo; - - /** - * Get/set the progress event sink for this transport. - */ - attribute nsIProgressEventSink progressEventSink; - - /** - * Open an input stream on this transport. - * - * @param offset - read starting at this offset - * @param count - read this many bytes - * @param flags - optional transport specific flags - */ - nsIInputStream openInputStream(in unsigned long offset, - in unsigned long count, - in unsigned long flags); - - /** - * Open an output stream on this transport. - * - * @param offset - write starting at this offset - * @param count - write no more than this many bytes - * @param flags - optional transport specific flags - */ - nsIOutputStream openOutputStream(in unsigned long offset, - in unsigned long count, - in unsigned long flags); - - /** - * Asynchronously read data from the transport. - * - * @param listener - notify this listener when data is available - * @param ctxt - opaque parameter passed to listener methods - * @param offset - read starting at this offset - * @param count - read this many bytes - * @param flags - optional transport specific flags - */ - nsIRequest asyncRead(in nsIStreamListener listener, - in nsISupports ctxt, - in unsigned long offset, - in unsigned long count, - in unsigned long flags); - - /** - * Asynchronously write data to the transport. - * - * @param provider - notify this provider when data can be written - * @param ctxt - opaque parameter passed to provider methods - * @param offset - write starting at this offset - * @param count - write this many bytes - * @param flags - optional transport specific flags - */ - nsIRequest asyncWrite(in nsIStreamProvider provider, - in nsISupports ctxt, - in unsigned long offset, - in unsigned long count, - in unsigned long flags); -}; - -[scriptable, uuid(d7abf5a4-ce72-482a-9217-a219a905c019)] -interface nsITransportRequest : nsIRequest -{ - /** - * Get the transport associated with this request. - */ - readonly attribute nsITransport transport; -}; diff --git a/mozilla/netwerk/base/public/nsNetUtil.h b/mozilla/netwerk/base/public/nsNetUtil.h index d9c837b2c50..19ef0a78e8c 100644 --- a/mozilla/netwerk/base/public/nsNetUtil.h +++ b/mozilla/netwerk/base/public/nsNetUtil.h @@ -36,7 +36,6 @@ #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsIChannel.h" -#include "nsITransport.h" #include "nsMemory.h" #include "nsCOMPtr.h" #include "nsIHTTPProtocolHandler.h" @@ -95,7 +94,9 @@ NS_OpenURI(nsIChannel* *result, nsIIOService* ioService = nsnull, // pass in nsIIOService to optimize callers nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), + PRUint32 bufferSegmentSize = 0, + PRUint32 bufferMaxSize = 0) { nsresult rv; @@ -122,6 +123,14 @@ NS_OpenURI(nsIChannel* *result, rv = channel->SetLoadAttributes(loadAttributes); if (NS_FAILED(rv)) return rv; } + if (bufferSegmentSize != 0) { + rv = channel->SetBufferSegmentSize(bufferSegmentSize); + if (NS_FAILED(rv)) return rv; + } + if (bufferMaxSize != 0) { + rv = channel->SetBufferMaxSize(bufferMaxSize); + if (NS_FAILED(rv)) return rv; + } *result = channel; return rv; @@ -139,17 +148,20 @@ NS_OpenURI(nsIInputStream* *result, nsIIOService* ioService = nsnull, // pass in nsIIOService to optimize callers nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), + PRUint32 bufferSegmentSize = 0, + PRUint32 bufferMaxSize = 0) { nsresult rv; nsCOMPtr channel; rv = NS_OpenURI(getter_AddRefs(channel), uri, ioService, - loadGroup, notificationCallbacks, loadAttributes); + loadGroup, notificationCallbacks, loadAttributes, + bufferSegmentSize, bufferMaxSize); if (NS_FAILED(rv)) return rv; nsIInputStream* inStr; - rv = channel->Open(&inStr); + rv = channel->OpenInputStream(&inStr); if (NS_FAILED(rv)) return rv; *result = inStr; @@ -163,16 +175,19 @@ NS_OpenURI(nsIStreamListener* aConsumer, nsIIOService* ioService = nsnull, // pass in nsIIOService to optimize callers nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), + PRUint32 bufferSegmentSize = 0, + PRUint32 bufferMaxSize = 0) { nsresult rv; nsCOMPtr channel; rv = NS_OpenURI(getter_AddRefs(channel), uri, ioService, - loadGroup, notificationCallbacks, loadAttributes); + loadGroup, notificationCallbacks, loadAttributes, + bufferSegmentSize, bufferMaxSize); if (NS_FAILED(rv)) return rv; - rv = channel->AsyncOpen(aConsumer, context); + rv = channel->AsyncRead(aConsumer, context); return rv; } @@ -311,7 +326,9 @@ NS_NewDownloader(nsIDownloader* *result, PRBool synchronous = PR_FALSE, nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), + PRUint32 bufferSegmentSize = 0, + PRUint32 bufferMaxSize = 0) { nsresult rv; nsCOMPtr downloader; @@ -321,8 +338,8 @@ NS_NewDownloader(nsIDownloader* *result, NS_GET_IID(nsIDownloader), getter_AddRefs(downloader)); if (NS_FAILED(rv)) return rv; - rv = downloader->Init(uri, observer, context, synchronous, loadGroup, - notificationCallbacks, loadAttributes); + rv = downloader->Init(uri, observer, context, synchronous, loadGroup, notificationCallbacks, + loadAttributes, bufferSegmentSize, bufferMaxSize); if (NS_FAILED(rv)) return rv; *result = downloader; NS_ADDREF(*result); @@ -336,7 +353,9 @@ NS_NewStreamLoader(nsIStreamLoader* *result, nsISupports* context = nsnull, nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), + PRUint32 bufferSegmentSize = 0, + PRUint32 bufferMaxSize = 0) { nsresult rv; nsCOMPtr loader; @@ -346,9 +365,8 @@ NS_NewStreamLoader(nsIStreamLoader* *result, NS_GET_IID(nsIStreamLoader), getter_AddRefs(loader)); if (NS_FAILED(rv)) return rv; - rv = loader->Init(uri, observer, context, loadGroup, - notificationCallbacks, loadAttributes); - + rv = loader->Init(uri, observer, context, loadGroup, notificationCallbacks, loadAttributes, + bufferSegmentSize, bufferMaxSize); if (NS_FAILED(rv)) return rv; *result = loader; NS_ADDREF(*result); @@ -375,7 +393,9 @@ NS_NewStreamObserverProxy(nsIStreamObserver **aResult, rv = proxy->Init(aObserver, aEventQ); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = proxy); + *aResult = proxy; + NS_ADDREF(*aResult); + return NS_OK; } @@ -401,7 +421,9 @@ NS_NewStreamListenerProxy(nsIStreamListener **aResult, rv = proxy->Init(aListener, aEventQ, aBufferSegmentSize, aBufferMaxSize); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = proxy); + *aResult = proxy; + NS_ADDREF(*aResult); + return NS_OK; } @@ -427,7 +449,9 @@ NS_NewStreamProviderProxy(nsIStreamProvider **aResult, rv = proxy->Init(aProvider, aEventQ, aBufferSegmentSize, aBufferMaxSize); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = proxy); + *aResult = proxy; + NS_ADDREF(*aResult); + return NS_OK; } @@ -450,7 +474,9 @@ NS_NewSimpleStreamListener(nsIStreamListener **aResult, rv = listener->Init(aSink, aObserver); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = listener); + *aResult = listener.get(); + NS_ADDREF(*aResult); + return NS_OK; } @@ -473,7 +499,9 @@ NS_NewSimpleStreamProvider(nsIStreamProvider **aResult, rv = provider->Init(aSource, aObserver); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = provider); + *aResult = provider.get(); + NS_ADDREF(*aResult); + return NS_OK; } @@ -494,7 +522,8 @@ NS_NewAsyncStreamObserver(nsIStreamObserver **result, rv = obs->Init(receiver, eventQueue); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*result = obs); + *result = obs; + NS_ADDREF(*result); return NS_OK; } @@ -515,7 +544,8 @@ NS_NewAsyncStreamListener(nsIStreamListener **result, rv = lsnr->Init(receiver, eventQueue); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*result = lsnr); + *result = lsnr; + NS_ADDREF(*result); return NS_OK; } @@ -542,26 +572,25 @@ NS_NewSyncStreamListener(nsIInputStream **aInStream, rv = NS_NewSimpleStreamListener(aResult, pipeOut); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aInStream = pipeIn); - NS_ADDREF(*aOutStream = pipeOut); + *aInStream = pipeIn; + NS_ADDREF(*aInStream); + *aOutStream = pipeOut; + NS_ADDREF(*aOutStream); + return NS_OK; } // -// Calls AsyncWrite on the specified transport, with a stream provider that +// Calls AsyncWrite on the specified channel, with a stream provider that // reads data from the specified input stream. // inline nsresult -NS_AsyncWriteFromStream(nsIRequest **aRequest, - nsITransport *aTransport, +NS_AsyncWriteFromStream(nsIChannel *aChannel, nsIInputStream *aSource, - PRUint32 aOffset=0, - PRUint32 aCount=0, - PRUint32 aFlags=0, nsIStreamObserver *aObserver=NULL, nsISupports *aContext=NULL) { - NS_ENSURE_ARG_POINTER(aTransport); + NS_ENSURE_ARG_POINTER(aChannel); nsresult rv; nsCOMPtr provider; @@ -570,28 +599,20 @@ NS_AsyncWriteFromStream(nsIRequest **aRequest, aObserver); if (NS_FAILED(rv)) return rv; - return aTransport->AsyncWrite(provider, aContext, - aOffset, - aCount, - aFlags, - getter_AddRefs(aRequest)); + return aChannel->AsyncWrite(provider, aContext); } // -// Calls AsyncRead on the specified transport, with a stream listener that +// Calls AsyncRead on the specified channel, with a stream listener that // writes data to the specified output stream. // inline nsresult -NS_AsyncReadToStream(nsIRequest **aRequest, - nsITransport *aTransport, +NS_AsyncReadToStream(nsIChannel *aChannel, nsIOutputStream *aSink, - PRUint32 aOffset=0, - PRUint32 aCount=0, - PRUint32 aFlags=0, nsIStreamObserver *aObserver=NULL, nsISupports *aContext=NULL) { - NS_ENSURE_ARG_POINTER(aTransport); + NS_ENSURE_ARG_POINTER(aChannel); nsresult rv; nsCOMPtr listener; @@ -600,11 +621,7 @@ NS_AsyncReadToStream(nsIRequest **aRequest, aObserver); if (NS_FAILED(rv)) return rv; - return aTransport->AsyncRead(listener, aContext, - aOffset, - aCount, - aFlags, - getter_AddRefs(aRequest)); + return aChannel->AsyncRead(listener, aContext); } #endif // nsNetUtil_h__ diff --git a/mozilla/netwerk/base/public/security-prefs.js b/mozilla/netwerk/base/public/security-prefs.js index 59c8dee10dc..7b97b561eb9 100644 --- a/mozilla/netwerk/base/public/security-prefs.js +++ b/mozilla/netwerk/base/public/security-prefs.js @@ -9,7 +9,3 @@ pref("security.warn_entering_secure", true); pref("security.warn_leaving_secure", true); pref("security.warn_viewing_mixed", true); pref("security.warn_submit_insecure", true); - -pref("security.ui.enable", true); - - diff --git a/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp b/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp index a7f3209a292..f5f08f4a532 100644 --- a/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp +++ b/mozilla/netwerk/base/src/nsAsyncStreamListener.cpp @@ -48,7 +48,7 @@ class nsStreamListenerEvent { public: nsStreamListenerEvent(nsAsyncStreamObserver* listener, - nsIRequest* request, nsISupports* context); + nsIChannel* channel, nsISupports* context); virtual ~nsStreamListenerEvent(); nsresult Fire(nsIEventQueue* aEventQ); @@ -60,7 +60,7 @@ protected: static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent); nsAsyncStreamObserver* mListener; - nsIRequest* mRequest; + nsIChannel* mChannel; nsISupports* mContext; PLEvent mEvent; }; @@ -71,13 +71,13 @@ protected: //////////////////////////////////////////////////////////////////////////////// nsStreamListenerEvent::nsStreamListenerEvent(nsAsyncStreamObserver* listener, - nsIRequest* request, nsISupports* context) - : mListener(listener), mRequest(request), mContext(context) + nsIChannel* channel, nsISupports* context) + : mListener(listener), mChannel(channel), mContext(context) { MOZ_COUNT_CTOR(nsStreamListenerEvent); NS_IF_ADDREF(mListener); - NS_IF_ADDREF(mRequest); + NS_IF_ADDREF(mChannel); NS_IF_ADDREF(mContext); } @@ -86,7 +86,7 @@ nsStreamListenerEvent::~nsStreamListenerEvent() MOZ_COUNT_DTOR(nsStreamListenerEvent); NS_IF_RELEASE(mListener); - NS_IF_RELEASE(mRequest); + NS_IF_RELEASE(mChannel); NS_IF_RELEASE(mContext); } @@ -105,7 +105,7 @@ void PR_CALLBACK nsStreamListenerEvent::HandlePLEvent(PLEvent* aEvent) // the pipe to empty... // if (NS_FAILED(rv)) { - nsresult cancelRv = ev->mRequest->Cancel(rv); + nsresult cancelRv = ev->mChannel->Cancel(rv); NS_ASSERTION(NS_SUCCEEDED(cancelRv), "Cancel failed"); } } @@ -182,8 +182,8 @@ class nsOnStartRequestEvent : public nsStreamListenerEvent { public: nsOnStartRequestEvent(nsAsyncStreamObserver* listener, - nsIRequest* request, nsISupports* context) - : nsStreamListenerEvent(listener, request, context) {} + nsIChannel* channel, nsISupports* context) + : nsStreamListenerEvent(listener, channel, context) {} virtual ~nsOnStartRequestEvent() {} NS_IMETHOD HandleEvent(); @@ -205,19 +205,19 @@ nsOnStartRequestEvent::HandleEvent() } nsresult status; - nsresult rv = mRequest->GetStatus(&status); + nsresult rv = mChannel->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); - rv = receiver->OnStartRequest(mRequest, mContext); + rv = receiver->OnStartRequest(mChannel, mContext); return rv; } NS_IMETHODIMP -nsAsyncStreamObserver::OnStartRequest(nsIRequest *request, nsISupports* context) +nsAsyncStreamObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) { nsresult rv; nsOnStartRequestEvent* event = - new nsOnStartRequestEvent(this, request, context); + new nsOnStartRequestEvent(this, channel, context); if (event == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -252,8 +252,8 @@ class nsOnStopRequestEvent : public nsStreamListenerEvent { public: nsOnStopRequestEvent(nsAsyncStreamObserver* listener, - nsISupports* context, nsIRequest* request) - : nsStreamListenerEvent(listener, request, context), + nsISupports* context, nsIChannel* channel) + : nsStreamListenerEvent(listener, channel, context), mStatus(NS_OK) {} virtual ~nsOnStopRequestEvent(); @@ -293,7 +293,7 @@ nsOnStopRequestEvent::HandleEvent() } nsresult status = NS_OK; - nsresult rv = mRequest->GetStatus(&status); + nsresult rv = mChannel->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); // @@ -303,14 +303,14 @@ nsOnStopRequestEvent::HandleEvent() if (NS_SUCCEEDED(rv) && NS_FAILED(status)) { mStatus = status; } - rv = receiver->OnStopRequest(mRequest, mContext, mStatus, mStatusArg.GetUnicode()); + rv = receiver->OnStopRequest(mChannel, mContext, mStatus, mStatusArg.GetUnicode()); // Call clear on the listener to make sure it's cleanup is done on the correct thread mListener->Clear(); return rv; } NS_IMETHODIMP -nsAsyncStreamObserver::OnStopRequest(nsIRequest* request, nsISupports* context, +nsAsyncStreamObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -320,7 +320,7 @@ nsAsyncStreamObserver::OnStopRequest(nsIRequest* request, nsISupports* context, // Status is... // nsOnStopRequestEvent* event = - new nsOnStopRequestEvent(this, context, request); + new nsOnStopRequestEvent(this, context, channel); if (event == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -354,8 +354,8 @@ class nsOnDataAvailableEvent : public nsStreamListenerEvent { public: nsOnDataAvailableEvent(nsAsyncStreamObserver* listener, - nsIRequest* request, nsISupports* context) - : nsStreamListenerEvent(listener, request, context), + nsIChannel* channel, nsISupports* context) + : nsStreamListenerEvent(listener, channel, context), mIStream(nsnull), mLength(0) {} virtual ~nsOnDataAvailableEvent(); @@ -401,7 +401,7 @@ nsOnDataAvailableEvent::HandleEvent() } nsresult status; - nsresult rv = mRequest->GetStatus(&status); + nsresult rv = mChannel->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); // @@ -409,7 +409,7 @@ nsOnDataAvailableEvent::HandleEvent() // have succeeded... // if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) { - rv = receiver->OnDataAvailable(mRequest, mContext, + rv = receiver->OnDataAvailable(mChannel, mContext, mIStream, mSourceOffset, mLength); } else { @@ -419,14 +419,14 @@ nsOnDataAvailableEvent::HandleEvent() } NS_IMETHODIMP -nsAsyncStreamListener::OnDataAvailable(nsIRequest* request, nsISupports* context, +nsAsyncStreamListener::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { nsresult rv; nsOnDataAvailableEvent* event = - new nsOnDataAvailableEvent(this, request, context); + new nsOnDataAvailableEvent(this, channel, context); if (event == nsnull) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/base/src/nsAsyncStreamListener.h b/mozilla/netwerk/base/src/nsAsyncStreamListener.h index c1e3b11b02d..7eac3aa6355 100644 --- a/mozilla/netwerk/base/src/nsAsyncStreamListener.h +++ b/mozilla/netwerk/base/src/nsAsyncStreamListener.h @@ -28,7 +28,7 @@ #include "nsIEventQueue.h" #include "nsIStreamObserver.h" #include "nsIStreamListener.h" -#include "nsIRequest.h" + //////////////////////////////////////////////////////////////////////////////// class nsAsyncStreamObserver : public nsIAsyncStreamObserver @@ -66,20 +66,20 @@ public: NS_DECL_ISUPPORTS_INHERITED // nsIStreamListener methods: - NS_IMETHOD OnStartRequest(nsIRequest* request, + NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context) { - return nsAsyncStreamObserver::OnStartRequest(request, context); + return nsAsyncStreamObserver::OnStartRequest(channel, context); } - NS_IMETHOD OnStopRequest(nsIRequest* request, + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { - return nsAsyncStreamObserver::OnStopRequest(request, context, aStatus, aStatusArg); + return nsAsyncStreamObserver::OnStopRequest(channel, context, aStatus, aStatusArg); } - NS_IMETHOD OnDataAvailable(nsIRequest* request, nsISupports* context, + NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength); diff --git a/mozilla/netwerk/base/src/nsDownloader.cpp b/mozilla/netwerk/base/src/nsDownloader.cpp index a23febb948b..795579065d5 100644 --- a/mozilla/netwerk/base/src/nsDownloader.cpp +++ b/mozilla/netwerk/base/src/nsDownloader.cpp @@ -43,7 +43,9 @@ nsDownloader::Init(nsIURI* aURL, PRBool aIsSynchronous, nsILoadGroup* aGroup, nsIInterfaceRequestor* aNotificationCallbacks, - nsLoadFlags aLoadAttributes) + nsLoadFlags aLoadAttributes, + PRUint32 aBufferSegmentSize, + PRUint32 aBufferMaxSize) { nsresult rv; mObserver = aObserver; @@ -53,13 +55,10 @@ nsDownloader::Init(nsIURI* aURL, aLoadAttributes |= nsIChannel::CACHE_AS_FILE; rv = NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, aGroup, aNotificationCallbacks, - aLoadAttributes); + aLoadAttributes, aBufferSegmentSize, aBufferMaxSize); if (NS_SUCCEEDED(rv) && channel) - { - nsCOMPtr fc = do_QueryInterface(channel); - if (fc) - rv = fc->GetFile(getter_AddRefs(localFile)); - } + rv = channel->GetLocalFile(getter_AddRefs(localFile)); + if (mObserver && (NS_FAILED(rv) || localFile)) { if (aIsSynchronous) @@ -82,7 +81,8 @@ nsDownloader::Init(nsIURI* aURL, return pObserver->OnDownloadComplete(this, mContext, rv, localFile); } } - return channel->AsyncOpen(this, aContext); + + return channel->AsyncRead(this, aContext); } NS_METHOD @@ -103,13 +103,13 @@ NS_IMPL_ISUPPORTS3(nsDownloader, nsIDownloader, nsIStreamObserver, nsIStreamListener) NS_IMETHODIMP -nsDownloader::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +nsDownloader::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { return NS_OK; } NS_IMETHODIMP -nsDownloader::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +nsDownloader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsCOMPtr file; @@ -117,10 +117,6 @@ nsDownloader::OnStopRequest(nsIRequest *request, nsISupports *ctxt, { nsresult rv; nsCOMPtr uri; - - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - rv = channel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; nsXPIDLCString spec; @@ -151,7 +147,7 @@ nsDownloader::OnStopRequest(nsIRequest *request, nsISupports *ctxt, #define BUF_SIZE 1024 NS_IMETHODIMP -nsDownloader::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +nsDownloader::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { diff --git a/mozilla/netwerk/base/src/nsFileTransport.cpp b/mozilla/netwerk/base/src/nsFileTransport.cpp index 776ca0cd3a7..e54be33e277 100644 --- a/mozilla/netwerk/base/src/nsFileTransport.cpp +++ b/mozilla/netwerk/base/src/nsFileTransport.cpp @@ -208,6 +208,7 @@ nsFileTransport::nsFileTransport() mOffset(0), mTotalAmount(-1), mTransferAmount(-1), + mLoadAttributes(LOAD_NORMAL), mSourceWrapper(nsnull), mSinkWrapper(nsnull), mService(nsnull) @@ -282,9 +283,8 @@ nsFileTransport::~nsFileTransport() PR_AtomicDecrement(&mService->mTotalTransports); } -NS_IMPL_THREADSAFE_ISUPPORTS4(nsFileTransport, - nsITransport, - nsITransportRequest, +NS_IMPL_THREADSAFE_ISUPPORTS3(nsFileTransport, + nsIChannel, nsIRequest, nsIRunnable) @@ -384,80 +384,52 @@ nsFileTransport::Resume() return NS_OK; } -//////////////////////////////////////////////////////////////////////////////// -// From nsITransportRequest -//////////////////////////////////////////////////////////////////////////////// - -NS_IMETHODIMP -nsFileTransport::GetTransport(nsITransport **result) -{ - NS_ENSURE_ARG_POINTER(result); - NS_ADDREF(*result = this); - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// // From nsITransport //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileTransport::OpenInputStream(PRUint32 aTransferOffset, - PRUint32 aTransferCount, - PRUint32 aFlags, - nsIInputStream **aResult) +nsFileTransport::OpenInputStream(nsIInputStream **result) { - NS_ENSURE_ARG_POINTER(aResult); nsresult rv; nsCOMPtr in; rv = mStreamIO->GetInputStream(getter_AddRefs(in)); if (NS_FAILED(rv)) return rv; - NS_ASSERTION(aTransferCount == (PRUint32) -1, "need to wrap input stream in one that truncates"); - if (aTransferOffset > 0) { + NS_ASSERTION(mTransferAmount == -1, "need to wrap input stream in one that truncates"); + if (mOffset > 0) { nsCOMPtr seekable = do_QueryInterface(in, &rv); if (NS_FAILED(rv)) return rv; - rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, aTransferOffset); + rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset); if (NS_FAILED(rv)) return rv; } - NS_ADDREF(*aResult = in); + *result = in; + NS_ADDREF(*result); return rv; } NS_IMETHODIMP -nsFileTransport::OpenOutputStream(PRUint32 aTransferOffset, - PRUint32 aTransferCount, - PRUint32 aFlags, - nsIOutputStream **aResult) +nsFileTransport::OpenOutputStream(nsIOutputStream **result) { - NS_ASSERTION(aTransferOffset == 0, "need to seek to specified offset"); - NS_ASSERTION(aTransferCount == (PRUint32) -1, "need to wrap output stream in one that truncates"); - return mStreamIO->GetOutputStream(aResult); + return mStreamIO->GetOutputStream(result); } NS_IMETHODIMP -nsFileTransport::AsyncRead(nsIStreamListener *aListener, - nsISupports *aContext, - PRUint32 aTransferOffset, - PRUint32 aTransferCount, - PRUint32 aFlags, - nsIRequest **aResult) +nsFileTransport::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { - NS_ENSURE_ARG_POINTER(aResult); nsresult rv = NS_OK; if (mXferState != CLOSED) return NS_ERROR_IN_PROGRESS; - NS_ASSERTION(aListener, "need to supply an nsIStreamListener"); + NS_ASSERTION(listener, "need to supply an nsIStreamListener"); rv = NS_NewStreamListenerProxy(getter_AddRefs(mListener), - aListener, nsnull, + listener, nsnull, mBufferSegmentSize, mBufferMaxSize); if (NS_FAILED(rv)) return rv; NS_ASSERTION(mContext == nsnull, "context not released"); - mContext = aContext; - mOffset = aTransferOffset; - mTransferAmount = aTransferCount; + mContext = ctxt; mXferState = OPEN_FOR_READ; LOG(("nsFileTransport: AsyncRead [this=%x %s] mOffset=%d mTransferAmount=%d\n", @@ -469,38 +441,27 @@ nsFileTransport::AsyncRead(nsIStreamListener *aListener, rv = mService->DispatchRequest(this); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = this); return NS_OK; } NS_IMETHODIMP -nsFileTransport::AsyncWrite(nsIStreamProvider *aProvider, - nsISupports *aContext, - PRUint32 aTransferOffset, - PRUint32 aTransferCount, - PRUint32 aFlags, - nsIRequest **aResult) +nsFileTransport::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) { - NS_ENSURE_ARG_POINTER(aResult); nsresult rv = NS_OK; LOG(("nsFileTransport: AsyncWrite [this=%x, provider=%x]\n", - this, aProvider)); + this, provider)); if (mXferState != CLOSED) return NS_ERROR_IN_PROGRESS; - NS_ASSERTION(aProvider, "need to supply an nsIStreamProvider"); - rv = NS_NewStreamProviderProxy(getter_AddRefs(mProvider), - aProvider, nsnull, - mBufferSegmentSize, - mBufferMaxSize); + NS_ASSERTION(provider, "need to supply an nsIStreamProvider"); + rv = NS_NewStreamProviderProxy(getter_AddRefs(mProvider), provider); if (NS_FAILED(rv)) return rv; NS_ASSERTION(mContext == nsnull, "context not released"); - mContext = aContext; - mOffset = aTransferOffset; - mTransferAmount = aTransferCount; + mContext = ctxt; mXferState = OPEN_FOR_WRITE; LOG(("nsFileTransport: AsyncWrite [this=%x %s] mOffset=%d mTransferAmount=%d\n", @@ -512,7 +473,6 @@ nsFileTransport::AsyncWrite(nsIStreamProvider *aProvider, rv = mService->DispatchRequest(this); if (NS_FAILED(rv)) return rv; - NS_ADDREF(*aResult = this); return NS_OK; } @@ -711,8 +671,8 @@ nsFileTransport::Process(void) LOG(("nsFileTransport: READING [this=%x %s] read %u bytes [offset=%u]\n", this, mStreamName.GetBuffer(), total, mOffset)); -// what about check for background flags! dougt - if (mProgress && (mTransferAmount >= 0)) { + if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND) + && (mTransferAmount >= 0)) { mProgress->OnProgress(this, mContext, mTotalAmount - mTransferAmount, mTotalAmount); @@ -744,8 +704,7 @@ nsFileTransport::Process(void) mListener->OnStopRequest(this, mContext, mStatus, nsnull); mListener = 0; } -// what about check for background flag! dougt - if (mProgress) { + if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND)) { nsAutoString fileName; fileName.AssignWithConversion(mStreamName); mProgress->OnStatus(this, mContext, @@ -758,6 +717,7 @@ nsFileTransport::Process(void) mSource = 0; NS_IF_RELEASE(mSourceWrapper); mSourceWrapper = nsnull; + mXferState = CLOSING; break; } @@ -883,8 +843,9 @@ nsFileTransport::Process(void) else LOG(("nsFileTransport: WRITING [this=%x %s] wrote %u bytes [offset=%u]\n", this, mStreamName.GetBuffer(), total, mOffset)); -// what about check for background flag dougt! - if (mProgress && (mTransferAmount >= 0)) + + if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND) + && (mTransferAmount >= 0)) mProgress->OnProgress(this, mContext, mTotalAmount - mTransferAmount, mTotalAmount); @@ -914,15 +875,16 @@ nsFileTransport::Process(void) NS_IF_RELEASE(mSinkWrapper); mSinkWrapper = nsnull; + nsresult rv; if (mProvider) { mProvider->OnStopRequest(this, mContext, mStatus, nsnull); mProvider = 0; } - if (mProgress) { + if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND)) { nsAutoString fileName; fileName.AssignWithConversion(mStreamName); - nsresult rv = mProgress->OnStatus(this, mContext, - NS_NET_STATUS_WROTE_TO, - fileName.GetUnicode()); + rv = mProgress->OnStatus(this, mContext, + NS_NET_STATUS_WROTE_TO, + fileName.GetUnicode()); NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnStatus failure"); } mContext = 0; @@ -966,7 +928,6 @@ nsFileTransport::DoClose(void) // other nsIChannel methods: //////////////////////////////////////////////////////////////////////////////// -#if 0 NS_IMETHODIMP nsFileTransport::GetOriginalURI(nsIURI* *aURI) { @@ -1044,6 +1005,90 @@ nsFileTransport::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsFileTransport::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::SetTransferOffset(PRUint32 aTransferOffset) +{ + mOffset = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mTransferAmount; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::SetTransferCount(PRInt32 aTransferCount) +{ + mTransferAmount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::GetLocalFile(nsIFile* *file) +{ + nsresult rv; + nsCOMPtr fileIO = do_QueryInterface(mStreamIO, &rv); + if (NS_FAILED(rv)) return rv; + + rv = fileIO->GetFile(file); + if (NS_FAILED(rv)) { + *file = nsnull; + } + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsFileTransport::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsFileTransport::GetOwner(nsISupports * *aOwner) { @@ -1106,7 +1151,6 @@ nsFileTransport::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCa return NS_OK; } -#endif NS_IMETHODIMP nsFileTransport::GetSecurityInfo(nsISupports * *aSecurityInfo) @@ -1115,34 +1159,4 @@ nsFileTransport::GetSecurityInfo(nsISupports * *aSecurityInfo) return NS_OK; } - -NS_IMETHODIMP -nsFileTransport::GetProgressEventSink(nsIProgressEventSink **aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - NS_IF_ADDREF(*aResult = mProgress); - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::SetProgressEventSink(nsIProgressEventSink *aProgress) -{ - mProgress = nsnull; - - if (aProgress) { - // Now generate a proxied event sink - nsresult rv; - NS_WITH_SERVICE(nsIProxyObjectManager, - proxyMgr, kProxyObjectManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - - rv = proxyMgr->GetProxyForObject(NS_UI_THREAD_EVENTQ, // primordial thread - should change? - NS_GET_IID(nsIProgressEventSink), - aProgress, - PROXY_ASYNC | PROXY_ALWAYS, - getter_AddRefs(mProgress)); - } - return NS_OK; -} - //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/base/src/nsFileTransport.h b/mozilla/netwerk/base/src/nsFileTransport.h index 30c66f9fb82..2379cc97a3e 100644 --- a/mozilla/netwerk/base/src/nsFileTransport.h +++ b/mozilla/netwerk/base/src/nsFileTransport.h @@ -23,8 +23,7 @@ #ifndef nsFileTransport_h__ #define nsFileTransport_h__ -#include "nsITransport.h" -#include "nsIRequest.h" +#include "nsIChannel.h" #include "nsIRunnable.h" #include "nsFileSpec.h" #include "prlock.h" @@ -50,15 +49,13 @@ class nsIInterfaceRequestor; class nsFileTransportSourceWrapper; class nsFileTransportSinkWrapper; -class nsFileTransport : public nsITransport, - public nsITransportRequest, +class nsFileTransport : public nsIChannel, public nsIRunnable { public: NS_DECL_ISUPPORTS - NS_DECL_NSITRANSPORT NS_DECL_NSIREQUEST - NS_DECL_NSITRANSPORTREQUEST + NS_DECL_NSICHANNEL NS_DECL_NSIRUNNABLE nsFileTransport(); @@ -101,6 +98,7 @@ public: }; protected: + nsCOMPtr mCallbacks; nsCOMPtr mProgress; nsCOMPtr mStreamIO; char *mContentType; @@ -127,6 +125,7 @@ protected: PRUint32 mOffset; PRInt32 mTotalAmount; PRInt32 mTransferAmount; + nsLoadFlags mLoadAttributes; // reading state variables: nsCOMPtr mListener; diff --git a/mozilla/netwerk/base/src/nsFileTransportService.cpp b/mozilla/netwerk/base/src/nsFileTransportService.cpp index d4e68254933..d2cfb5085b8 100644 --- a/mozilla/netwerk/base/src/nsFileTransportService.cpp +++ b/mozilla/netwerk/base/src/nsFileTransportService.cpp @@ -88,7 +88,7 @@ NS_IMETHODIMP nsFileTransportService::CreateTransport(nsIFile* file, PRInt32 ioFlags, PRInt32 perm, - nsITransport** result) + nsIChannel** result) { nsresult rv; nsFileTransport* trans = new nsFileTransport(); @@ -109,7 +109,7 @@ nsFileTransportService::CreateTransportFromStream(const char* name, nsIInputStream *fromStream, const char* contentType, PRInt32 contentLength, - nsITransport** result) + nsIChannel** result) { nsresult rv; nsFileTransport* trans = new nsFileTransport(); @@ -127,7 +127,7 @@ nsFileTransportService::CreateTransportFromStream(const char* name, NS_IMETHODIMP nsFileTransportService::CreateTransportFromStreamIO(nsIStreamIO *io, - nsITransport **result) + nsIChannel **result) { nsresult rv; nsFileTransport* trans = new nsFileTransport(); diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index b60f83f73bc..e5c5c8aba94 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -368,6 +368,40 @@ nsIOService::SetOffline(PRBool offline) } +NS_IMETHODIMP +nsIOService::ConsumeInput(nsIChannel* channel, nsISupports* context, + nsIStreamListener* consumer) +{ + nsresult rv; + nsCOMPtr in; + rv = channel->OpenInputStream(getter_AddRefs(in)); + if (NS_FAILED(rv)) return rv; + + rv = consumer->OnStartRequest(channel, context); + if (NS_FAILED(rv)) return rv; + + PRUint32 sourceOffset = 0; + while (1) { + char buf[1024]; + PRUint32 readCount; + rv = in->Read(buf, sizeof(buf), &readCount); + if (NS_FAILED(rv)) + break; + + if (readCount == 0) // eof + break; + + rv = consumer->OnDataAvailable(channel, context, 0, sourceOffset, readCount); + sourceOffset += readCount; + if (NS_FAILED(rv)) + break; + } + rv = consumer->OnStopRequest(channel, context, rv, nsnull); + if (NS_FAILED(rv)) return rv; + + return rv; +} + //////////////////////////////////////////////////////////////////////////////// // URL parsing utilities diff --git a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp index 591fece8403..c8ddef50f25 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp @@ -170,6 +170,9 @@ nsStreamIOChannel::Init(nsIURI* uri, nsIStreamIO* io) return NS_OK; } +NS_IMPL_THREADSAFE_ADDREF(nsStreamIOChannel) +NS_IMPL_THREADSAFE_RELEASE(nsStreamIOChannel) + NS_INTERFACE_MAP_BEGIN(nsStreamIOChannel) NS_INTERFACE_MAP_ENTRY(nsIStreamIOChannel) NS_INTERFACE_MAP_ENTRY(nsIChannel) @@ -180,8 +183,8 @@ NS_INTERFACE_MAP_BEGIN(nsStreamIOChannel) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener) NS_INTERFACE_MAP_END_THREADSAFE -NS_IMPL_THREADSAFE_ADDREF(nsStreamIOChannel) -NS_IMPL_THREADSAFE_RELEASE(nsStreamIOChannel) +//////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods: NS_IMETHODIMP nsStreamIOChannel::GetName(PRUnichar* *result) @@ -199,8 +202,8 @@ nsStreamIOChannel::GetName(PRUnichar* *result) NS_IMETHODIMP nsStreamIOChannel::IsPending(PRBool *result) { - if (mRequest) - return mRequest->IsPending(result); + if (mFileTransport) + return mFileTransport->IsPending(result); *result = PR_FALSE; return NS_OK; } @@ -212,8 +215,8 @@ nsStreamIOChannel::GetStatus(nsresult *status) // if we don't have a status error of our own to report // then we should propogate the status error of the underlying // file transport (if we have one) - if (NS_SUCCEEDED(mStatus) && mRequest) - mRequest->GetStatus(status); + if (NS_SUCCEEDED(mStatus) && mFileTransport) + mFileTransport->GetStatus(status); return NS_OK; } @@ -223,30 +226,29 @@ nsStreamIOChannel::Cancel(nsresult status) { NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code"); mStatus = status; - if (mRequest) - return mRequest->Cancel(status); + if (mFileTransport) + return mFileTransport->Cancel(status); return NS_OK; } NS_IMETHODIMP nsStreamIOChannel::Suspend(void) { - if (mRequest) - return mRequest->Suspend(); + if (mFileTransport) + return mFileTransport->Suspend(); return NS_OK; } NS_IMETHODIMP nsStreamIOChannel::Resume(void) { - if (mRequest) - return mRequest->Resume(); + if (mFileTransport) + return mFileTransport->Resume(); return NS_OK; } //////////////////////////////////////////////////////////////////////////////// -// nsIChannel implementation: -//////////////////////////////////////////////////////////////////////////////// +// nsIChannel methods: NS_IMETHODIMP nsStreamIOChannel::GetOriginalURI(nsIURI* *aURI) @@ -279,13 +281,19 @@ nsStreamIOChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsStreamIOChannel::Open(nsIInputStream **result) +nsStreamIOChannel::OpenInputStream(nsIInputStream **result) { return mStreamIO->GetInputStream(result); } NS_IMETHODIMP -nsStreamIOChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +nsStreamIOChannel::OpenOutputStream(nsIOutputStream **result) +{ + return mStreamIO->GetOutputStream(result); +} + +NS_IMETHODIMP +nsStreamIOChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; @@ -307,7 +315,7 @@ nsStreamIOChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) } } - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -317,6 +325,14 @@ nsStreamIOChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) rv = fts->CreateTransportFromStreamIO(mStreamIO, getter_AddRefs(mFileTransport)); if (NS_FAILED(rv)) goto done; + if (mBufferSegmentSize > 0) { + rv = mFileTransport->SetBufferSegmentSize(mBufferSegmentSize); + if (NS_FAILED(rv)) goto done; + } + if (mBufferMaxSize > 0) { + rv = mFileTransport->SetBufferMaxSize(mBufferMaxSize); + if (NS_FAILED(rv)) goto done; + } } #if 0 @@ -325,13 +341,78 @@ nsStreamIOChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) if (NS_FAILED(rv)) goto done; } #endif - rv = mFileTransport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(mRequest)); + rv = mFileTransport->AsyncRead(this, ctxt); done: if (NS_FAILED(rv)) { nsresult rv2; - rv2 = mLoadGroup->RemoveRequest(this, ctxt, rv, nsnull); - NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveRequest failed"); + rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); + NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); + // release the transport so that we don't think we're in progress + mFileTransport = nsnull; + } + return rv; +} + +NS_IMETHODIMP +nsStreamIOChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +{ + nsresult rv; + + NS_ASSERTION(provider, "no provider"); + SetProvider(provider); + + if (mLoadGroup) { + nsCOMPtr factory; + // + // Create a load group "proxy" listener... + // + rv = mLoadGroup->GetGroupListenerFactory(getter_AddRefs(factory)); + if (factory) { + NS_WARNING("load group proxy listener not implemented for AsyncWrite"); +#if 0 + nsIStreamListener *newListener; + rv = factory->CreateLoadGroupListener(GetListener(), &newListener); + if (NS_SUCCEEDED(rv)) { + mUserObserver = newListener; + NS_RELEASE(newListener); + } +#endif + } + + rv = mLoadGroup->AddChannel(this, nsnull); + if (NS_FAILED(rv)) return rv; + } + + if (mFileTransport == nsnull) { + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); + if (NS_FAILED(rv)) goto done; + + rv = fts->CreateTransportFromStreamIO(mStreamIO, getter_AddRefs(mFileTransport)); + if (NS_FAILED(rv)) goto done; + if (mBufferSegmentSize > 0) { + rv = mFileTransport->SetBufferSegmentSize(mBufferSegmentSize); + if (NS_FAILED(rv)) goto done; + } + if (mBufferMaxSize > 0) { + rv = mFileTransport->SetBufferMaxSize(mBufferMaxSize); + if (NS_FAILED(rv)) goto done; + } + } + +#if 0 + if (mContentType == nsnull) { + rv = mStreamIO->Open(&mContentType, &mContentLength); + if (NS_FAILED(rv)) goto done; + } +#endif + rv = mFileTransport->AsyncWrite(this, ctxt); + + done: + if (NS_FAILED(rv)) { + nsresult rv2; + rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); + NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); // release the transport so that we don't think we're in progress mFileTransport = nsnull; } @@ -352,58 +433,6 @@ nsStreamIOChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) return NS_OK; } -NS_IMETHODIMP -nsStreamIOChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) -{ - *aLoadGroup = mLoadGroup.get(); - NS_IF_ADDREF(*aLoadGroup); - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) -{ - mLoadGroup = aLoadGroup; - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::GetOwner(nsISupports* *aOwner) -{ - *aOwner = mOwner.get(); - NS_IF_ADDREF(*aOwner); - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::SetOwner(nsISupports* aOwner) -{ - mOwner = aOwner; - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) -{ - *aNotificationCallbacks = mCallbacks.get(); - NS_IF_ADDREF(*aNotificationCallbacks); - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) -{ - mCallbacks = aNotificationCallbacks; - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) -{ - *aSecurityInfo = nsnull; - return NS_OK; -} - NS_IMETHODIMP nsStreamIOChannel::GetContentType(char * *aContentType) { @@ -448,19 +477,149 @@ nsStreamIOChannel::SetContentLength(PRInt32 aContentLength) return NS_OK; } +NS_IMETHODIMP +nsStreamIOChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsStreamIOChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsStreamIOChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsStreamIOChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsStreamIOChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("nsStreamIOChannel::SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) +{ + *aLoadGroup = mLoadGroup.get(); + NS_IF_ADDREF(*aLoadGroup); + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) +{ + mLoadGroup = aLoadGroup; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetOwner(nsISupports* *aOwner) +{ + *aOwner = mOwner.get(); + NS_IF_ADDREF(*aOwner); + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetOwner(nsISupports* aOwner) +{ + mOwner = aOwner; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) +{ + *aNotificationCallbacks = mCallbacks.get(); + NS_IF_ADDREF(*aNotificationCallbacks); + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) +{ + mCallbacks = aNotificationCallbacks; + return NS_OK; +} + + +NS_IMETHODIMP +nsStreamIOChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +{ + *aSecurityInfo = nsnull; + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // nsIStreamObserver implementation: //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsStreamIOChannel::OnStartRequest(nsIRequest *request, nsISupports* context) +nsStreamIOChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) { NS_ASSERTION(mUserObserver, "No listener..."); return mUserObserver->OnStartRequest(this, context); } NS_IMETHODIMP -nsStreamIOChannel::OnStopRequest(nsIRequest *request, nsISupports* context, +nsStreamIOChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -472,7 +631,7 @@ nsStreamIOChannel::OnStopRequest(nsIRequest *request, nsISupports* context, if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - rv = mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); + rv = mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } } @@ -489,7 +648,7 @@ nsStreamIOChannel::OnStopRequest(nsIRequest *request, nsISupports* context, //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsStreamIOChannel::OnDataAvailable(nsIRequest *request, nsISupports* context, +nsStreamIOChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -502,9 +661,9 @@ nsStreamIOChannel::OnDataAvailable(nsIRequest *request, nsISupports* context, //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsStreamIOChannel::OnDataWritable(nsIRequest *request, nsISupports *context, - nsIOutputStream *aOStream, - PRUint32 aOffset, PRUint32 aLength) +nsStreamIOChannel::OnDataWritable(nsIChannel* transportChannel, nsISupports* context, + nsIOutputStream *aOStream, PRUint32 aOffset, + PRUint32 aLength) { return GetProvider()->OnDataWritable(this, context, aOStream, aOffset, aLength); diff --git a/mozilla/netwerk/base/src/nsInputStreamChannel.h b/mozilla/netwerk/base/src/nsInputStreamChannel.h index d94d375dd8b..8b1c5ec4c64 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.h +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.h @@ -32,7 +32,6 @@ #include "nsIStreamProvider.h" #include "nsIInterfaceRequestor.h" #include "nsIStreamIO.h" -#include "nsITransport.h" class nsInputStreamIO : public nsIInputStreamIO { @@ -91,8 +90,7 @@ protected: nsCOMPtr mStreamIO; nsCOMPtr mLoadGroup; nsCOMPtr mOwner; - nsCOMPtr mFileTransport; - nsCOMPtr mRequest; + nsCOMPtr mFileTransport; nsCOMPtr mUserObserver; PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; diff --git a/mozilla/netwerk/base/src/nsLoadGroup.cpp b/mozilla/netwerk/base/src/nsLoadGroup.cpp index f300db78719..6495691439e 100644 --- a/mozilla/netwerk/base/src/nsLoadGroup.cpp +++ b/mozilla/netwerk/base/src/nsLoadGroup.cpp @@ -56,7 +56,7 @@ PRLogModuleInfo* gLoadGroupLog = nsnull; nsLoadGroup::nsLoadGroup(nsISupports* outer) : mDefaultLoadAttributes(nsIChannel::LOAD_NORMAL), mForegroundCount(0), - mRequests(nsnull), + mChannels(nsnull), mStatus(NS_OK) { NS_INIT_AGGREGATED(outer); @@ -82,8 +82,8 @@ nsLoadGroup::~nsLoadGroup() rv = Cancel(NS_BINDING_ABORTED); NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed"); - NS_IF_RELEASE(mRequests); - mDefaultLoadRequest = null_nsCOMPtr(); + NS_IF_RELEASE(mChannels); + mDefaultLoadChannel = null_nsCOMPtr(); PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, ("LOADGROUP [%x]: Destroyed.\n", this)); @@ -92,7 +92,7 @@ nsLoadGroup::~nsLoadGroup() nsresult nsLoadGroup::Init() { - return NS_NewISupportsArray(&mRequests); + return NS_NewISupportsArray(&mChannels); } @@ -157,20 +157,19 @@ NS_IMETHODIMP nsLoadGroup::GetName(PRUnichar* *result) { // XXX is this the right "name" for a load group? - *result = nsnull; - - if (mDefaultLoadRequest) { - nsXPIDLString nameStr; - nsresult rv = mDefaultLoadRequest->GetName(getter_Copies(nameStr)); - if (NS_SUCCEEDED(rv)) { - nsString name; - name.Assign(nameStr); - *result = name.ToNewUnicode(); - return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } + nsresult rv; + nsXPIDLCString urlStr; + if (mDefaultLoadChannel) { + nsCOMPtr url; + rv = mDefaultLoadChannel->GetURI(getter_AddRefs(url)); + if (NS_FAILED(rv)) return rv; + rv = url->GetSpec(getter_Copies(urlStr)); + if (NS_FAILED(rv)) return rv; } - - return NS_OK; + nsString name; + name.AppendWithConversion(urlStr); + *result = name.ToNewUnicode(); + return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } NS_IMETHODIMP @@ -188,9 +187,9 @@ nsLoadGroup::IsPending(PRBool *aResult) NS_IMETHODIMP nsLoadGroup::GetStatus(nsresult *status) { - if (NS_SUCCEEDED(mStatus) && mDefaultLoadRequest) - return mDefaultLoadRequest->GetStatus(status); - + if (NS_SUCCEEDED(mStatus) && mDefaultLoadChannel) + return mDefaultLoadChannel->GetStatus(status); + *status = mStatus; return NS_OK; } @@ -207,57 +206,67 @@ nsLoadGroup::Cancel(nsresult status) mStatus = status; - rv = mRequests->Count(&count); + rv = mChannels->Count(&count); if (NS_FAILED(rv)) return rv; firstError = NS_OK; if (count) { - nsIRequest* request; + nsIChannel* channel; // // Operate the elements from back to front so that if items get // get removed from the list it won't affect our iteration // while (count > 0) { - request = NS_STATIC_CAST(nsIRequest*, mRequests->ElementAt(--count)); + channel = NS_STATIC_CAST(nsIChannel*, mChannels->ElementAt(--count)); - NS_ASSERTION(request, "NULL request found in list."); - if (!request) { + NS_ASSERTION(channel, "NULL channel found in list."); + if (!channel) { continue; } #if defined(PR_LOGGING) - nsXPIDLString nameStr; - request->GetName(getter_Copies(nameStr)); + char* uriStr; + nsCOMPtr uri; + + rv = channel->GetURI(getter_AddRefs(uri)); + if (NS_SUCCEEDED(rv)) { + rv = uri->GetSpec(&uriStr); + } + if (NS_FAILED(rv)) { + uriStr = nsCRT::strdup("?"); + } + PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Canceling request %x %s.\n", - this, request, NS_ConvertUCS2toUTF8(nameStr).get())); + ("LOADGROUP [%x]: Canceling channel %x %s.\n", + this, channel, uriStr)); + nsCRT::free(uriStr); #endif /* PR_LOGGING */ // - // Remove the request from the load group... This may cause + // Remove the channel from the load group... This may cause // the OnStopRequest notification to fire... // // XXX: What should the context and error message be? // - (void)RemoveRequest(request, nsnull, status, nsnull); + (void)RemoveChannel(channel, nsnull, status, nsnull); - // Cancel the request... - rv = request->Cancel(status); + // Cancel the channel... + rv = channel->Cancel(status); // Remember the first failure and return it... if (NS_FAILED(rv) && NS_SUCCEEDED(firstError)) { firstError = rv; } - NS_RELEASE(request); + NS_RELEASE(channel); } #if defined(DEBUG) - (void)mRequests->Count(&count); + (void)mChannels->Count(&count); - NS_ASSERTION(count == 0, "Request list is not empty."); + NS_ASSERTION(count == 0, "Channel list is not empty."); NS_ASSERTION(mForegroundCount == 0, "Foreground URLs are active."); #endif /* DEBUG */ } @@ -273,7 +282,7 @@ nsLoadGroup::Suspend() nsresult rv, firstError; PRUint32 count; - rv = mRequests->Count(&count); + rv = mChannels->Count(&count); if (NS_FAILED(rv)) return rv; firstError = NS_OK; @@ -282,30 +291,42 @@ nsLoadGroup::Suspend() // get removed from the list it won't affect our iteration // while (count > 0) { - nsIRequest* request = NS_STATIC_CAST(nsIRequest*, mRequests->ElementAt(--count)); + nsIChannel* channel; - NS_ASSERTION(request, "NULL request found in list."); - if (!request) { + channel = NS_STATIC_CAST(nsIChannel*, mChannels->ElementAt(--count)); + + NS_ASSERTION(channel, "NULL channel found in list."); + if (!channel) { continue; } #if defined(PR_LOGGING) - nsXPIDLString nameStr; - request->GetName(getter_Copies(nameStr)); - PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Suspending request %x %s.\n", - this, request, NS_ConvertUCS2toUTF8(nameStr).get())); + char* uriStr; + nsCOMPtr uri; + + rv = channel->GetURI(getter_AddRefs(uri)); + if (NS_SUCCEEDED(rv)) { + rv = uri->GetSpec(&uriStr); + } + if (NS_FAILED(rv)) { + uriStr = nsCRT::strdup("?"); + } + + PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, + ("LOADGROUP [%x]: Suspending channel %x %s.\n", + this, channel, uriStr)); + nsCRT::free(uriStr); #endif /* PR_LOGGING */ - // Suspend the request... - rv = request->Suspend(); + // Suspend the channel... + rv = channel->Suspend(); // Remember the first failure and return it... if (NS_FAILED(rv) && NS_SUCCEEDED(firstError)) { firstError = rv; } - NS_RELEASE(request); + NS_RELEASE(channel); } return firstError; @@ -318,7 +339,7 @@ nsLoadGroup::Resume() nsresult rv, firstError; PRUint32 count; - rv = mRequests->Count(&count); + rv = mChannels->Count(&count); if (NS_FAILED(rv)) return rv; firstError = NS_OK; @@ -327,30 +348,42 @@ nsLoadGroup::Resume() // get removed from the list it won't affect our iteration // while (count > 0) { - nsIRequest* request = NS_STATIC_CAST(nsIRequest*, mRequests->ElementAt(--count)); + nsIChannel* channel; - NS_ASSERTION(request, "NULL request found in list."); - if (!request) { + channel = NS_STATIC_CAST(nsIChannel*, mChannels->ElementAt(--count)); + + NS_ASSERTION(channel, "NULL channel found in list."); + if (!channel) { continue; } #if defined(PR_LOGGING) - nsXPIDLString nameStr; - request->GetName(getter_Copies(nameStr)); + char* uriStr; + nsCOMPtr uri; + + rv = channel->GetURI(getter_AddRefs(uri)); + if (NS_SUCCEEDED(rv)) { + rv = uri->GetSpec(&uriStr); + } + if (NS_FAILED(rv)) { + uriStr = nsCRT::strdup("?"); + } + PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Resuming request %x %s.\n", - this, request, NS_ConvertUCS2toUTF8(nameStr).get())); + ("LOADGROUP [%x]: Resuming channel %x %s.\n", + this, channel, uriStr)); + nsCRT::free(uriStr); #endif /* PR_LOGGING */ - // Resume the request... - rv = request->Resume(); + // Resume the channel... + rv = channel->Resume(); // Remember the first failure and return it... if (NS_FAILED(rv) && NS_SUCCEEDED(firstError)) { firstError = rv; } - NS_RELEASE(request); + NS_RELEASE(channel); } return firstError; @@ -384,46 +417,58 @@ nsLoadGroup::SetDefaultLoadAttributes(PRUint32 aDefaultLoadAttributes) } NS_IMETHODIMP -nsLoadGroup::GetDefaultLoadRequest(nsIRequest * *aRequest) +nsLoadGroup::GetDefaultLoadChannel(nsIChannel * *aChannel) { - *aRequest = mDefaultLoadRequest; - NS_IF_ADDREF(*aRequest); + *aChannel = mDefaultLoadChannel; + NS_IF_ADDREF(*aChannel); return NS_OK; } NS_IMETHODIMP -nsLoadGroup::SetDefaultLoadRequest(nsIRequest *aRequest) +nsLoadGroup::SetDefaultLoadChannel(nsIChannel *aChannel) { - mDefaultLoadRequest = aRequest; + mDefaultLoadChannel = aChannel; return NS_OK; } NS_IMETHODIMP -nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) +nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt) { nsresult rv; #if defined(PR_LOGGING) - PRUint32 count = 0; - (void)mRequests->Count(&count); - nsXPIDLString nameStr; - request->GetName(getter_Copies(nameStr)); + { + PRUint32 count; + char* uriStr; + nsCOMPtr uri; + rv = channel->GetURI(getter_AddRefs(uri)); + if (NS_SUCCEEDED(rv)) + rv = uri->GetSpec(&uriStr); + if (NS_FAILED(rv)) + uriStr = nsCRT::strdup("?"); + + (void)mChannels->Count(&count); PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Adding request %x %s (count=%d).\n", - this, request, NS_ConvertUCS2toUTF8(nameStr).get(), count)); + ("LOADGROUP [%x]: Adding channel %x %s (count=%d).\n", + this, channel, uriStr, count)); + nsCRT::free(uriStr); + } #endif /* PR_LOGGING */ nsLoadFlags flags; - rv = MergeLoadAttributes(request, flags); + + MergeLoadAttributes(channel); + + rv = channel->GetLoadAttributes(&flags); if (NS_FAILED(rv)) return rv; - + // - // Add the request to the list of active requests... + // Add the channel to the list of active channels... // // XXX this method incorrectly returns a bool // - rv = mRequests->AppendElement(request) ? NS_OK : NS_ERROR_FAILURE; + rv = mChannels->AppendElement(channel) ? NS_OK : NS_ERROR_FAILURE; if (NS_FAILED(rv)) return rv; if (!(flags & nsIChannel::LOAD_BACKGROUND)) { @@ -433,28 +478,28 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) // // Fire the OnStartRequest notification out to the observer... // - // If the notification fails then DO NOT add the request to + // If the notification fails then DO NOT add the channel to // the load group. // nsCOMPtr observer (do_QueryReferent(mObserver)); if (observer) { PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Firing OnStartRequest for request %x." + ("LOADGROUP [%x]: Firing OnStartRequest for channel %x." "(foreground count=%d).\n", - this, request, mForegroundCount)); + this, channel, mForegroundCount)); - rv = observer->OnStartRequest(request, ctxt); + rv = observer->OnStartRequest(channel, ctxt); if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, - ("LOADGROUP [%x]: OnStartRequest for request %x FAILED.\n", - this, request)); + ("LOADGROUP [%x]: OnStartRequest for channel %x FAILED.\n", + this, channel)); // // The URI load has been canceled by the observer. Clean up // the damage... // // XXX this method incorrectly returns a bool // - rv = mRequests->RemoveElement(request) ? NS_OK : NS_ERROR_FAILURE; + rv = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; mForegroundCount -= 1; } } @@ -464,43 +509,56 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) } NS_IMETHODIMP -nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, +nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; #if defined(PR_LOGGING) - PRUint32 count = 0; - (void)mRequests->Count(&count); - nsXPIDLString nameStr; - request->GetName(getter_Copies(nameStr)); - PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Removing request %x %s status %x (count=%d).\n", - this, request, NS_ConvertUCS2toUTF8(nameStr).get(), aStatus, count-1)); + { + PRUint32 count = 0; + char* uriStr; + nsCOMPtr uri; + + if (channel) { + rv = channel->GetURI(getter_AddRefs(uri)); + } + else { + rv = NS_ERROR_NULL_POINTER; + } + + if (NS_SUCCEEDED(rv)) + rv = uri->GetSpec(&uriStr); + if (NS_FAILED(rv)) + uriStr = nsCRT::strdup("?"); + + (void)mChannels->Count(&count); + + PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, + ("LOADGROUP [%x]: Removing channel %x %s status %x (count=%d).\n", + this, channel, uriStr, aStatus, count-1)); + nsCRT::free(uriStr); + } #endif /* PR_LOGGING */ // - // Remove the request from the group. If this fails, it means that - // the request was *not* in the group so do not update the foreground + // Remove the channel from the group. If this fails, it means that + // the channel was *not* in the group so do not update the foreground // count or it will get messed up... // // // XXX this method incorrectly returns a bool // - rv = mRequests->RemoveElement(request) ? NS_OK : NS_ERROR_FAILURE; + rv = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, - ("LOADGROUP [%x]: Unable to remove request %x. Not in group!\n", - this, request)); + ("LOADGROUP [%x]: Unable to remove channel %x. Not in group!\n", + this, channel)); return rv; } nsLoadFlags flags; - nsCOMPtr aChannel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; - - rv = aChannel->GetLoadAttributes(&flags); + rv = channel->GetLoadAttributes(&flags); if (NS_FAILED(rv)) return rv; if (!(flags & nsIChannel::LOAD_BACKGROUND)) { @@ -511,15 +569,15 @@ nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, nsCOMPtr observer (do_QueryReferent(mObserver)); if (observer) { PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Firing OnStopRequest for request %x." + ("LOADGROUP [%x]: Firing OnStopRequest for channel %x." "(foreground count=%d).\n", - this, request, mForegroundCount)); + this, channel, mForegroundCount)); - rv = observer->OnStopRequest(request, ctxt, aStatus, aStatusArg); + rv = observer->OnStopRequest(channel, ctxt, aStatus, aStatusArg); if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, - ("LOADGROUP [%x]: OnStopRequest for request %x FAILED.\n", - this, request)); + ("LOADGROUP [%x]: OnStopRequest for channel %x FAILED.\n", + this, channel)); } } } @@ -530,9 +588,9 @@ nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, NS_IMETHODIMP -nsLoadGroup::GetRequests(nsISimpleEnumerator * *aRequests) +nsLoadGroup::GetChannels(nsISimpleEnumerator * *aChannels) { - return NS_NewArrayEnumerator(aRequests, mRequests); + return NS_NewArrayEnumerator(aChannels, mChannels); } @@ -601,18 +659,13 @@ nsLoadGroup::GetActiveCount(PRUint32* aResult) //////////////////////////////////////////////////////////////////////////////// -nsresult nsLoadGroup::MergeLoadAttributes(nsIRequest *aRequest, nsLoadFlags& outFlags) +nsresult nsLoadGroup::MergeLoadAttributes(nsIChannel *aChannel) { nsresult rv; nsLoadFlags flags, oldFlags; - nsCOMPtr aChannel = do_QueryInterface(aRequest, &rv); - if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; - rv = aChannel->GetLoadAttributes(&flags); - if (NS_FAILED(rv)) - return rv; + if (NS_FAILED(rv)) return rv; oldFlags = flags; // @@ -654,7 +707,6 @@ nsresult nsLoadGroup::MergeLoadAttributes(nsIRequest *aRequest, nsLoadFlags& out rv = aChannel->SetLoadAttributes(flags); } - outFlags = flags; - return rv; } + diff --git a/mozilla/netwerk/base/src/nsLoadGroup.h b/mozilla/netwerk/base/src/nsLoadGroup.h index 5c505c9de26..94adcc8e0a1 100644 --- a/mozilla/netwerk/base/src/nsLoadGroup.h +++ b/mozilla/netwerk/base/src/nsLoadGroup.h @@ -59,20 +59,21 @@ protected: virtual ~nsLoadGroup(); nsresult Init(); - nsresult MergeLoadAttributes(nsIRequest *aRequest, nsLoadFlags& flags); + nsresult MergeLoadAttributes(nsIChannel *aChannel); protected: PRUint32 mDefaultLoadAttributes; PRUint32 mForegroundCount; - nsCOMPtr mDefaultLoadRequest; - nsISupportsArray* mRequests; + nsISupportsArray* mChannels; - nsWeakPtr mObserver; + nsWeakPtr mObserver; // nsCOMPtr mObserver; - + nsCOMPtr mDefaultLoadChannel; + nsWeakPtr mGroupListenerFactory; - nsresult mStatus; + + nsresult mStatus; }; #endif // nsLoadGroup_h__ diff --git a/mozilla/netwerk/base/src/nsSimpleStreamListener.cpp b/mozilla/netwerk/base/src/nsSimpleStreamListener.cpp index 2023970875f..e3a184edef2 100644 --- a/mozilla/netwerk/base/src/nsSimpleStreamListener.cpp +++ b/mozilla/netwerk/base/src/nsSimpleStreamListener.cpp @@ -38,21 +38,21 @@ NS_IMPL_ISUPPORTS3(nsSimpleStreamListener, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsSimpleStreamListener::OnStartRequest(nsIRequest *aRequest, +nsSimpleStreamListener::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { return mObserver ? - mObserver->OnStartRequest(aRequest, aContext) : NS_OK; + mObserver->OnStartRequest(aChannel, aContext) : NS_OK; } NS_IMETHODIMP -nsSimpleStreamListener::OnStopRequest(nsIRequest* request, +nsSimpleStreamListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { return mObserver ? - mObserver->OnStopRequest(request, aContext, aStatus, aStatusText) : NS_OK; + mObserver->OnStopRequest(aChannel, aContext, aStatus, aStatusText) : NS_OK; } // @@ -61,7 +61,7 @@ nsSimpleStreamListener::OnStopRequest(nsIRequest* request, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsSimpleStreamListener::OnDataAvailable(nsIRequest* request, +nsSimpleStreamListener::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aSource, PRUint32 aOffset, diff --git a/mozilla/netwerk/base/src/nsSimpleStreamProvider.cpp b/mozilla/netwerk/base/src/nsSimpleStreamProvider.cpp index f6d70794afd..90c04f42076 100644 --- a/mozilla/netwerk/base/src/nsSimpleStreamProvider.cpp +++ b/mozilla/netwerk/base/src/nsSimpleStreamProvider.cpp @@ -39,21 +39,21 @@ NS_IMPL_ISUPPORTS3(nsSimpleStreamProvider, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsSimpleStreamProvider::OnStartRequest(nsIRequest *request, +nsSimpleStreamProvider::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { return mObserver ? - mObserver->OnStartRequest(request, aContext) : NS_OK; + mObserver->OnStartRequest(aChannel, aContext) : NS_OK; } NS_IMETHODIMP -nsSimpleStreamProvider::OnStopRequest(nsIRequest* request, +nsSimpleStreamProvider::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { return mObserver ? - mObserver->OnStopRequest(request, aContext, aStatus, aStatusText) : NS_OK; + mObserver->OnStopRequest(aChannel, aContext, aStatus, aStatusText) : NS_OK; } // @@ -62,7 +62,7 @@ nsSimpleStreamProvider::OnStopRequest(nsIRequest* request, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsSimpleStreamProvider::OnDataWritable(nsIRequest *request, +nsSimpleStreamProvider::OnDataWritable(nsIChannel *aChannel, nsISupports *aContext, nsIOutputStream *aOutput, PRUint32 aOffset, diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index 4cd950d8c7f..93324c465ab 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -54,6 +54,193 @@ static NS_DEFINE_CID(kDNSService, NS_DNSSERVICE_CID); static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); +// +//---------------------------------------------------------------------------- +// nsSocketInputStream +//---------------------------------------------------------------------------- +// +class nsSocketInputStream : public nsIInputStream +{ +public: + NS_DECL_ISUPPORTS + + nsSocketInputStream() + : mBytesRead(0), + mSocketFD(nsnull), + mWouldBlock(PR_FALSE) + { NS_INIT_ISUPPORTS(); } + virtual ~nsSocketInputStream() {} + + void SetSocketFD(PRFileDesc *aSocketFD) { + mSocketFD = aSocketFD; + } + PRUint32 GetBytesRead() { + return mBytesRead; + } + void ZeroBytesRead() { + mBytesRead = 0; + } + PRBool GotWouldBlock() { + return mWouldBlock; + } + + // + // nsIInputStream implementation... + // + NS_IMETHOD Close() { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD Available(PRUint32 *aCount) { + NS_PRECONDITION(mSocketFD, "null socket fd"); + PRInt32 avail = PR_Available(mSocketFD); + if (avail >= 0) { + *aCount = avail; + return NS_OK; + } + else + return NS_ERROR_FAILURE; + } + NS_IMETHOD Read(char *aBuf, PRUint32 aCount, PRUint32 *aBytesRead) { + NS_PRECONDITION(mSocketFD, "null socket fd"); + PRInt32 result = PR_Read(mSocketFD, aBuf, aCount); + LOG(("nsSocketTransport: PR_Read(count=%u) returned %d\n", aCount, result)); + mWouldBlock = PR_FALSE; + nsresult rv = NS_OK; + if (result < 0) { + PRErrorCode code = PR_GetError(); + if (PR_WOULD_BLOCK_ERROR == code) { + LOG(("nsSocketTransport: PR_Read() failed with PR_WOULD_BLOCK_ERROR\n")); + rv = NS_BASE_STREAM_WOULD_BLOCK; + mWouldBlock = PR_TRUE; + } + else { + LOG(("nsSocketTransport: PR_Read() failed [error=%x, os_error=%x]\n", + code, PR_GetOSError())); + rv = NS_ERROR_FAILURE; + } + *aBytesRead = 0; + } + else { + *aBytesRead = result; + mBytesRead += result; + } + return rv; + } + NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void *aClosure, + PRUint32 aCount, PRUint32 *aBytesRead) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD GetNonBlocking(PRBool *aValue) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD GetObserver(nsIInputStreamObserver **aObserver) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD SetObserver(nsIInputStreamObserver *aObserver) { + return NS_ERROR_NOT_IMPLEMENTED; + } + +protected: + PRUint32 mBytesRead; + PRFileDesc *mSocketFD; + PRBool mWouldBlock; +}; + +NS_IMPL_ISUPPORTS1(nsSocketInputStream, nsIInputStream) + +// +//---------------------------------------------------------------------------- +// nsSocketOutputStream +//---------------------------------------------------------------------------- +// +class nsSocketOutputStream : public nsIOutputStream +{ +public: + NS_DECL_ISUPPORTS + + nsSocketOutputStream() + : mBytesWritten(0), + mSocketFD(nsnull), + mWouldBlock(PR_FALSE) + { NS_INIT_ISUPPORTS(); } + virtual ~nsSocketOutputStream() {} + + void SetSocketFD(PRFileDesc *aSocketFD) { + mSocketFD = aSocketFD; + } + PRUint32 GetBytesWritten() { + return mBytesWritten; + } + void ZeroBytesWritten() { + mBytesWritten = 0; + } + PRBool GotWouldBlock() { + return mWouldBlock; + } + + // + // nsIInputStream implementation... + // + NS_IMETHOD Close() { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD Flush() { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *aBytesWritten) { + NS_PRECONDITION(mSocketFD, "null socket fd"); + PRInt32 result = PR_Write(mSocketFD, aBuf, aCount); + LOG(("nsSocketTransport: PR_Write(count=%u) returned %d\n", aCount, result)); + mWouldBlock = PR_FALSE; + nsresult rv = NS_OK; + if (result < 0) { + PRErrorCode code = PR_GetError(); + if (PR_WOULD_BLOCK_ERROR == code) { + LOG(("nsSocketTransport: PR_Write() failed with PR_WOULD_BLOCK_ERROR\n")); + rv = NS_BASE_STREAM_WOULD_BLOCK; + mWouldBlock = PR_TRUE; + } else { + LOG(("nsSocketTransport: PR_Write() failed [error=%x, os_error=%x]\n", + code, PR_GetOSError())); + rv = NS_ERROR_FAILURE; + } + *aBytesWritten = 0; + } + else { + *aBytesWritten = result; + mBytesWritten += result; + } + return rv; + } + NS_IMETHOD WriteFrom(nsIInputStream *aIS, PRUint32 aCount, PRUint32 *aBytesWritten) { + NS_NOTREACHED("WriteFrom"); + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void *aClosure, + PRUint32 aCount, PRUint32 *aBytesWritten) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD GetNonBlocking(PRBool *aValue) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD SetNonBlocking(PRBool aValue) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD GetObserver(nsIOutputStreamObserver **aObserver) { + return NS_ERROR_NOT_IMPLEMENTED; + } + NS_IMETHOD SetObserver(nsIOutputStreamObserver *aObserver) { + return NS_ERROR_NOT_IMPLEMENTED; + } + +protected: + PRUint32 mBytesWritten; + PRFileDesc *mSocketFD; + PRBool mWouldBlock; +}; + +NS_IMPL_ISUPPORTS1(nsSocketOutputStream, nsIOutputStream) + // //---------------------------------------------------------------------------- // nsSocketTransport @@ -123,9 +310,14 @@ static PRUint32 sTotalTransportsDeleted = 0; nsSocketTransport::nsSocketTransport(): mSocketTimeout(PR_INTERVAL_NO_TIMEOUT), mSocketConnectTimeout(PR_MillisecondsToInterval(DEFAULT_SOCKET_CONNECT_TIMEOUT_IN_MS)), + mOnStartWriteFired(PR_FALSE), + mOnStartReadFired(PR_FALSE), + mCancelStatus(NS_OK), + mCloseConnectionOnceDone(PR_FALSE), mCurrentState(eSocketState_Created), mHostName(nsnull), mPort(0), + mLoadAttributes(LOAD_NORMAL), mMonitor(nsnull), mOperation(eSocketOperation_None), mProxyPort(0), @@ -136,21 +328,22 @@ nsSocketTransport::nsSocketTransport(): mReadWriteState(0), mSelectFlags(0), mStatus(NS_OK), + mSuspendCount(0), mSocketFD(nsnull), mSocketTypeCount(0), mSocketTypes(nsnull), + mReadOffset(0), + mWriteOffset(0), + mWriteCount(0), mBytesExpected(-1), mReuseCount(0), mLastReuseCount(0), + mSocketInputStream(nsnull), + mSocketOutputStream(nsnull), mBufferSegmentSize(0), mBufferMaxSize(0), mIdleTimeoutInSeconds(0), - mBIS(nsnull), - mBOS(nsnull), - mReadRequest(nsnull), - mWriteRequest(nsnull), - mCloseConnectionOnceDone(PR_FALSE), - mWasConnected(PR_FALSE) + mWasConnected (PR_FALSE) { NS_INIT_REFCNT(); @@ -188,6 +381,20 @@ nsSocketTransport::~nsSocketTransport() LOG(("nsSocketTransport: Deleting [%s:%d %x], TotalCreated=%d, TotalDeleted=%d\n", mHostName, mPort, this, sTotalTransportsCreated, ++sTotalTransportsDeleted)); + // Release the nsCOMPtrs... + // + // It is easier to debug problems if these are released before the + // nsSocketTransport context is lost... + // + mReadListener = 0; + mReadContext = 0; + mReadPipeIn = 0; + mReadPipeOut = 0; + + //mWriteProvider = 0; + mWriteContext = 0; + mWritePipeIn = 0; + mWritePipeOut = 0; // // Cancel any pending DNS request... // @@ -197,11 +404,8 @@ nsSocketTransport::~nsSocketTransport() } CloseConnection(); - - if (mService) { - PR_AtomicDecrement(&mService->mTotalTransports); - NS_RELEASE(mService); - } + + NS_IF_RELEASE(mService); CRTFREEIF(mProxyHost); CRTFREEIF(mHostName); @@ -216,6 +420,9 @@ nsSocketTransport::~nsSocketTransport() nsAutoMonitor::DestroyMonitor(mMonitor); mMonitor = nsnull; } + + if (mService) + PR_AtomicDecrement(&mService->mTotalTransports); } @@ -256,6 +463,10 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, rv = NS_ERROR_OUT_OF_MEMORY; } + nsCOMPtr spService(do_GetService(kSocketProviderService)); + if (!spService) + rv = NS_ERROR_FAILURE; + if (NS_SUCCEEDED(rv) && aSocketTypeCount) { mSocketTypes = (char**) nsMemory::Alloc(aSocketTypeCount * sizeof(char*)); if (!mSocketTypes) @@ -269,6 +480,15 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, #ifdef DEBUG LOG(("nsSocketTransport: pushing io layer: %s\n", socketType)); #endif + + // Before doing anything else, make sure we can get a + // provider for this type of socket. + + nsCOMPtr sProvider; + rv = spService->GetSocketProvider(socketType, getter_AddRefs(sProvider)); + if (NS_FAILED(rv)) + break; + mSocketTypes[mSocketTypeCount] = nsCRT::strdup(socketType); if (!mSocketTypes[mSocketTypeCount]) { rv = NS_ERROR_OUT_OF_MEMORY; @@ -309,7 +529,7 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, } -nsresult nsSocketTransport::CheckForTimeout(PRIntervalTime aCurrentTime) +nsresult nsSocketTransport::CheckForTimeout (PRIntervalTime aCurrentTime) { nsresult rv = NS_OK; PRIntervalTime idleInterval; @@ -317,26 +537,26 @@ nsresult nsSocketTransport::CheckForTimeout(PRIntervalTime aCurrentTime) // Enter the socket transport lock... nsAutoMonitor mon(mMonitor); - if (aCurrentTime > mLastActiveTime) { + if (aCurrentTime > mLastActiveTime) idleInterval = aCurrentTime - mLastActiveTime; + else + idleInterval = 0; - if ((mSocketConnectTimeout != PR_INTERVAL_NO_TIMEOUT) && - (mCurrentState == eSocketState_WaitConnect) && - (idleInterval >= mSocketConnectTimeout) - || - (mSocketTimeout != PR_INTERVAL_NO_TIMEOUT) && - (mCurrentState == eSocketState_WaitReadWrite) && - (idleInterval >= mSocketTimeout)) - { - LOG(("nsSocketTransport: CheckForTimeout() [%s:%d %x].\t" - "TIMED OUT... Idle interval: %d\n", - mHostName, mPort, this, idleInterval)); - - // Move the transport into the Timeout state... - mCurrentState = eSocketState_Timeout; - rv = NS_ERROR_NET_TIMEOUT; - } + if (mSocketConnectTimeout != PR_INTERVAL_NO_TIMEOUT && mCurrentState == eSocketState_WaitConnect + && idleInterval >= mSocketConnectTimeout + || + mSocketTimeout != PR_INTERVAL_NO_TIMEOUT && mCurrentState == eSocketState_WaitReadWrite + && idleInterval >= mSocketTimeout) + { + LOG(("nsSocketTransport: CheckForTimeout() [%s:%d %x].\t" + "TIMED OUT... Idle interval: %d\n", + mHostName, mPort, this, idleInterval)); + + // Move the transport into the Timeout state... + mCurrentState = eSocketState_Timeout; + rv = NS_ERROR_NET_TIMEOUT; } + return rv; } @@ -358,7 +578,53 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) if (mOperation == eSocketOperation_None) done = PR_TRUE; // nothing to process + // + // Check for an error during PR_Poll(...) + // + if (PR_POLL_EXCEPT & aSelectFlags) { + LOG(("nsSocketTransport: Operation failed via PR_POLL_EXCEPT. [host=%s:%d this=%x].\n", + mHostName, mPort, this)); + // An error has occurred, so cancel the read and/or write operation... + if (mCurrentState == eSocketState_WaitConnect) + mStatus = NS_ERROR_CONNECTION_REFUSED; + else + mStatus = NS_BINDING_FAILED; + } + + if (PR_POLL_HUP & aSelectFlags) { + LOG(("nsSocketTransport: Operation failed via PR_POLL_HUP. [host=%s:%d this=%x].\n", + mHostName, mPort, this)); + if (mCurrentState == eSocketState_WaitConnect) + mStatus = NS_ERROR_CONNECTION_REFUSED; + else + mStatus = NS_OK; + mCurrentState = eSocketState_Error; + } + while (!done) { + // + // If the transport has been canceled then set the cancel status as + // the transport's status. This will cause the transport to move + // into the error state and end the request. + // + if (NS_FAILED(mCancelStatus)) { + LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] has been cancelled.\n", + mHostName, mPort, this)); + + mStatus = mCancelStatus; + mCancelStatus = NS_OK; + } + // + // If the transport has been suspended, then return NS_OK immediately. + // This removes the transport from the select list. + // + else if (mSuspendCount) { + LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] is suspended.\n", + mHostName, mPort, this)); + mStatus = NS_OK; + break; + } + // // If an error has occurred then move into the error state... // @@ -378,28 +644,34 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) case eSocketState_Connected: LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] is in Connected state.\n", mHostName, mPort, this)); - // // A connection has been established with the server // PR_AtomicIncrement(&mService->mConnectedTransports); mWasConnected = PR_TRUE; - // Send status message - OnStatus(NS_NET_STATUS_CONNECTED_TO); - - // Initialize select flags mSelectFlags = PR_POLL_EXCEPT; - if (mReadRequest) { + if (GetReadType() != eSocketRead_None) { + // Set the select flags for non-blocking reads... mSelectFlags |= PR_POLL_READ; - mReadRequest->OnStart(); - mReadRequest->SetSocket(mSocketFD); + + // Fire a notification that the read has started... + if (mReadListener && !mOnStartReadFired) { + mOnStartReadFired = PR_TRUE; + mReadListener->OnStartRequest(this, mReadContext); + } } - if (mWriteRequest) { + + if (GetWriteType() != eSocketWrite_None) { + // Set the select flags for non-blocking writes... mSelectFlags |= PR_POLL_WRITE; - mWriteRequest->OnStart(); - mWriteRequest->SetSocket(mSocketFD); + + // Fire a notification that the write has started... + if (mWriteProvider && !mOnStartWriteFired) { + mOnStartWriteFired = PR_TRUE; + mWriteProvider->OnStartRequest(this, mWriteContext); + } } break; @@ -413,13 +685,11 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) mDNSRequest = 0; } - // Set the error status on the request(s) - if (mReadRequest) - mReadRequest->SetStatus(mStatus); - if (mWriteRequest) - mWriteRequest->SetStatus(mStatus); + // Cancel any read and/or write requests... + SetFlag(eSocketRead_Done); + SetFlag(eSocketWrite_Done); - mCloseConnectionOnceDone = PR_TRUE; + CloseConnection(); // // Fall into the Done state... @@ -428,45 +698,136 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] is in Done state.\n", mHostName, mPort, this)); - if (mReadRequest) - CompleteAsyncRead(); + mBytesExpected = -1; - if (mWriteRequest) - CompleteAsyncWrite(); + if (GetFlag(eSocketRead_Done)) { + // Fire a notification that the read has finished... + if (mReadListener) { + if (!mOnStartReadFired) { + mOnStartReadFired = PR_TRUE; + mReadListener->OnStartRequest(this, mReadContext); + } + mReadListener->OnStopRequest(this, mReadContext, mStatus, nsnull); + mReadListener = 0; + mReadContext = 0; + } - // Close connection if expected to do so... - if (mCloseConnectionOnceDone) - CloseConnection(); + if (mSocketInputStream) { + NS_RELEASE(mSocketInputStream); + mSocketInputStream = 0; + } - mCurrentState = gStateTable[mOperation][mCurrentState]; - mOperation = eSocketOperation_None; - mStatus = NS_OK; - done = PR_TRUE; + // Close the socket transport end of the pipe... + if (mReadPipeOut) { + mReadPipeOut->Close(); + mReadPipeIn = 0; + } + mReadPipeOut = 0; + + SetReadType(eSocketRead_None); + ClearFlag(eSocketRead_Done); + + // When we have finished reading from the server + // close connection if required to do so... + if (mCloseConnectionOnceDone) + CloseConnection(); + } /* eSocketRead_Done */ + + if (GetFlag(eSocketWrite_Done)) { + // Fire a notification that the write has finished... + if (mWriteProvider) { + if (!mOnStartWriteFired) { + mOnStartWriteFired = PR_TRUE; + mWriteProvider->OnStartRequest(this, mWriteContext); + } + mWriteProvider->OnStopRequest(this, mWriteContext, mStatus, nsnull); + mWriteProvider = 0; + mWriteContext = 0; + } + + if (mSocketOutputStream) { + NS_RELEASE(mSocketOutputStream); + mSocketOutputStream = 0; + } + + // Close down the pipe + if (mWritePipeIn) + mWritePipeIn->Close(); + if (mWritePipeOut) + mWritePipeOut->Close(); + mWritePipeIn = 0; + mWritePipeOut = 0; + + SetWriteType(eSocketWrite_None); + ClearFlag(eSocketWrite_Done); + + // Close down the pipe + if (mCloseConnectionOnceDone) + CloseConnection (); + } /* eSocketWrite_Done */ + + // + // Are all read and write requests done? + // + if ((GetReadType() == eSocketRead_None) && + (GetWriteType() == eSocketWrite_None)) { + mCurrentState = gStateTable[mOperation][mCurrentState]; + mOperation = eSocketOperation_None; + mStatus = NS_OK; + done = PR_TRUE; + } + else { + // Still reading or writing... + mCurrentState = eSocketState_WaitReadWrite; + } continue; case eSocketState_WaitDNS: LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] is in WaitDNS state.\n", mHostName, mPort, this)); mStatus = doResolveHost(); - - // Send status message - OnStatus(NS_NET_STATUS_RESOLVING_HOST); break; case eSocketState_WaitConnect: LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] is in WaitConnect state.\n", mHostName, mPort, this)); mStatus = doConnection(aSelectFlags); - - // Send status message - OnStatus(NS_NET_STATUS_CONNECTING_TO); break; case eSocketState_WaitReadWrite: LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] " "is in WaitReadWrite state [readtype=%x writetype=%x status=%x].\n", mHostName, mPort, this, GetReadType(), GetWriteType(), mStatus)); - mStatus = doReadWrite(aSelectFlags); + // Process the read request... + if (GetReadType() != eSocketRead_None) { + if (mBytesExpected == 0) { + mStatus = NS_OK; + mSelectFlags &= (~PR_POLL_READ); + } + else if (GetFlag(eSocketRead_Async)) + mStatus = doReadAsync(aSelectFlags); + else + mStatus = doRead(aSelectFlags); + + if (NS_SUCCEEDED(mStatus)) { + SetFlag(eSocketRead_Done); + break; + } + } + + if (NS_FAILED(mStatus) && (mStatus != NS_BASE_STREAM_WOULD_BLOCK)) + break; + + // Process the write request... + if (GetWriteType() != eSocketWrite_None) { + if (GetFlag(eSocketWrite_Async)) + mStatus = doWriteAsync(aSelectFlags); + else + mStatus = doWrite(aSelectFlags); + + if (NS_SUCCEEDED(mStatus)) + SetFlag(eSocketWrite_Done); + } break; case eSocketState_Timeout: @@ -481,6 +842,10 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) break; } + // Notify the nsIProgressEventSink of the progress... + if (!(nsIChannel::LOAD_BACKGROUND & mLoadAttributes)) + fireStatus(mCurrentState); + // // If the current state has successfully completed, then move to the // next state for the current operation... @@ -500,60 +865,13 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) mLastActiveTime = PR_IntervalNow(); LOG(("nsSocketTransport: Leaving Process() [host=%s:%d this=%x], mStatus = %x, " - "CurrentState=%d, mSelectFlags=%x\n\n", - mHostName, mPort, this, mStatus, mCurrentState, mSelectFlags)); + "CurrentState=%d\n\n", + mHostName, mPort, this, mStatus, mCurrentState)); PR_ExitMonitor(mMonitor); return mStatus; } -nsresult -nsSocketTransport::Cancel(nsresult status) -{ - // - // Cancel any existing requests - // - if (mReadRequest) - mReadRequest->Cancel(status); - if (mWriteRequest) - mWriteRequest->Cancel(status); - return NS_OK; -} - -void -nsSocketTransport::CompleteAsyncRead() -{ - LOG(("nsSocketTransport: CompleteAsyncRead [this=%x]\n", this)); - - // order here is not important since we are called from within the monitor - - SetFlag(eSocketRead_Done); - SetReadType(eSocketRead_None); - - mSelectFlags &= ~PR_POLL_READ; - mBytesExpected = -1; - - mReadRequest->OnStop(); - NS_RELEASE(mReadRequest); - mReadRequest = nsnull; -} - -void -nsSocketTransport::CompleteAsyncWrite() -{ - LOG(("nsSocketTransport: CompleteAsyncWrite [this=%x]\n", this)); - - // order here is not important since we are called from within the monitor - - SetFlag(eSocketWrite_Done); - SetWriteType(eSocketWrite_None); - - mSelectFlags &= ~PR_POLL_WRITE; - - mWriteRequest->OnStop(); - NS_RELEASE(mWriteRequest); - mWriteRequest = nsnull; -} //----- // @@ -717,16 +1035,21 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags) if (!NS_SUCCEEDED(rv) || !mSocketFD) break; - // if the service was ssl or tls, we want to hold onto the socket info + // if the service was ssl, we want to hold onto the socket info if (nsCRT::strcmp(mSocketTypes[type], "ssl") == 0 || nsCRT::strcmp(mSocketTypes[type], "tls") == 0) { mSecurityInfo = socketInfo; + nsCOMPtr secinfo(do_QueryInterface(mSecurityInfo)); + if (secinfo) + secinfo->SetChannel(this); } else if (nsCRT::strcmp(mSocketTypes[type], "ssl-forcehandshake") == 0) { mSecurityInfo = socketInfo; nsCOMPtr securityInfo = do_QueryInterface(mSecurityInfo, &rv); - if (NS_SUCCEEDED(rv) && securityInfo) + if (NS_SUCCEEDED(rv) && securityInfo) { securityInfo->SetForceHandshake(PR_TRUE); + securityInfo->SetChannel(this); + } } else if (nsCRT::strcmp(mSocketTypes[type], "socks") == 0) { // since socks is transparent, any layers above @@ -810,11 +1133,7 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags) if (PR_POLL_EXCEPT & aSelectFlags) { LOG(("nsSocketTransport: Connection Refused via PR_POLL_EXCEPT. [%s:%d %x].\n", mHostName, mPort, this)); - rv = NS_ERROR_CONNECTION_REFUSED; - } - else if (PR_POLL_HUP & aSelectFlags) { - LOG(("nsSocketTransport: Connection Refused via PR_POLL_HUP. [%s:%d %x].\n", - mHostName, mPort, this)); + rv = NS_ERROR_CONNECTION_REFUSED; } // @@ -844,158 +1163,492 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags) return rv; } -nsresult -nsSocketTransport::doBlockingConnection() + +typedef struct { + PRFileDesc *fd; + PRBool bEOF; +} nsReadFromSocketClosure; + + +static NS_METHOD +nsReadFromSocket(nsIOutputStream* out, + void* closure, + char* toRawSegment, + PRUint32 offset, + PRUint32 count, + PRUint32 *readCount) { nsresult rv = NS_OK; + PRInt32 len; + nsReadFromSocketClosure *info = (nsReadFromSocketClosure*)closure; - // - // The hostname has not been resolved yet... - // - if (PR_IsNetAddrType(&mNetAddress, PR_IpAddrAny)) { - NS_WITH_SERVICE(nsIDNSService, - pDNSService, - kDNSService, - &rv); - if (NS_FAILED(rv)) return rv; - - nsXPIDLCString result; - const char *host = (mProxyHost && !mProxyTransparent) ? mProxyHost : mHostName; - rv = pDNSService->Resolve(host, getter_Copies(result)); - if (NS_FAILED(rv)) return rv; - - LOG(("nsSocketTransport: doBlockingConnection [this=%x] resolved host=%s ==> %s\n", - this, host, result.get())); - - PRNetAddr addr; - PRStatus st = PR_StringToNetAddr(result, &addr); - if (st != PR_SUCCESS) { - LOG(("nsSocketTransport: doBlockingConnection [this=%x] host resolution failed\n", this)); - return NS_ERROR_FAILURE; - } - - if (addr.raw.family == PR_AF_INET) - PR_ConvertIPv4AddrToIPv6(addr.inet.ip, &mNetAddress.ipv6.ip); - else - memcpy(&mNetAddress.ipv6.ip, &addr.ipv6.ip, sizeof(mNetAddress.ipv6.ip)); - - mNetAddress.ipv6.port - = PR_htons(((mProxyPort != -1 && !mProxyTransparent) ? mProxyPort : mPort)); - - LOG(("address { family=%hu, port=%hu }\n", - mNetAddress.ipv6.family, PR_ntohs(mNetAddress.ipv6.port))); - } - - // - // The connection has not been established yet... - // - if (!mSocketFD) { - mCurrentState = eSocketState_WaitConnect; - rv = doConnection(0); - if (NS_FAILED(rv)) { - if (rv != NS_BASE_STREAM_WOULD_BLOCK) - return rv; - PRPollDesc pd; - PRIntervalTime pollTimeout = PR_MillisecondsToInterval(DEFAULT_POLL_TIMEOUT_IN_MS); - PRInt32 result; - do { - pd.fd = mSocketFD; - pd.in_flags = mSelectFlags; - pd.out_flags = 0; - - result = PR_Poll(&pd, 1, pollTimeout); - switch (result) { - case 0: - rv = NS_ERROR_NET_TIMEOUT; - break; - case 1: - rv = doConnection(pd.out_flags); - break; - default: - rv = NS_ERROR_FAILURE; - } + info->bEOF = PR_FALSE; + *readCount = 0; + if (count > 0) { + len = PR_Read(info->fd, toRawSegment, count); + if (len >= 0) { + *readCount = (PRUint32)len; + info->bEOF = (0 == len); + } + // + // Error... + // + else { + PRErrorCode code = PR_GetError(); + if (PR_WOULD_BLOCK_ERROR == code) + rv = NS_BASE_STREAM_WOULD_BLOCK; + else { + PRInt32 osCode = PR_GetOSError (); + LOG(("nsSocketTransport: PR_Read() failed. PRErrorCode = %x, os_error=%d\n", code, osCode)); + info->bEOF = PR_TRUE; + // XXX: What should this error code be? + rv = NS_ERROR_FAILURE; } - while (rv == NS_BASE_STREAM_WOULD_BLOCK); } - mCurrentState = eSocketState_Connected; } + LOG(("nsSocketTransport: nsReadFromSocket [fd=%x]. rv = %x. Buffer space = %d. Bytes read =%d\n", + info->fd, rv, count, *readCount)); + return rv; } -nsresult -nsSocketTransport::doReadWrite(PRInt16 aSelectFlags) +static NS_METHOD +nsWriteToSocket(nsIInputStream* in, + void* closure, + const char* fromRawSegment, + PRUint32 toOffset, + PRUint32 count, + PRUint32 *writeCount) { - nsresult readStatus = NS_OK, writeStatus = NS_OK; + nsresult rv = NS_OK; + PRInt32 len; + PRFileDesc* fd = (PRFileDesc*)closure; - LOG(("nsSocketTransport: doReadWrite [this=%x, aSelectFlags=%hx, mReadRequest=%x, mWriteRequest=%x", - this, aSelectFlags, mReadRequest, mWriteRequest)); - - if (PR_POLL_EXCEPT & aSelectFlags) { - LOG(("nsSocketTransport: [this=%x] received PR_POLL_EXCEPT\n", this)); - return NS_BINDING_FAILED; - } - if (PR_POLL_ERR & aSelectFlags) { - LOG(("nsSocketTransport: [this=%x] received PR_POLL_ERR\n", this)); - return NS_BINDING_FAILED; - } - if (PR_POLL_HUP & aSelectFlags) { - LOG(("nsSocketTransport: [this=%x] received PR_POLL_HUP\n", this)); - return NS_OK; - } - - // Process the read request... - if (mReadRequest) { - if (mReadRequest->IsCanceled() || (mBytesExpected == 0)) - mSelectFlags &= ~PR_POLL_READ; - else if (aSelectFlags & PR_POLL_READ) - readStatus = mReadRequest->OnRead(); - else - readStatus = NS_BASE_STREAM_WOULD_BLOCK; - - if (mReadRequest->IsSuspended()) { - mSelectFlags &= ~PR_POLL_READ; - readStatus = NS_BASE_STREAM_WOULD_BLOCK; + *writeCount = 0; + if (count > 0) { + len = PR_Write(fd, fromRawSegment, count); + if (len > 0) + *writeCount = (PRUint32)len; + // + // Error... + // + else { + PRErrorCode code = PR_GetError(); + if (PR_WOULD_BLOCK_ERROR == code) + rv = NS_BASE_STREAM_WOULD_BLOCK; + else { + LOG(("nsSocketTransport: PR_Write() failed. PRErrorCode = %x\n", code)); + // XXX: What should this error code be? + rv = NS_ERROR_FAILURE; + } } - else if (NS_SUCCEEDED(readStatus)) - CompleteAsyncRead(); - else if (NS_FAILED(readStatus) && (readStatus != NS_BASE_STREAM_WOULD_BLOCK)) - return readStatus; } - // Process the write request... - if (mWriteRequest) { - if (mWriteRequest->IsCanceled()) - mSelectFlags &= ~PR_POLL_WRITE; - else if (aSelectFlags & PR_POLL_WRITE) - writeStatus = mWriteRequest->OnWrite(); - else - writeStatus = NS_BASE_STREAM_WOULD_BLOCK; + LOG(("nsSocketTransport: nsWriteToSocket [fd=%x]. rv = %x. Buffer space = %d. Bytes written =%d\n", + fd, rv, count, *writeCount)); - if (mWriteRequest->IsSuspended()) { - mSelectFlags &= ~PR_POLL_WRITE; - writeStatus = NS_BASE_STREAM_WOULD_BLOCK; - } - else if (NS_SUCCEEDED(writeStatus)) - CompleteAsyncWrite(); - else if (NS_FAILED(writeStatus) && (writeStatus != NS_BASE_STREAM_WOULD_BLOCK)) - return writeStatus; + return rv; +} + +//----- +// +// doReadAsync: +// +// Return values: +// NS_OK +// NS_BASE_STREAM_WOULD_BLOCK +// failure +// +//----- +nsresult nsSocketTransport::doReadAsync(PRInt16 aSelectFlags) +{ + if (!(aSelectFlags & PR_POLL_READ)) { + // wait for the proper select flags + return NS_BASE_STREAM_WOULD_BLOCK; } - LOG(("nsSocketTransport: doReadWrite [readstatus=%x writestatus=%x readsuspend=%d writesuspend=%d mSelectFlags=%hx]\n", - readStatus, writeStatus, - mReadRequest ? mReadRequest->IsSuspended() : 0, - mWriteRequest ? mWriteRequest->IsSuspended() : 0, - mSelectFlags)); + if (!mSocketInputStream) { + NS_NEWXPCOM(mSocketInputStream, nsSocketInputStream); + if (!mSocketInputStream) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(mSocketInputStream); + mSocketInputStream->SetSocketFD(mSocketFD); + } + + mSocketInputStream->ZeroBytesRead(); + + PRUint32 transferAmt = PR_MIN(mBufferMaxSize, MAX_IO_TRANSFER_SIZE); + + LOG(("nsSocketTransport: READING [this=%x] calling listener [offset=%u, count=%u]\n", + this, mReadOffset, transferAmt)); + + nsresult rv = mReadListener->OnDataAvailable(this, + mReadContext, + mSocketInputStream, + mReadOffset, + transferAmt); // - // If both requests successfully completed then move to the "done" state. + // Handle the error conditions // - if (NS_SUCCEEDED(readStatus) && NS_SUCCEEDED(writeStatus)) - return NS_OK; + if (NS_BASE_STREAM_WOULD_BLOCK == rv) { + // + // Don't suspend the transport if we also writing to it. + // XXX interface does not provide for overlapped i/o (bug 65220). + // + if (mSelectFlags & PR_POLL_WRITE) { + LOG(("nsSocketTransport: READING [this=%x] busy waiting on read!\n", this)); + PR_Sleep(10); // Don't starve the other threads either!! + } else { + LOG(("nsSocketTransport: READING [this=%x] listener would block; suspending self.\n", this)); + mSuspendCount++; + } + } + else if (NS_BASE_STREAM_CLOSED == rv) { + LOG(("nsSocketTransport: READING [this=%x] done reading socket.\n", this)); + rv = NS_OK; // go to done state + } + else if (NS_FAILED(rv)) { + LOG(("nsSocketTransport: READING [this=%x] error reading socket.\n", this)); + } + else { + PRUint32 total = mSocketInputStream->GetBytesRead(); + mReadOffset += total; - // Else remain in the same state - return NS_BASE_STREAM_WOULD_BLOCK; + if ((0 == total) && !mSocketInputStream->GotWouldBlock()) { + LOG(("nsSocketTransport: READING [this=%x] done reading socket.\n", this)); + mSelectFlags &= ~PR_POLL_READ; + } + else { + LOG(("nsSocketTransport: READING [this=%x] read %u bytes [offset=%u]\n", + this, total, mReadOffset)); + // + // Stay in the read state + // + rv = NS_BASE_STREAM_WOULD_BLOCK; + } + + if (total && !(nsIChannel::LOAD_BACKGROUND & mLoadAttributes) && mEventSink) + // we don't have content length info at the socket level + // just pass 0 through. + mEventSink->OnProgress(this, mReadContext, mReadOffset, 0); + } + return rv; +} + +//----- +// +// doRead: +// +// This method is called while holding the SocketTransport lock. It is +// always called on the socket transport thread... +// +// Return values: +// NS_OK +// NS_BASE_STREAM_WOULD_BLOCK +// +// NS_ERROR_FAILURE +// +//----- +nsresult nsSocketTransport::doRead(PRInt16 aSelectFlags) +{ + nsReadFromSocketClosure info; + PRUint32 totalBytesWritten; + nsresult rv = NS_OK; + + NS_ASSERTION(eSocketState_WaitReadWrite == mCurrentState, "Wrong state."); + NS_ASSERTION(GetReadType() != eSocketRead_None, "Bad Read Type!"); + + LOG(("nsSocketTransport: Entering doRead() [host=%s:%d this=%x], " + "aSelectFlags=%x.\n", + mHostName, mPort, this, aSelectFlags)); + + // + // Fill the stream with as much data from the network as possible... + // + // + totalBytesWritten = 0; + info.fd = mSocketFD; + + // Release the transport lock... WriteSegments(...) aquires the nsPipe + // lock which could cause a deadlock by blocking the socket transport + // thread + // + PR_ExitMonitor(mMonitor); + rv = mReadPipeOut->WriteSegments(nsReadFromSocket, (void*)&info, + MAX_IO_TRANSFER_SIZE, &totalBytesWritten); + PR_EnterMonitor(mMonitor); + + LOG(("nsSocketTransport: WriteSegments [fd=%x]. rv = %x. Bytes read =%d\n", + mSocketFD, rv, totalBytesWritten)); + + // + // Fire a single OnDataAvaliable(...) notification once as much data has + // been filled into the stream as possible... + // + if (totalBytesWritten) { + if (mReadListener) { + nsresult rv1; + rv1 = mReadListener->OnDataAvailable(this, mReadContext, mReadPipeIn, + mReadOffset, + totalBytesWritten); + // + // If the consumer returns failure, then cancel the operation... + // + if (NS_FAILED(rv1)) + rv = rv1; + + } + mReadOffset += totalBytesWritten; + } + + // + // Deal with the possible return values... + // + if (NS_SUCCEEDED(rv)) { + if (info.bEOF || mBytesExpected == 0) { + // EOF condition + mSelectFlags &= (~PR_POLL_READ); + rv = NS_OK; + } + else // continue to return WOULD_BLOCK until we've completely finished this read + rv = NS_BASE_STREAM_WOULD_BLOCK; + } + + LOG(("nsSocketTransport: Leaving doRead() [%s:%d %x]. rv = %x.\t" + "Total bytes read: %d\n\n", + mHostName, mPort, this, rv, totalBytesWritten)); + + if (!(nsIChannel::LOAD_BACKGROUND & mLoadAttributes) && mEventSink) + // we don't have content length info at the socket level + // just pass 0 through. + (void)mEventSink->OnProgress(this, mReadContext, mReadOffset, 0); + + return rv; +} + +//----- +// +// doWriteAsync: +// +// This method is called while holding the SocketTransport lock. It is +// always called on the socket transport thread... +// +// Return values: +// NS_OK - keep on truckin +// NS_BASE_STREAM_WOULD_BLOCK - no data was written at this time +// NS_BASE_STREAM_CLOSED - no more data will ever be written +// +// FAILURE +// +//----- +nsresult nsSocketTransport::doWriteAsync(PRInt16 aSelectFlags) +{ + LOG(("nsSocketTransport: Entering doWriteAsync() [host=%s:%d this=%x], " + "aSelectFlags=%x.\n", + mHostName, mPort, this, aSelectFlags)); + + if (!(aSelectFlags & PR_POLL_WRITE)) { + // wait for the proper select flags + return NS_BASE_STREAM_WOULD_BLOCK; + } + + if (!mSocketOutputStream) { + NS_NEWXPCOM(mSocketOutputStream, nsSocketOutputStream); + if (!mSocketOutputStream) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(mSocketOutputStream); + mSocketOutputStream->SetSocketFD(mSocketFD); + } + + mSocketOutputStream->ZeroBytesWritten(); + + PRUint32 transferAmt = PR_MIN(mBufferMaxSize, MAX_IO_TRANSFER_SIZE); + + nsresult rv = mWriteProvider->OnDataWritable(this, + mWriteContext, + mSocketOutputStream, + mWriteOffset, + transferAmt); + + // + // Handle the error conditions + // + if (NS_BASE_STREAM_WOULD_BLOCK == rv) { + // + // Don't suspend the transport if we also reading from it. + // XXX interface does not provide for overlapped i/o (bug 65220). + // + if (mSelectFlags & PR_POLL_READ) { + LOG(("nsSocketTransport: WRITING [this=%x] busy waiting on write!\n", this)); + PR_Sleep(10); // Don't starve the other threads either!! + } else { + LOG(("nsSocketTransport: WRITING [this=%x] provider would block; suspending self.\n", this)); + mSuspendCount++; + } + } + else if (NS_BASE_STREAM_CLOSED == rv) { + LOG(("nsSocketTransport: WRITING [this=%x] provider has finished.\n", this)); + rv = NS_OK; // go to done state + } + else if (NS_FAILED(rv)) { + LOG(("nsSocketTransport: WRITING [this=%x] provider failed, rv=%x.\n", this, rv)); + } + else { + PRUint32 total = mSocketOutputStream->GetBytesWritten(); + mWriteOffset += total; + + if ((0 == total) && !mSocketOutputStream->GotWouldBlock()) { + LOG(("nsSocketTransport: WRITING [this=%x] done writing to socket.\n", this)); + mSelectFlags &= ~PR_POLL_WRITE; + } + else { + LOG(("nsSocketTransport: WRITING [this=%x] wrote %u bytes [offset=%u]\n", + this, total, mWriteOffset)); + // + // Stay in the write state + // + rv = NS_BASE_STREAM_WOULD_BLOCK; + } + + if (total && !(nsIChannel::LOAD_BACKGROUND & mLoadAttributes) && mEventSink) + // we don't have content length info at the socket level + // just pass 0 through. + mEventSink->OnProgress(this, mWriteContext, mWriteOffset, 0); + } + return rv; +} + +//----- +// +// doWrite: +// +// This method is called while holding the SocketTransport lock. It is +// always called on the socket transport thread... +// +// Return values: +// NS_OK - keep on truckin +// NS_BASE_STREAM_WOULD_BLOCK - no data was written to the pipe at this time +// NS_BASE_STREAM_CLOSED - no more data will ever be written to the pipe +// +// FAILURE +// +//----- +nsresult nsSocketTransport::doWrite(PRInt16 aSelectFlags) +{ + PRUint32 totalBytesWritten = 0; + nsresult rv = NS_OK; + + NS_ASSERTION(eSocketState_WaitReadWrite == mCurrentState, "Wrong state."); + NS_ASSERTION(GetWriteType() != eSocketWrite_None, "Bad Write Type!"); + + LOG(("nsSocketTransport: Entering doWrite() [host=%s:%d this=%x], " + "aSelectFlags=%x.\n", + mHostName, mPort, this, aSelectFlags)); + + rv = doWriteFromBuffer(&totalBytesWritten); + do { + totalBytesWritten = 0; + + // Writing from a nsIInputStream... + rv = doWriteFromBuffer(&totalBytesWritten); + + // Update the counters... + if (mWriteCount > 0) { + NS_ASSERTION(mWriteCount >= (PRInt32)totalBytesWritten, + "wrote more than humanly possible"); + mWriteCount -= totalBytesWritten; + } + mWriteOffset += totalBytesWritten; + } + while (NS_SUCCEEDED (rv) && totalBytesWritten); + + // + // The write operation has completed... + // + if (NS_SUCCEEDED(rv) && (0 == totalBytesWritten || // eof, or + GetFlag(eSocketWrite_Async) && 0 == mWriteCount) ) { // wrote everything + mSelectFlags &= (~PR_POLL_WRITE); + rv = NS_OK; + } + else if (NS_SUCCEEDED(rv)) { + // + // We wrote something, so loop and try again. + // return WOULD_BLOCK to keep the transport on the select list... + // + rv = NS_BASE_STREAM_WOULD_BLOCK; + } + else if (NS_BASE_STREAM_WOULD_BLOCK == rv) { + // + // If the buffer is empty, then notify the reader and stop polling + // for write until there is data in the buffer. See the OnWrite() + // notification... + // + NS_ASSERTION((0 == totalBytesWritten), + "returned NS_BASE_STREAM_WOULD_BLOCK and a writeCount"); + // + // We can only wait if we created the stream (a pipe -- created + // in the synchronous OpenOutputStream case). If we didn't create + // it, we couldn't have been the buffer observer, so we won't get + // any notification when more data becomes available. + // + SetFlag(eSocketWrite_Wait); + mSelectFlags &= (~PR_POLL_WRITE); + } + + LOG(("nsSocketTransport: Leaving doWrite() [%s:%d %x]. rv = %x.\t" + "Total bytes written: %d\n\n", + mHostName, mPort, this, rv, totalBytesWritten)); + + if (!(nsIChannel::LOAD_BACKGROUND & mLoadAttributes) && mEventSink) + // we don't have content length info at the socket level + // just pass 0 through. + mEventSink->OnProgress(this, mWriteContext, mWriteOffset, 0); + + return rv; +} + + +// +// Try to write out everything in the pipe. Return NS_OK unless +// there is an error. This should never return WOULD_BLOCK! +// +nsresult nsSocketTransport::doWriteFromBuffer(PRUint32 *aCount) +{ + nsresult rv; + PRUint32 transferCount; + + // Figure out how much data to write... + if (mWriteCount > 0) + transferCount = PR_MIN(mWriteCount, MAX_IO_TRANSFER_SIZE); + else + transferCount = MAX_IO_TRANSFER_SIZE; + + // + // Release the transport lock... ReadSegments(...) aquires the nsBuffer + // lock which could cause a deadlock by blocking the socket transport + // thread + // + PR_ExitMonitor(mMonitor); + + // + // Write the data to the network... + // + // return values: + // NS_BASE_STREAM_WOULD_BLOCK - The stream is empty. + // NS_OK - The write succeeded. + // FAILURE - Something bad happened. + // + rv = mWritePipeIn->ReadSegments(nsWriteToSocket, (void *) mSocketFD, + transferCount, aCount); + PR_EnterMonitor(mMonitor); + + LOG(("nsSocketTransport: ReadSegments [fd=%x]. rv = %x. Bytes written =%d\n", + mSocketFD, rv, *aCount)); + + //NS_POSTCONDITION(rv != NS_BASE_STREAM_WOULD_BLOCK, "ReadSegments returned WOULD_BLOCK!"); + return rv; } nsresult nsSocketTransport::CloseConnection(PRBool bNow) @@ -1013,7 +1666,7 @@ nsresult nsSocketTransport::CloseConnection(PRBool bNow) return NS_OK; } - status = PR_Close(mSocketFD); + status = PR_Close (mSocketFD); if (PR_SUCCESS != status) rv = NS_ERROR_FAILURE; @@ -1038,9 +1691,12 @@ nsresult nsSocketTransport::CloseConnection(PRBool bNow) // -------------------------------------------------------------------------- // -NS_IMPL_THREADSAFE_ISUPPORTS3(nsSocketTransport, - nsITransport, +NS_IMPL_THREADSAFE_ISUPPORTS6(nsSocketTransport, + nsIChannel, + nsIRequest, nsIDNSListener, + nsIInputStreamObserver, + nsIOutputStreamObserver, nsISocketTransport); // @@ -1048,25 +1704,6 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsSocketTransport, // nsISocketTransport implementation... // -------------------------------------------------------------------------- // - -NS_IMETHODIMP -nsSocketTransport::GetHost(char **aHost) -{ - NS_ENSURE_ARG_POINTER(aHost); - *aHost = nsCRT::strdup(mHostName); - if (!*aHost) - return NS_ERROR_OUT_OF_MEMORY; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketTransport::GetPort(PRInt32 *aPort) -{ - NS_ENSURE_ARG_POINTER(aPort); - *aPort = mPort; - return NS_OK; -} - NS_IMETHODIMP nsSocketTransport::GetReuseConnection(PRBool *_retval) { @@ -1136,44 +1773,15 @@ nsSocketTransport::GetSecurityInfo(nsISupports **info) return NS_OK; } -NS_IMETHODIMP -nsSocketTransport::GetProgressEventSink(nsIProgressEventSink **aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - NS_ADDREF(*aResult = mEventSink); - return NS_OK; -} - -NS_IMETHODIMP -nsSocketTransport::SetProgressEventSink(nsIProgressEventSink *aEventSink) -{ - mEventSink = nsnull; - - if (aEventSink) { - nsresult rv; - // Now generate a proxied event sink- - NS_WITH_SERVICE(nsIProxyObjectManager, - proxyMgr, kProxyObjectManagerCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = proxyMgr->GetProxyForObject(NS_UI_THREAD_EVENTQ, // primordial thread - should change? - NS_GET_IID(nsIProgressEventSink), - aEventSink, - PROXY_ASYNC | PROXY_ALWAYS, - getter_AddRefs(mEventSink)); - } - } - return NS_OK; -} - // // -------------------------------------------------------------------------- -// request helpers... +// nsIRequest implementation... // -------------------------------------------------------------------------- // -nsresult -nsSocketTransport::GetName(PRUnichar **result) +NS_IMETHODIMP +nsSocketTransport::GetName(PRUnichar* *result) { nsString name; name.AppendWithConversion(mHostName); @@ -1183,39 +1791,218 @@ nsSocketTransport::GetName(PRUnichar **result) return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } -nsresult -nsSocketTransport::Dispatch(nsSocketRequest *req) +NS_IMETHODIMP +nsSocketTransport::IsPending(PRBool *result) { + *result = mCurrentState != eSocketState_Created + && mCurrentState != eSocketState_Closed; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::GetStatus(nsresult *status) +{ + if (NS_FAILED(mCancelStatus)) + *status = mCancelStatus; + else if (mStatus == NS_BASE_STREAM_WOULD_BLOCK) + *status = NS_OK; + else + *status = mStatus; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::Cancel(nsresult status) +{ + NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code"); nsresult rv = NS_OK; // Enter the socket transport lock... nsAutoMonitor mon(mMonitor); - if (req == mReadRequest) - mSelectFlags |= PR_POLL_READ; - else - mSelectFlags |= PR_POLL_WRITE; + mCancelStatus = status; + + // A cancelled transport cannot be suspended. + mSuspendCount = 0; // // Wake up the transport on the socket transport thread so it can - // be resumed... + // be removed from the select list... // - mLastActiveTime = PR_IntervalNow(); + mLastActiveTime = PR_IntervalNow (); rv = mService->AddToWorkQ(this); - LOG(("nsSocketTransport: Resuming [%s:%d %x]. rv = %x\t", + LOG(("nsSocketTransport: Canceling [%s:%d %x]. rv = %x\n", mHostName, mPort, this, rv)); return rv; } -nsresult -nsSocketTransport::OnProgress(nsSocketRequest *req, nsISupports *ctx, PRUint32 offset) +NS_IMETHODIMP +nsSocketTransport::Suspend(void) { - if (mEventSink) - // we don't have content length info at the socket level - // just pass 0 through. - mEventSink->OnProgress(req, ctx, offset, 0); + // Silently ignore calls to suspend a cancelled transport + if (NS_FAILED(mCancelStatus)) + return NS_OK; + + nsresult rv = NS_OK; + + // Enter the socket transport lock... + nsAutoMonitor mon(mMonitor); + + mSuspendCount += 1; + // + // Wake up the transport on the socket transport thread so it can + // be removed from the select list... + // + // Only do this the first time a transport is suspended... + // + if (1 == mSuspendCount) { + mLastActiveTime = PR_IntervalNow (); + rv = mService->AddToWorkQ(this); + } + + LOG(("nsSocketTransport: Suspending [%s:%d %x]. rv = %x\t" + "mSuspendCount = %d.\n", + mHostName, mPort, this, rv, mSuspendCount)); + + return rv; +} + + +NS_IMETHODIMP +nsSocketTransport::Resume(void) +{ + // Silently ignore calls to resume a cancelled transport + if (NS_FAILED(mCancelStatus)) + return NS_OK; + + nsresult rv = NS_OK; + + // Enter the socket transport lock... + nsAutoMonitor mon(mMonitor); + + if (mSuspendCount) { + mSuspendCount -= 1; + // + // Wake up the transport on the socket transport thread so it can + // be resumed... + // + if (0 == mSuspendCount) { + mLastActiveTime = PR_IntervalNow (); + rv = mService->AddToWorkQ(this); + } + } else { + // Only a suspended transport can be resumed... + rv = NS_ERROR_FAILURE; + } + + LOG(("nsSocketTransport: Resuming [%s:%d %x]. rv = %x\t" + "mSuspendCount = %d.\n", + mHostName, mPort, this, rv, mSuspendCount)); + + return rv; +} + +// +// -------------------------------------------------------------------------- +// nsIInputStreamObserver/nsIOutputStreamObserver implementation... +// -------------------------------------------------------------------------- +// +// The pipe observer is used by the following methods: +// OpenInputStream(...) +// OpenOutputStream(...). +// +NS_IMETHODIMP +nsSocketTransport::OnFull(nsIOutputStream* out) +{ + LOG(("nsSocketTransport: OnFull() [%s:%d %x] nsIOutputStream=%x.\n", + mHostName, mPort, this, out)); + + // + // The socket transport has filled up the pipe. Remove the + // transport from the select list until the consumer can + // make room... + // + if (out == mReadPipeOut.get()) { + // Enter the socket transport lock... + nsAutoMonitor mon(mMonitor); + + if (!GetFlag(eSocketRead_Wait)) { + SetFlag(eSocketRead_Wait); + mSelectFlags &= (~PR_POLL_READ); + } + return NS_OK; + } + + // Else, since we might get an OnFull without an intervening OnWrite + // try the OnWrite case to see if we need to resume the blocking write operation: + return OnWrite(out, 0); +} + + +NS_IMETHODIMP +nsSocketTransport::OnWrite(nsIOutputStream* out, PRUint32 aCount) +{ + nsresult rv = NS_OK; + + LOG(("nsSocketTransport: OnWrite() [%s:%d %x]. nsIOutputStream=%x Count=%d\n", + mHostName, mPort, this, out, aCount)); + + // + // The consumer has written some data into the pipe... If the transport + // was waiting to write some data to the network, then add it to the + // select list... + // + if (out == mWritePipeOut.get()) { + // Enter the socket transport lock... + nsAutoMonitor mon(mMonitor); + + if (GetFlag(eSocketWrite_Wait)) { + ClearFlag(eSocketWrite_Wait); + mSelectFlags |= PR_POLL_WRITE; + + // Start the crank. + mOperation = eSocketOperation_ReadWrite; + mLastActiveTime = PR_IntervalNow (); + rv = mService->AddToWorkQ(this); + } + } + + return NS_OK; +} + + +NS_IMETHODIMP +nsSocketTransport::OnEmpty(nsIInputStream* in) +{ + nsresult rv = NS_OK; + + LOG(("nsSocketTransport: OnEmpty() [%s:%d %x] nsIInputStream=%x.\n", + mHostName, mPort, this, in)); + + // + // The consumer has emptied the pipe... If the transport was waiting + // for room in the pipe, then put it back on the select list... + // + if (in == mReadPipeIn.get()) { + // Enter the socket transport lock... + nsAutoMonitor mon(mMonitor); + + if (GetFlag(eSocketRead_Wait)) { + ClearFlag(eSocketRead_Wait); + mSelectFlags |= PR_POLL_READ; + mLastActiveTime = PR_IntervalNow (); + rv = mService->AddToWorkQ(this); + } + } + + return rv; +} + +NS_IMETHODIMP +nsSocketTransport::OnClose(nsIInputStream* inStr) +{ return NS_OK; } @@ -1241,6 +2028,9 @@ nsSocketTransport::OnFound(nsISupports *aContext, // Enter the socket transport lock... nsAutoMonitor mon(mMonitor); nsresult rv = NS_OK; +#if defined(PR_LOGGING) + char addrbuf[50]; +#endif if (aHostEnt->hostEnt.h_addr_list && aHostEnt->hostEnt.h_addr_list[0]) { if (aHostEnt->hostEnt.h_addrtype == PR_AF_INET6) @@ -1248,7 +2038,6 @@ nsSocketTransport::OnFound(nsISupports *aContext, else PR_ConvertIPv4AddrToIPv6(*(PRUint32*)aHostEnt->hostEnt.h_addr_list[0], &mNetAddress.ipv6.ip); #if defined(PR_LOGGING) - char addrbuf[50]; PR_NetAddrToString(&mNetAddress, addrbuf, sizeof(addrbuf)); LOG(("nsSocketTransport: OnFound(...) [%s:%d %x]." " DNS lookup succeeded => %s (%s)\n", @@ -1302,19 +2091,55 @@ nsSocketTransport::OnStopLookup(nsISupports *aContext, // // -------------------------------------------------------------------------- -// nsITransport implementation... +// nsIChannel implementation... // -------------------------------------------------------------------------- // +NS_IMETHODIMP +nsSocketTransport::GetOriginalURI(nsIURI* *aURL) +{ + nsStdURL *url; + url = new nsStdURL(nsnull); + // XXX: not sure this is correct behavior, but we should somehow + // prevent reusing the same nsSocketTransport for different SSL hosts + // in proxied case. + if (mProxyHost && !(mProxyTransparent || mSSLProxy)) { + url->SetHost(mProxyHost); + url->SetPort(mProxyPort); + } + else { + url->SetHost(mHostName); + url->SetPort(mPort); + } + + nsresult rv; + rv = CallQueryInterface((nsIURL*)url, aURL); + + return rv; +} + +NS_IMETHODIMP +nsSocketTransport::SetOriginalURI(nsIURI* aURL) +{ + NS_NOTREACHED("SetOriginalURI"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetURI(nsIURI* *aURL) +{ + return GetOriginalURI(aURL); +} + +NS_IMETHODIMP +nsSocketTransport::SetURI(nsIURI* aURL) +{ + return SetOriginalURI(aURL); +} NS_IMETHODIMP nsSocketTransport::AsyncRead(nsIStreamListener* aListener, - nsISupports* aContext, - PRUint32 aOffset, - PRUint32 aCount, - PRUint32 aFlags, - nsIRequest **aRequest) + nsISupports* aContext) { - NS_ENSURE_ARG_POINTER(aRequest); nsresult rv = NS_OK; // Enter the socket transport lock... @@ -1323,55 +2148,39 @@ nsSocketTransport::AsyncRead(nsIStreamListener* aListener, LOG(("nsSocketTransport: Entering AsyncRead() [host=%s:%d this=%x]\n", mHostName, mPort, this)); + // If a read is already in progress then fail... if (GetReadType() != eSocketRead_None) rv = NS_ERROR_IN_PROGRESS; - nsCOMPtr listener; - - if (NS_SUCCEEDED(rv)) - rv = NS_NewStreamListenerProxy(getter_AddRefs(listener), + if (NS_SUCCEEDED(rv)) { + mReadContext = aContext; + mOnStartReadFired = PR_FALSE; + // Create a stream listener proxy to receive notifications... + rv = NS_NewStreamListenerProxy(getter_AddRefs(mReadListener), aListener, nsnull, mBufferSegmentSize, mBufferMaxSize); - - if (NS_SUCCEEDED(rv)) { - NS_NEWXPCOM(mReadRequest, nsSocketReadRequest); - if (mReadRequest) { - NS_ADDREF(mReadRequest); - mReadRequest->SetTransport(this); - mReadRequest->SetListener(listener); - mReadRequest->SetListenerContext(aContext); - //mReadRequest->SetTransferCount(aCount); - } - else - rv = NS_ERROR_OUT_OF_MEMORY; } if (NS_SUCCEEDED(rv)) { mOperation = eSocketOperation_ReadWrite; SetReadType(eSocketRead_Async); - mLastActiveTime = PR_IntervalNow(); + mLastActiveTime = PR_IntervalNow (); rv = mService->AddToWorkQ(this); } LOG(("nsSocketTransport: Leaving AsyncRead() [host=%s:%d this=%x], rv=%x.\n", mHostName, mPort, this, rv)); - NS_IF_ADDREF(*aRequest = mReadRequest); return rv; } NS_IMETHODIMP nsSocketTransport::AsyncWrite(nsIStreamProvider* aProvider, - nsISupports* aContext, - PRUint32 aOffset, - PRUint32 aCount, - PRUint32 aFlags, - nsIRequest **aRequest) + nsISupports* aContext) { - NS_ENSURE_ARG_POINTER(aRequest); nsresult rv = NS_OK; // Enter the socket transport lock... @@ -1383,26 +2192,17 @@ nsSocketTransport::AsyncWrite(nsIStreamProvider* aProvider, // If a write is already in progress then fail... if (GetWriteType() != eSocketWrite_None) rv = NS_ERROR_IN_PROGRESS; - - nsCOMPtr provider; - if (NS_SUCCEEDED(rv)) - rv = NS_NewStreamProviderProxy(getter_AddRefs(provider), - aProvider, nsnull, - mBufferSegmentSize, - mBufferMaxSize); - if (NS_SUCCEEDED(rv)) { - NS_NEWXPCOM(mWriteRequest, nsSocketWriteRequest); - if (mWriteRequest) { - NS_ADDREF(mWriteRequest); - mWriteRequest->SetTransport(this); - mWriteRequest->SetProvider(provider); - mWriteRequest->SetProviderContext(aContext); - //mWriteRequest->SetTransferCount(aCount); + mWriteContext = aContext; + mOnStartWriteFired = PR_FALSE; + + if (aProvider) { + mWriteProvider = 0; + // Create a stream provider proxy to handle notifications... + rv = NS_NewStreamProviderProxy(getter_AddRefs(mWriteProvider), + aProvider, NS_CURRENT_EVENTQ); } - else - rv = NS_ERROR_OUT_OF_MEMORY; } if (NS_SUCCEEDED(rv)) { @@ -1416,18 +2216,13 @@ nsSocketTransport::AsyncWrite(nsIStreamProvider* aProvider, LOG(("nsSocketTransport: Leaving AsyncWrite() [host=%s:%d this=%x], rv=%x.\n", mHostName, mPort, this, rv)); - NS_IF_ADDREF(*aRequest = mWriteRequest); return rv; } NS_IMETHODIMP -nsSocketTransport::OpenInputStream(PRUint32 aOffset, - PRUint32 aCount, - PRUint32 aFlags, - nsIInputStream **aResult) +nsSocketTransport::OpenInputStream(nsIInputStream* *result) { - NS_ENSURE_ARG_POINTER(aResult); nsresult rv = NS_OK; // Enter the socket transport lock... @@ -1440,17 +2235,25 @@ nsSocketTransport::OpenInputStream(PRUint32 aOffset, if (GetReadType() != eSocketRead_None) rv = NS_ERROR_IN_PROGRESS; - if (NS_SUCCEEDED(rv)) - rv = doBlockingConnection(); - + // Create a new blocking input stream for reading data into... if (NS_SUCCEEDED(rv)) { - NS_NEWXPCOM(mBIS, nsSocketBIS); - if (!mBIS) - rv = NS_ERROR_OUT_OF_MEMORY; - else { - NS_ADDREF(mBIS); - mBIS->SetTransport(this); - mBIS->SetSocket(mSocketFD); + mReadListener = 0; + mReadContext = 0; + + // XXXbe calling out of module with a lock held... + rv = NS_NewPipe(getter_AddRefs(mReadPipeIn), + getter_AddRefs(mReadPipeOut), + mBufferSegmentSize, mBufferMaxSize); + if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) + rv = mReadPipeIn->SetObserver(this); + if (NS_SUCCEEDED(rv)) + rv = mReadPipeOut->SetObserver(this); + if (NS_SUCCEEDED(rv)) { + rv = mReadPipeOut->SetNonBlocking(PR_TRUE); + *result = mReadPipeIn; + NS_IF_ADDREF(*result); + } } } @@ -1458,23 +2261,20 @@ nsSocketTransport::OpenInputStream(PRUint32 aOffset, mOperation = eSocketOperation_ReadWrite; SetReadType(eSocketRead_Sync); - mLastActiveTime = PR_IntervalNow(); + mLastActiveTime = PR_IntervalNow (); + rv = mService->AddToWorkQ(this); } LOG(("nsSocketTransport: Leaving OpenInputStream() [host=%s:%d this=%x], " "rv=%x.\n", mHostName, mPort, this, rv)); - NS_IF_ADDREF(*aResult = mBIS); return rv; } NS_IMETHODIMP -nsSocketTransport::OpenOutputStream(PRUint32 aOffset, - PRUint32 aCount, - PRUint32 aFlags, - nsIOutputStream **aResult) +nsSocketTransport::OpenOutputStream(nsIOutputStream* *result) { nsresult rv = NS_OK; @@ -1488,35 +2288,231 @@ nsSocketTransport::OpenOutputStream(PRUint32 aOffset, if (GetWriteType() != eSocketWrite_None) rv = NS_ERROR_IN_PROGRESS; - if (NS_SUCCEEDED(rv)) - rv = doBlockingConnection(); - if (NS_SUCCEEDED(rv)) { - NS_NEWXPCOM(mBOS, nsSocketBOS); - if (!mBOS) - rv = NS_ERROR_OUT_OF_MEMORY; - else { - NS_ADDREF(mBOS); - mBOS->SetTransport(this); - mBOS->SetSocket(mSocketFD); + // No provider or write context is available... + mWriteCount = 0; + mWriteProvider = 0; + mWriteContext = 0; + + // We want a pipe here so the caller can "write" into one end + // and the other end (aWriteStream) gets the data. This data + // is then written to the underlying socket when nsSocketTransport::doWrite() + // is called. + + nsCOMPtr out; + nsCOMPtr in; + // XXXbe calling out of module with a lock held... + rv = NS_NewPipe(getter_AddRefs(in), getter_AddRefs(out), + mBufferSegmentSize, mBufferMaxSize, + PR_TRUE, PR_FALSE); + if (NS_SUCCEEDED(rv)) + rv = in->SetObserver(this); + + if (NS_SUCCEEDED(rv)) + rv = out->SetObserver(this); + + if (NS_SUCCEEDED(rv)) { + mWritePipeIn = in; + *result = out; + NS_IF_ADDREF(*result); + + mWritePipeOut = out; } - } - if (NS_SUCCEEDED(rv)) { - mOperation = eSocketOperation_ReadWrite; SetWriteType(eSocketWrite_Sync); - - mLastActiveTime = PR_IntervalNow(); } LOG(("nsSocketTransport: Leaving OpenOutputStream() [host=%s:%d this=%x], " "rv = %x.\n", mHostName, mPort, this, rv)); - NS_IF_ADDREF(*aResult = mBOS); return rv; } +NS_IMETHODIMP +nsSocketTransport::GetLoadAttributes(PRUint32 *aLoadAttributes) +{ + *aLoadAttributes = mLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetLoadAttributes(PRUint32 aLoadAttributes) +{ + mLoadAttributes = aLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::GetContentType(char * *aContentType) +{ + *aContentType = nsnull; + return NS_ERROR_FAILURE; // XXX doesn't make sense for transports +} + +NS_IMETHODIMP +nsSocketTransport::SetContentType(const char *aContentType) +{ + return NS_ERROR_FAILURE; // XXX doesn't make sense for transports +} + +NS_IMETHODIMP +nsSocketTransport::GetContentLength(PRInt32 *aContentLength) +{ + // The content length is always unknown for transports... + *aContentLength = -1; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetContentLength(PRInt32 aContentLength) +{ + NS_NOTREACHED("SetContentLength"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mWriteCount; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetTransferCount(PRInt32 aTransferCount) +{ + mWriteCount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup) +{ + NS_ASSERTION(0, "transports shouldn't end up in groups"); + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsSocketTransport::SetLoadGroup(nsILoadGroup* aLoadGroup) +{ + NS_NOTREACHED("SetLoadGroup"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsSocketTransport::GetOwner(nsISupports * *aOwner) +{ + *aOwner = mOwner.get(); + NS_IF_ADDREF(*aOwner); + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetOwner(nsISupports * aOwner) +{ + mOwner = aOwner; + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) +{ + *aNotificationCallbacks = mCallbacks.get(); + NS_IF_ADDREF(*aNotificationCallbacks); + return NS_OK; +} + +NS_IMETHODIMP +nsSocketTransport::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) +{ + mCallbacks = aNotificationCallbacks; + mEventSink = 0; + + // Get a nsIProgressEventSink so that we can fire status/progress on it- + if (mCallbacks) { + nsCOMPtr sink; + nsresult rv = mCallbacks->GetInterface(NS_GET_IID(nsIProgressEventSink), + getter_AddRefs(sink)); + if (NS_SUCCEEDED(rv)) { + // Now generate a proxied event sink- + NS_WITH_SERVICE(nsIProxyObjectManager, + proxyMgr, kProxyObjectManagerCID, &rv); + if (NS_SUCCEEDED(rv)) { + rv = proxyMgr->GetProxyForObject(NS_UI_THREAD_EVENTQ, // primordial thread - should change? + NS_GET_IID(nsIProgressEventSink), + sink, + PROXY_ASYNC | PROXY_ALWAYS, + getter_AddRefs(mEventSink)); + } + } + } + + return NS_OK; +} + NS_IMETHODIMP nsSocketTransport::IsAlive (PRUint32 seconds, PRBool *alive) { @@ -1630,767 +2626,38 @@ nsSocketTransport::SetSocketConnectTimeout (PRUint32 a_Seconds) } nsresult -nsSocketTransport::OnStatus(nsSocketRequest *req, nsISupports *ctxt, nsresult message) +nsSocketTransport::fireStatus(PRUint32 aCode) { if (!mEventSink) return NS_ERROR_FAILURE; + nsresult status; + switch (aCode) { + case eSocketState_Created: + case eSocketState_WaitDNS: + status = NS_NET_STATUS_RESOLVING_HOST; + break; + case eSocketState_Connected: + status = NS_NET_STATUS_CONNECTED_TO; + break; + case eSocketState_WaitReadWrite: + status = mWriteContext + ? NS_NET_STATUS_RECEIVING_FROM + : NS_NET_STATUS_SENDING_TO; + break; + case eSocketState_WaitConnect: + status = NS_NET_STATUS_CONNECTING_TO; + break; + case eSocketState_Closed: + case eSocketState_Done: + case eSocketState_Timeout: + case eSocketState_Error: + case eSocketState_Max: + default: + status = NS_OK; + break; + } + nsAutoString host; host.AssignWithConversion(mHostName); - return mEventSink->OnStatus(req, ctxt, message, host.GetUnicode()); -} - -nsresult -nsSocketTransport::OnStatus(nsresult message) -{ - nsSocketRequest *req; - - if (mReadRequest) - req = mReadRequest; - else - req = mWriteRequest; - - NS_ENSURE_TRUE(req, NS_ERROR_NOT_INITIALIZED); - return OnStatus(req, req->GetContext(), message); -} - -// -//---------------------------------------------------------------------------- -// nsSocketBS -//---------------------------------------------------------------------------- -// - -nsSocketBS::nsSocketBS() - : mTransport(nsnull) - , mSock(nsnull) -{ } - -nsSocketBS::~nsSocketBS() -{ - NS_IF_RELEASE(mTransport); -} - -void -nsSocketBS::SetTransport(nsSocketTransport *aTransport) -{ - NS_IF_RELEASE(mTransport); - NS_IF_ADDREF(mTransport = aTransport); -} - -nsresult -nsSocketBS::Poll(PRInt16 event) -{ - nsresult rv = NS_OK; - - PRIntervalTime pollTimeout = PR_MillisecondsToInterval(DEFAULT_POLL_TIMEOUT_IN_MS); - PRPollDesc pd; - - pd.fd = mSock; - pd.in_flags = event | PR_POLL_EXCEPT; - pd.out_flags = 0; - - PRInt32 result = PR_Poll(&pd, 1, pollTimeout); - switch (result) { - case 0: - rv = NS_ERROR_NET_TIMEOUT; - case 1: - rv = NS_OK; - default: - LOG(("nsSocketBS::Poll [this=%x] PR_Poll returned %d [error=%d]\n", - this, result, PR_GetError())); - rv = NS_ERROR_FAILURE; - } - - return rv; -} - -// -//---------------------------------------------------------------------------- -// nsSocketBIS -//---------------------------------------------------------------------------- -// - -NS_IMPL_ISUPPORTS1(nsSocketBIS, nsIInputStream) - -nsSocketBIS::nsSocketBIS() -{ - NS_INIT_ISUPPORTS(); -} - -nsSocketBIS::~nsSocketBIS() -{ } - -NS_IMETHODIMP -nsSocketBIS::Close() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBIS::Available(PRUint32 *aCount) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBIS::Read(char *aBuf, PRUint32 aCount, PRUint32 *aBytesRead) -{ - nsresult rv; - PRInt32 total; - - LOG(("nsSocketBIS::Read [this=%x count=%u]\n", this, aCount)); - -tryRead: - total = PR_Read(mSock, aBuf, aCount); - if (total < 0) { - if (PR_GetError() == PR_WOULD_BLOCK_ERROR) { - // - // Block until the socket is readable and then try again. - // - rv = Poll(PR_POLL_READ); - if (NS_FAILED(rv)) { - LOG(("nsSocketBIS::Read [this=%x] Poll failed [rv=%x]\n", this, rv)); - return rv; - } - LOG(("nsSocketBIS::Read [this=%x] Poll succeeded; looping back to PR_Read\n", this)); - goto tryRead; - } - return NS_ERROR_FAILURE; - } - /* - if (mTransport && total) { - mTransport->OnStatus(this, mListenerContext, NS_NET_STATUS_RECEIVING_FROM); - mTransport->OnProgress(this, mListenerContext, mOffset); - } - */ - *aBytesRead = (PRUint32) total; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketBIS::ReadSegments(nsWriteSegmentFun aWriter, void *aClosure, - PRUint32 aCount, PRUint32 *aBytesRead) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBIS::GetNonBlocking(PRBool *aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBIS::GetObserver(nsIInputStreamObserver **aObserver) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBIS::SetObserver(nsIInputStreamObserver *aObserver) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -// -//---------------------------------------------------------------------------- -// nsSocketBOS -//---------------------------------------------------------------------------- -// - -NS_IMPL_ISUPPORTS1(nsSocketBOS, nsIOutputStream) - -nsSocketBOS::nsSocketBOS() -{ - NS_INIT_ISUPPORTS(); -} - -nsSocketBOS::~nsSocketBOS() -{ } - -NS_IMETHODIMP -nsSocketBOS::Close() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::Flush() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::Write(const char *aBuf, PRUint32 aCount, PRUint32 *aBytesWritten) -{ - nsresult rv; - PRInt32 total; - - LOG(("nsSocketBOS::Write [this=%x count=%u]\n", this, aCount)); - -tryWrite: - total = PR_Write(mSock, aBuf, aCount); - if (total < 0) { - if (PR_GetError() == PR_WOULD_BLOCK_ERROR) { - // - // Block until the socket is writable and then try again. - // - rv = Poll(PR_POLL_WRITE); - if (NS_FAILED(rv)) { - LOG(("nsSocketBOS::Write [this=%x] Poll failed [rv=%x]\n", this, rv)); - return rv; - } - LOG(("nsSocketBOS::Write [this=%x] Poll succeeded; looping back to PR_Write\n", this)); - goto tryWrite; - } - return NS_ERROR_FAILURE; - } - /* - if (mTransport && total) { - mTransport->OnStatus(this, mListenerContext, NS_NET_STATUS_SENDING_TO); - mTransport->OnProgress(this, mListenerContext, mOffset); - } - */ - *aBytesWritten = (PRUint32) total; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketBOS::WriteFrom(nsIInputStream *aIS, PRUint32 aCount, PRUint32 *aBytesWritten) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::WriteSegments(nsReadSegmentFun aReader, void *aClosure, - PRUint32 aCount, PRUint32 *aBytesWritten) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::GetNonBlocking(PRBool *aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::SetNonBlocking(PRBool aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::GetObserver(nsIOutputStreamObserver **aObserver) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketBOS::SetObserver(nsIOutputStreamObserver *aObserver) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -// -//---------------------------------------------------------------------------- -// nsSocketIS -//---------------------------------------------------------------------------- -// - -NS_IMPL_THREADSAFE_ISUPPORTS1(nsSocketIS, nsIInputStream) - -nsSocketIS::nsSocketIS() - : mOffset(0) - , mSock(nsnull) - , mError(0) -{ - NS_INIT_ISUPPORTS(); -} - -NS_IMETHODIMP -nsSocketIS::Close() -{ - mSock = nsnull; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketIS::Available(PRUint32 *aCount) -{ - NS_ENSURE_ARG_POINTER(aCount); - NS_ENSURE_TRUE(mSock, NS_ERROR_NOT_INITIALIZED); - PRInt32 avail = PR_Available(mSock); - if (avail < 0) - return NS_ERROR_FAILURE; - *aCount = avail; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketIS::Read(char *aBuf, PRUint32 aCount, PRUint32 *aBytesRead) -{ - NS_ENSURE_ARG_POINTER(aBytesRead); - NS_ENSURE_TRUE(mSock, NS_ERROR_NOT_INITIALIZED); - PRInt32 result = PR_Read(mSock, aBuf, aCount); - LOG(("nsSocketTransport: PR_Read(count=%u) returned %d\n", aCount, result)); - mError = 0; - nsresult rv = NS_OK; - if (result < 0) { - mError = PR_GetError(); - if (PR_WOULD_BLOCK_ERROR == mError) { - LOG(("nsSocketTransport: PR_Read() failed with PR_WOULD_BLOCK_ERROR\n")); - rv = NS_BASE_STREAM_WOULD_BLOCK; - } - else { - LOG(("nsSocketTransport: PR_Read() failed [error=%x, os_error=%x]\n", - mError, PR_GetOSError())); - rv = NS_ERROR_FAILURE; - } - *aBytesRead = 0; - } - else { - *aBytesRead = (PRUint32) result; - mOffset += (PRUint32) result; - } - return rv; -} - -NS_IMETHODIMP -nsSocketIS::ReadSegments(nsWriteSegmentFun aWriter, void *aClosure, - PRUint32 aCount, PRUint32 *aBytesRead) -{ - NS_NOTREACHED("nsSocketIS::ReadSegments"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketIS::GetNonBlocking(PRBool *aValue) -{ - NS_ENSURE_ARG_POINTER(aValue); - *aValue = PR_TRUE; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketIS::GetObserver(nsIInputStreamObserver **aObserver) -{ - NS_NOTREACHED("nsSocketIS::GetObserver"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketIS::SetObserver(nsIInputStreamObserver *aObserver) -{ - NS_NOTREACHED("nsSocketIS::SetObserver"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -// -//---------------------------------------------------------------------------- -// nsSocketOS -//---------------------------------------------------------------------------- -// - -NS_IMPL_THREADSAFE_ISUPPORTS1(nsSocketOS, nsIOutputStream) - -nsSocketOS::nsSocketOS() - : mOffset(0) - , mSock(nsnull) - , mError(0) -{ - NS_INIT_ISUPPORTS(); -} - -NS_IMETHODIMP -nsSocketOS::Close() -{ - mSock = nsnull; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketOS::Flush() -{ - return NS_OK; -} - -NS_IMETHODIMP -nsSocketOS::Write(const char *aBuf, PRUint32 aCount, PRUint32 *aBytesWritten) -{ - NS_ENSURE_TRUE(mSock, NS_ERROR_NOT_INITIALIZED); - PRInt32 result = PR_Write(mSock, aBuf, aCount); - LOG(("nsSocketTransport: PR_Write(count=%u) returned %d\n", aCount, result)); - mError = 0; - nsresult rv = NS_OK; - if (result < 0) { - mError = PR_GetError(); - if (PR_WOULD_BLOCK_ERROR == mError) { - LOG(("nsSocketTransport: PR_Write() failed with PR_WOULD_BLOCK_ERROR\n")); - rv = NS_BASE_STREAM_WOULD_BLOCK; - } else { - LOG(("nsSocketTransport: PR_Write() failed [error=%x, os_error=%x]\n", - mError, PR_GetOSError())); - rv = NS_ERROR_FAILURE; - } - *aBytesWritten = 0; - } - else { - *aBytesWritten = (PRUint32) result; - mOffset += (PRUint32) result; - } - return rv; -} - -NS_IMETHODIMP -nsSocketOS::WriteFrom(nsIInputStream *aIS, PRUint32 aCount, PRUint32 *aBytesWritten) -{ - NS_NOTREACHED("nsSocketOS::WriteFrom"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketOS::WriteSegments(nsReadSegmentFun aReader, void *aClosure, - PRUint32 aCount, PRUint32 *aBytesWritten) -{ - NS_NOTREACHED("nsSocketOS::WriteSegments"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketOS::GetNonBlocking(PRBool *aValue) -{ - NS_ENSURE_ARG_POINTER(aValue); - *aValue = PR_TRUE; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketOS::SetNonBlocking(PRBool aValue) -{ - NS_NOTREACHED("nsSocketOS::SetNonBlocking"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketOS::GetObserver(nsIOutputStreamObserver **aObserver) -{ - NS_NOTREACHED("nsSocketOS::GetObserver"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsSocketOS::SetObserver(nsIOutputStreamObserver *aObserver) -{ - NS_NOTREACHED("nsSocketOS::SetObserver"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -// -//---------------------------------------------------------------------------- -// nsSocketRequest -//---------------------------------------------------------------------------- -// - -NS_IMPL_THREADSAFE_ISUPPORTS2(nsSocketRequest, - nsIRequest, - nsITransportRequest) - -nsSocketRequest::nsSocketRequest() - : mTransport(nsnull) - , mStatus(NS_OK) - , mSuspendCount(PR_FALSE) - , mCanceled(PR_FALSE) - , mStartFired(0) -{ - NS_INIT_ISUPPORTS(); -} - -nsSocketRequest::~nsSocketRequest() -{ - NS_IF_RELEASE(mTransport); -} - -void -nsSocketRequest::SetTransport(nsSocketTransport *aTransport) -{ - // - // Keep an owning reference back to the transport - // - NS_IF_RELEASE(mTransport); - NS_IF_ADDREF(mTransport = aTransport); -} - -nsresult -nsSocketRequest::OnStart(nsIStreamObserver *aObserver, nsISupports *aContext) -{ - if (aObserver) { - aObserver->OnStartRequest(this, aContext); - mStartFired = PR_TRUE; - } - return NS_OK; -} - -nsresult -nsSocketRequest::OnStop(nsIStreamObserver *aObserver, nsISupports *aContext) -{ - if (aObserver) { - if (!mStartFired) { - aObserver->OnStartRequest(this, aContext); - mStartFired = PR_TRUE; - } - aObserver->OnStopRequest(this, aContext, mStatus, nsnull); - } - return NS_OK; -} - -NS_IMETHODIMP -nsSocketRequest::GetName(PRUnichar **aResult) -{ - return mTransport ? - mTransport->GetName(aResult) : NS_ERROR_NOT_INITIALIZED; -} - -NS_IMETHODIMP -nsSocketRequest::IsPending(PRBool *aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - *aResult = - (mTransport ? (mTransport->GetSocket() != nsnull) : nsnull); - return NS_OK; -} - -NS_IMETHODIMP -nsSocketRequest::GetStatus(nsresult *aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - *aResult = mStatus; - return NS_OK; -} - -NS_IMETHODIMP -nsSocketRequest::Cancel(nsresult status) -{ - if (!mTransport) - return NS_ERROR_NOT_INITIALIZED; - LOG(("nsSocketRequest: Cancel [this=%x status=%x]\n", this, status)); - mStatus = status; - mCanceled = PR_TRUE; - // Will be canceled the next time PR_Poll returns - return NS_OK; -} - -NS_IMETHODIMP -nsSocketRequest::Suspend() -{ - if (IsCanceled()) - return NS_ERROR_FAILURE; - if (!mTransport) - return NS_ERROR_NOT_INITIALIZED; - LOG(("nsSocketRequest: Suspend [this=%x]\n", this)); - mSuspendCount++; - // Will be suspended the next time PR_Poll returns - return NS_OK; -} - -NS_IMETHODIMP -nsSocketRequest::Resume() -{ - if (IsCanceled()) - return NS_ERROR_FAILURE; - if (!mTransport) - return NS_ERROR_NOT_INITIALIZED; - LOG(("nsSocketRequest: Resume [this=%x]\n", this)); - if (--mSuspendCount == 0) - return mTransport->Dispatch(this); - return NS_OK; -} - -NS_IMETHODIMP -nsSocketRequest::GetTransport(nsITransport **result) -{ - NS_ENSURE_ARG_POINTER(result); - NS_IF_ADDREF(*result = mTransport); - return NS_OK; -} - -// -//---------------------------------------------------------------------------- -// nsSocketReadRequest -//---------------------------------------------------------------------------- -// - -nsSocketReadRequest::nsSocketReadRequest() - : mInputStream(nsnull) -{ } - -nsSocketReadRequest::~nsSocketReadRequest() -{ - NS_IF_RELEASE(mInputStream); -} - -void -nsSocketReadRequest::SetSocket(PRFileDesc *aSock) -{ - if (!mInputStream) { - NS_NEWXPCOM(mInputStream, nsSocketIS); - if (mInputStream) { - NS_ADDREF(mInputStream); - mInputStream->SetSocket(aSock); - } - } -} - -// -// return: -// NS_OK to advance to next state -// NS_ERROR_... to advance to error state -// NS_BASE_STREAM_WOULD_BLOCK to stay on select list -// -nsresult -nsSocketReadRequest::OnRead() -{ - LOG(("nsSocketReadRequest: [this=%x] inside OnRead.\n", this)); - - NS_ENSURE_TRUE(mInputStream, NS_ERROR_NOT_INITIALIZED); - NS_ENSURE_TRUE(mListener, NS_ERROR_NOT_INITIALIZED); - - nsresult rv; - PRUint32 amount, offset = mInputStream->GetOffset(); - - rv = mInputStream->Available(&amount); - if (NS_FAILED(rv)) return rv; - - amount = PR_MIN(amount, MAX_IO_TRANSFER_SIZE); - - LOG(("nsSocketReadRequest: [this=%x] calling listener [offset=%u, count=%u]\n", - this, offset, amount)); - - rv = mListener->OnDataAvailable(this, - mListenerContext, - mInputStream, - offset, - amount); - - // - // Handle the error conditions - // - if (NS_BASE_STREAM_WOULD_BLOCK == rv) { - LOG(("nsSocketReadRequest: [this=%x] listener would block; suspending self.\n", this)); - mSuspendCount++; - } - else if (NS_BASE_STREAM_CLOSED == rv) { - LOG(("nsSocketReadRequest: [this=%x] done reading socket.\n", this)); - rv = NS_OK; // go to done state - } - else if (NS_FAILED(rv)) { - LOG(("nsSocketReadRequest: [this=%x] error reading socket.\n", this)); - } - else { - PRUint32 total = offset - mInputStream->GetOffset(); - offset += total; - - if ((0 == total) && !mInputStream->GotWouldBlock()) - LOG(("nsSocketReadRequest: [this=%x] done reading socket.\n", this)); - else { - LOG(("nsSocketReadRequest: [this=%x] read %u bytes [offset=%u]\n", - this, total, offset)); - // - // Stay in the read state - // - rv = NS_BASE_STREAM_WOULD_BLOCK; - } - - if (mTransport && total) { - mTransport->OnStatus(this, mListenerContext, NS_NET_STATUS_RECEIVING_FROM); - mTransport->OnProgress(this, mListenerContext, offset); - } - } - return rv; -} - -// -//---------------------------------------------------------------------------- -// nsSocketWriteRequest -//---------------------------------------------------------------------------- -// - -nsSocketWriteRequest::nsSocketWriteRequest() - : mOutputStream(nsnull) -{ } - -nsSocketWriteRequest::~nsSocketWriteRequest() -{ - NS_IF_RELEASE(mOutputStream); -} - -void -nsSocketWriteRequest::SetSocket(PRFileDesc *aSock) -{ - if (!mOutputStream) { - NS_NEWXPCOM(mOutputStream, nsSocketOS); - if (mOutputStream) { - NS_ADDREF(mOutputStream); - mOutputStream->SetSocket(aSock); - } - } -} - -// -// return: -// NS_OK to advance to next state -// NS_ERROR_... to advance to error state -// NS_BASE_STREAM_WOULD_BLOCK to stay on select list -// -nsresult -nsSocketWriteRequest::OnWrite() -{ - LOG(("nsSocketWriteRequest: [this=%x] inside OnWrite.\n", this)); - - NS_ENSURE_TRUE(mOutputStream, NS_ERROR_NOT_INITIALIZED); - NS_ENSURE_TRUE(mProvider, NS_ERROR_NOT_INITIALIZED); - - nsresult rv; - PRUint32 offset = mOutputStream->GetOffset(); - - rv = mProvider->OnDataWritable(this, - mProviderContext, - mOutputStream, - offset, - MAX_IO_TRANSFER_SIZE); - - // - // Handle the error conditions - // - if (NS_BASE_STREAM_WOULD_BLOCK == rv) { - LOG(("nsSocketWriteRequest: [this=%x] provider would block; suspending self.\n", this)); - mSuspendCount++; - } - else if (NS_BASE_STREAM_CLOSED == rv) { - LOG(("nsSocketWriteRequest: [this=%x] provider has finished.\n", this)); - rv = NS_OK; // go to done state - } - else if (NS_FAILED(rv)) { - LOG(("nsSocketWriteRequest: [this=%x] provider failed, rv=%x.\n", this, rv)); - } - else { - PRUint32 total = offset - mOutputStream->GetOffset(); - offset += total; - - if ((0 == total) && !mOutputStream->GotWouldBlock()) - LOG(("nsSocketWriteRequest: [this=%x] done writing to socket.\n", this)); - else { - LOG(("nsSocketWriteRequest: [this=%x] wrote %u bytes [offset=%u]\n", - this, total, offset)); - // - // Stay in the write state - // - rv = NS_BASE_STREAM_WOULD_BLOCK; - } - - if (mTransport && total) { - mTransport->OnStatus(this, mProviderContext, NS_NET_STATUS_SENDING_TO); - mTransport->OnProgress(this, mProviderContext, offset); - } - } - return rv; + return mEventSink->OnStatus(this, mReadContext, status, host.GetUnicode()); } diff --git a/mozilla/netwerk/base/src/nsSocketTransport.h b/mozilla/netwerk/base/src/nsSocketTransport.h index 461d2512b63..4456f305641 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.h +++ b/mozilla/netwerk/base/src/nsSocketTransport.h @@ -1,4 +1,5 @@ -/* +/* -*- 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.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of @@ -28,15 +29,17 @@ #include "prinrval.h" #include "nsCOMPtr.h" #include "nsISocketTransport.h" +#include "nsIChannel.h" +#include "nsIInputStream.h" #include "nsIInputStream.h" #include "nsIOutputStream.h" #include "nsIEventQueueService.h" #include "nsIStreamListener.h" #include "nsIStreamProvider.h" #include "nsIDNSListener.h" -#include "nsIDNSService.h" #include "nsIPipe.h" #include "nsIProgressEventSink.h" +#include "nsIInterfaceRequestor.h" #define NS_SOCKET_TRANSPORT_SEGMENT_SIZE (2*1024) #define NS_SOCKET_TRANSPORT_BUFFER_SIZE (8*1024) @@ -112,23 +115,23 @@ enum nsSocketReadWriteInfo { // Forward declarations... class nsSocketTransportService; -class nsSocketBS; // base class for blocking streams -class nsSocketBIS; // blocking input stream -class nsSocketBOS; // blocking output stream -class nsSocketIS; // input stream -class nsSocketOS; // output stream -class nsSocketRequest; -class nsSocketReadRequest; -class nsSocketWriteRequest; - +class nsSocketInputStream; +class nsSocketOutputStream; +class nsIInterfaceRequestor; class nsSocketTransport : public nsISocketTransport, - public nsIDNSListener + public nsIChannel, + public nsIDNSListener, + public nsIInputStreamObserver, + public nsIOutputStreamObserver { public: NS_DECL_ISUPPORTS - NS_DECL_NSITRANSPORT NS_DECL_NSISOCKETTRANSPORT + NS_DECL_NSIREQUEST + NS_DECL_NSICHANNEL + NS_DECL_NSIINPUTSTREAMOBSERVER + NS_DECL_NSIOUTPUTSTREAMOBSERVER NS_DECL_NSIDNSLISTENER // nsSocketTransport methods: @@ -146,8 +149,6 @@ public: PRUint32 bufferMaxSize); nsresult Process(PRInt16 aSelectFlags); - - nsresult Cancel(nsresult status); nsresult CheckForTimeout (PRIntervalTime aCurrentTime); @@ -163,26 +164,21 @@ public: PRBool CanBeReused(void) { return (mCurrentState != eSocketState_Error) && !mCloseConnectionOnceDone;} - - // - // request helpers - // - nsresult GetName(PRUnichar **); - nsresult Dispatch(nsSocketRequest *); - nsresult OnProgress(nsSocketRequest *, nsISupports *ctxt, PRUint32 offset); - nsresult OnStatus(nsSocketRequest *, nsISupports *ctxt, nsresult message); - + protected: nsresult doConnection(PRInt16 aSelectFlags); - nsresult doBlockingConnection(); - nsresult doReadWrite(PRInt16 aSelectFlags); - nsresult doResolveHost(); - - nsresult OnStatus(nsresult message); // with either request - - void CompleteAsyncRead(); - void CompleteAsyncWrite(); + nsresult doResolveHost(void); + nsresult doRead(PRInt16 aSelectFlags); + nsresult doReadAsync(PRInt16 aSelectFlags); + nsresult doWrite(PRInt16 aSelectFlags); + nsresult doWriteAsync(PRInt16 aSelectFlags); + + nsresult doWriteFromBuffer(PRUint32 *aCount); + nsresult doWriteFromStream(PRUint32 *aCount); + + nsresult fireStatus(PRUint32 aCode); +private: PRIntervalTime mSocketTimeout; PRIntervalTime mSocketConnectTimeout; @@ -209,234 +205,71 @@ protected: inline void ClearFlag(nsSocketReadWriteInfo aFlag) { mReadWriteState &= ~aFlag; } + + PRBool mOnStartWriteFired; + PRBool mOnStartReadFired; protected: + nsresult mCancelStatus; + PRBool mCloseConnectionOnceDone; nsSocketState mCurrentState; nsCOMPtr mDNSRequest; + nsCOMPtr mCallbacks; nsCOMPtr mEventSink; char* mHostName; PRInt32 mPort; PRIntervalTime mLastActiveTime; PRCList mListLink; + PRUint32 mLoadAttributes; PRMonitor* mMonitor; PRNetAddr mNetAddress; nsSocketOperation mOperation; + nsCOMPtr mOwner; nsCOMPtr mSecurityInfo; PRInt32 mProxyPort; char* mProxyHost; - PRPackedBool mProxyTransparent; - PRPackedBool mSSLProxy; + PRBool mProxyTransparent; + PRBool mSSLProxy; nsSocketTransportService* mService; PRUint32 mReadWriteState; PRInt16 mSelectFlags; nsresult mStatus; + PRInt32 mSuspendCount; PRFileDesc* mSocketFD; PRUint32 mSocketTypeCount; char* *mSocketTypes; - PRInt32 mBytesExpected; + nsCOMPtr mReadListener; + nsCOMPtr mReadContext; + PRUint32 mReadOffset; + + nsCOMPtr mWriteProvider; + nsCOMPtr mWriteContext; + PRUint32 mWriteOffset; + PRInt32 mWriteCount; + + PRInt32 mBytesExpected; PRUint32 mReuseCount; PRUint32 mLastReuseCount; + nsSocketInputStream *mSocketInputStream; + nsSocketOutputStream *mSocketOutputStream; + + nsCOMPtr mReadPipeIn; + nsCOMPtr mReadPipeOut; + nsCOMPtr mWritePipeIn; + nsCOMPtr mWritePipeOut; PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; PRUint32 mIdleTimeoutInSeconds; - - nsSocketBIS *mBIS; - nsSocketBOS *mBOS; - nsSocketReadRequest *mReadRequest; - nsSocketWriteRequest *mWriteRequest; - - PRPackedBool mCloseConnectionOnceDone; - PRPackedBool mWasConnected; + PRBool mWasConnected; }; -/** - * base blocking stream ... - */ -class nsSocketBS -{ -public: - nsSocketBS(); - virtual ~nsSocketBS(); - - void SetTransport(nsSocketTransport *); - void SetSocket(PRFileDesc *aSock) { mSock = aSock; } - - nsresult Poll(PRInt16 event); - -protected: - nsSocketTransport *mTransport; - PRFileDesc *mSock; -}; - -/** - * blocking input stream, returned by nsITransport::OpenInputStream() - */ -class nsSocketBIS : public nsSocketBS - , public nsIInputStream -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIINPUTSTREAM - - nsSocketBIS(); - virtual ~nsSocketBIS(); -}; - -/** - * blocking output stream, returned by nsITransport::OpenOutputStream() - */ -class nsSocketBOS : public nsSocketBS - , public nsIOutputStream -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOUTPUTSTREAM - - nsSocketBOS(); - virtual ~nsSocketBOS(); -}; - -/** - * input stream, passed to nsIStreamListener::OnDataAvailable() - */ -class nsSocketIS : public nsIInputStream -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIINPUTSTREAM - - nsSocketIS(); - virtual ~nsSocketIS() { } - - void SetSocket(PRFileDesc *aSock) { mSock = aSock; } - PRUint32 GetOffset() { return mOffset; } - void SetOffset(PRUint32 o) { mOffset = o; } - PRBool GotWouldBlock() { return mError == PR_WOULD_BLOCK_ERROR; } - PRBool GotError() { return mError != 0; } - PRErrorCode GetError() { return mError; } - -private: - PRUint32 mOffset; - PRFileDesc *mSock; - PRErrorCode mError; -}; - -/** - * output stream, passed to nsIStreamProvider::OnDataWritable() - */ -class nsSocketOS : public nsIOutputStream -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOUTPUTSTREAM - - nsSocketOS(); - virtual ~nsSocketOS() { } - - void SetSocket(PRFileDesc *aSock) { mSock = aSock; } - PRUint32 GetOffset() { return mOffset; } - void SetOffset(PRUint32 o) { mOffset = o; } - PRBool GotWouldBlock() { return mError == PR_WOULD_BLOCK_ERROR; } - PRBool GotError() { return mError != 0; } - PRErrorCode GetError() { return mError; } - -private: - PRUint32 mOffset; - PRFileDesc *mSock; - PRErrorCode mError; -}; - -/** - * base request - */ -class nsSocketRequest : public nsITransportRequest -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIREQUEST - NS_DECL_NSITRANSPORTREQUEST - - nsSocketRequest(); - virtual ~nsSocketRequest(); - - PRBool IsSuspended() { return mSuspendCount > 0; } - PRBool IsCanceled() { return mCanceled; } - - void SetTransport(nsSocketTransport *); - void SetStatus(nsresult status) { mStatus = status; } - - virtual nsISupports *GetContext() = 0; - - virtual nsresult OnStart() = 0; - virtual nsresult OnStop() = 0; - -protected: - nsresult OnStart(nsIStreamObserver *, nsISupports *); - nsresult OnStop(nsIStreamObserver *, nsISupports *); - - nsSocketTransport *mTransport; - nsresult mStatus; - PRIntn mSuspendCount; - PRPackedBool mCanceled; - PRPackedBool mStartFired; -}; - -/** - * read request, returned by nsITransport::AsyncRead() - */ -class nsSocketReadRequest : public nsSocketRequest -{ -public: - nsSocketReadRequest(); - virtual ~nsSocketReadRequest(); - - void SetSocket(PRFileDesc *); - void SetListener(nsIStreamListener *l) { mListener = l; } - void SetListenerContext(nsISupports *c) { mListenerContext = c; } - - nsISupports *GetContext() { return mListenerContext; } - - nsresult OnStart() { return nsSocketRequest::OnStart(mListener, mListenerContext); } - nsresult OnStop() { return nsSocketRequest::OnStop(mListener, mListenerContext); } - nsresult OnRead(); - -private: - nsSocketIS *mInputStream; - nsCOMPtr mListener; - nsCOMPtr mListenerContext; -}; - -/** - * write request, returned by nsITransport::AsyncWrite() - */ -class nsSocketWriteRequest : public nsSocketRequest -{ -public: - nsSocketWriteRequest(); - virtual ~nsSocketWriteRequest(); - - void SetSocket(PRFileDesc *); - void SetProvider(nsIStreamProvider *p) { mProvider = p; } - void SetProviderContext(nsISupports *c) { mProviderContext = c; } - - nsISupports *GetContext() { return mProviderContext; } - - nsresult OnStart() { return nsSocketRequest::OnStart(mProvider, mProviderContext); } - nsresult OnStop() { return nsSocketRequest::OnStop(mProvider, mProviderContext); } - nsresult OnWrite(); - -private: - nsSocketOS *mOutputStream; - nsCOMPtr mProvider; - nsCOMPtr mProviderContext; -}; #endif /* nsSocketTransport_h___ */ diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.cpp b/mozilla/netwerk/base/src/nsSocketTransportService.cpp index 2c33218ccda..40c977972e4 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransportService.cpp @@ -283,7 +283,7 @@ nsresult nsSocketTransportService::AddToSelectList(nsSocketTransport* aTransport } // Initialize/update the info in the entry... pfd = &mSelectFDSet[i]; - pfd->fd = aTransport->GetSocket(); + pfd->fd = aTransport->GetSocket();; pfd->in_flags = aTransport->GetSelectFlags(); pfd->out_flags = 0; // Add the FileDesc to the PRPollDesc list... @@ -499,7 +499,7 @@ nsSocketTransportService::CreateTransport(const char* aHost, PRInt32 proxyPort, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, - nsITransport** aResult) + nsIChannel** aResult) { return CreateTransportOfTypes(0, nsnull, aHost, aPort, proxyHost, proxyPort, bufferSegmentSize, bufferMaxSize, aResult); @@ -513,7 +513,7 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType, PRInt32 proxyPort, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, - nsITransport** aResult) + nsIChannel** aResult) { const char * types[] = { aSocketType }; return CreateTransportOfTypes(1, types, aHost, aPort, proxyHost, proxyPort, @@ -529,7 +529,7 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount, PRInt32 proxyPort, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, - nsITransport** aResult) + nsIChannel** aResult) { nsresult rv = NS_OK; @@ -572,7 +572,7 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount, } NS_IMETHODIMP -nsSocketTransportService::ReuseTransport(nsITransport* i_Transport, +nsSocketTransportService::ReuseTransport(nsIChannel* i_Transport, PRBool * o_Reuse) { nsresult rv = NS_ERROR_FAILURE; @@ -590,7 +590,7 @@ nsSocketTransportService::ReuseTransport(nsITransport* i_Transport, */ NS_IMETHODIMP -nsSocketTransportService::Wakeup (nsITransport* i_Transport) +nsSocketTransportService::Wakeup (nsIChannel* i_Transport) { nsSocketTransport *transport = NS_STATIC_CAST (nsSocketTransport *, i_Transport); diff --git a/mozilla/netwerk/base/src/nsStreamListenerProxy.cpp b/mozilla/netwerk/base/src/nsStreamListenerProxy.cpp index 74bc0343c82..b149350943b 100644 --- a/mozilla/netwerk/base/src/nsStreamListenerProxy.cpp +++ b/mozilla/netwerk/base/src/nsStreamListenerProxy.cpp @@ -35,17 +35,17 @@ //---------------------------------------------------------------------------- // Design Overview // -// A stream listener proxy maintains a pipe. When the request makes data +// A stream listener proxy maintains a pipe. When the channel makes data // available, the proxy copies as much of that data as possible into the pipe. // If data was written to the pipe, then the proxy posts an asynchronous event // corresponding to the amount of data written. If no data could be written, -// because the pipe was full, then WOULD_BLOCK is returned to the request, -// indicating that the request should suspend itself. +// because the pipe was full, then WOULD_BLOCK is returned to the channel, +// indicating that the channel should suspend itself. // -// Once suspended in this manner, the request is only resumed when the pipe is +// Once suspended in this manner, the channel is only resumed when the pipe is // emptied. // -// XXX The current design does NOT allow the request to be "externally" +// XXX The current design does NOT allow the channel to be "externally" // suspended!! For the moment this is not a problem, but it should be fixed. //---------------------------------------------------------------------------- // @@ -86,11 +86,11 @@ class nsOnDataAvailableEvent : public nsStreamObserverEvent { public: nsOnDataAvailableEvent(nsStreamProxyBase *aProxy, - nsIRequest *aRequest, + nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aSource, PRUint32 aOffset) - : nsStreamObserverEvent(aProxy, aRequest, aContext) + : nsStreamObserverEvent(aProxy, aChannel, aContext) , mSource(aSource) , mOffset(aOffset) { @@ -112,33 +112,33 @@ protected: NS_IMETHODIMP nsOnDataAvailableEvent::HandleEvent() { - LOG(("nsOnDataAvailableEvent: HandleEvent [event=%x, chan=%x]", this, mRequest.get())); + LOG(("nsOnDataAvailableEvent: HandleEvent [event=%x, chan=%x]", this, mChannel.get())); nsStreamListenerProxy *listenerProxy = NS_STATIC_CAST(nsStreamListenerProxy *, mProxy); if (NS_FAILED(listenerProxy->GetListenerStatus())) { LOG(("nsOnDataAvailableEvent: Discarding event [listener_status=%x, chan=%x]\n", - listenerProxy->GetListenerStatus(), mRequest.get())); + listenerProxy->GetListenerStatus(), mChannel.get())); return NS_ERROR_FAILURE; } nsCOMPtr listener = listenerProxy->GetListener(); if (!listener) { LOG(("nsOnDataAvailableEvent: Already called OnStopRequest (listener is NULL), [chan=%x]\n", - mRequest.get())); + mChannel.get())); return NS_ERROR_FAILURE; } nsresult status = NS_OK; - nsresult rv = mRequest->GetStatus(&status); + nsresult rv = mChannel->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); // - // We should only forward this event to the listener if the request is + // We should only forward this event to the listener if the channel is // still in a "good" state. Because these events are being processed // asynchronously, there is a very real chance that the listener might - // have cancelled the request after _this_ event was triggered. + // have cancelled the channel after _this_ event was triggered. // if (NS_SUCCEEDED(status)) { // @@ -152,21 +152,21 @@ nsOnDataAvailableEvent::HandleEvent() mSource->Available(&avail); LOG(("nsOnDataAvailableEvent: Calling the consumer's OnDataAvailable " "[offset=%u count=%u avail=%u chan=%x]\n", - mOffset, count, avail, mRequest.get())); + mOffset, count, avail, mChannel.get())); } #endif // Forward call to listener - rv = listener->OnDataAvailable(mRequest, mContext, mSource, mOffset, count); + rv = listener->OnDataAvailable(mChannel, mContext, mSource, mOffset, count); LOG(("nsOnDataAvailableEvent: Done with the consumer's OnDataAvailable " "[rv=%x, chan=%x]\n", - rv, mRequest.get())); + rv, mChannel.get())); // - // XXX Need to suspend the underlying request... must consider + // XXX Need to suspend the underlying channel... must consider // other pending events (such as OnStopRequest). These - // should not be forwarded to the listener if the request + // should not be forwarded to the listener if the channel // is suspended. Also, handling the Resume could be tricky. // if (rv == NS_BASE_STREAM_WOULD_BLOCK) { @@ -182,7 +182,7 @@ nsOnDataAvailableEvent::HandleEvent() } else LOG(("nsOnDataAvailableEvent: Not calling OnDataAvailable [chan=%x]", - mRequest.get())); + mChannel.get())); return NS_OK; } @@ -203,15 +203,15 @@ NS_IMPL_ISUPPORTS_INHERITED3(nsStreamListenerProxy, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamListenerProxy::OnStartRequest(nsIRequest *aRequest, +nsStreamListenerProxy::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { - return nsStreamProxyBase::OnStartRequest(aRequest, aContext); + return nsStreamProxyBase::OnStartRequest(aChannel, aContext); } NS_IMETHODIMP -nsStreamListenerProxy::OnStopRequest(nsIRequest *aRequest, +nsStreamListenerProxy::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) @@ -222,7 +222,7 @@ nsStreamListenerProxy::OnStopRequest(nsIRequest *aRequest, mPipeIn = 0; mPipeOut = 0; - return nsStreamProxyBase::OnStopRequest(aRequest, aContext, + return nsStreamProxyBase::OnStopRequest(aChannel, aContext, aStatus, aStatusText); } @@ -232,7 +232,7 @@ nsStreamListenerProxy::OnStopRequest(nsIRequest *aRequest, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, +nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aSource, PRUint32 aOffset, @@ -242,9 +242,9 @@ nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, PRUint32 bytesWritten=0; LOG(("nsStreamListenerProxy: OnDataAvailable [offset=%u count=%u chan=%x]\n", - aOffset, aCount, aRequest)); + aOffset, aCount, aChannel)); - NS_PRECONDITION(mRequestToResume == 0, "Unexpected call to OnDataAvailable"); + NS_PRECONDITION(mChannelToResume == 0, "Unexpected call to OnDataAvailable"); NS_PRECONDITION(mPipeIn, "Pipe not initialized"); NS_PRECONDITION(mPipeOut, "Pipe not initialized"); @@ -254,7 +254,7 @@ nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, { nsresult status = mListenerStatus; if (NS_FAILED(status)) { - LOG(("nsStreamListenerProxy: Listener failed [status=%x chan=%x]\n", status, aRequest)); + LOG(("nsStreamListenerProxy: Listener failed [status=%x chan=%x]\n", status, aChannel)); return status; } } @@ -265,29 +265,29 @@ nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, // Try to copy data into the pipe. // // If the pipe is full, then we return NS_BASE_STREAM_WOULD_BLOCK - // so the calling request can suspend itself. If, however, we detect + // so the calling channel can suspend itself. If, however, we detect // that the pipe was emptied during this time, we retry copying data // into the pipe. // rv = mPipeOut->WriteFrom(aSource, aCount, &bytesWritten); LOG(("nsStreamListenerProxy: Wrote data to pipe [rv=%x count=%u bytesWritten=%u chan=%x]\n", - rv, aCount, bytesWritten, aRequest)); + rv, aCount, bytesWritten, aChannel)); if (NS_FAILED(rv)) { if (rv == NS_BASE_STREAM_WOULD_BLOCK) { nsAutoLock lock(mLock); if (mPipeEmptied) { - LOG(("nsStreamListenerProxy: Pipe emptied; looping back [chan=%x]\n", aRequest)); + LOG(("nsStreamListenerProxy: Pipe emptied; looping back [chan=%x]\n", aChannel)); continue; } - LOG(("nsStreamListenerProxy: Pipe full; setting request to resume [chan=%x]\n", aRequest)); - mRequestToResume = aRequest; + LOG(("nsStreamListenerProxy: Pipe full; setting channel to resume [chan=%x]\n", aChannel)); + mChannelToResume = aChannel; } return rv; } if (bytesWritten == 0) { - LOG(("nsStreamListenerProxy: Copied zero bytes; not posting an event [chan=%x]\n", aRequest)); + LOG(("nsStreamListenerProxy: Copied zero bytes; not posting an event [chan=%x]\n", aChannel)); return NS_OK; } @@ -301,7 +301,7 @@ nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, PRUint32 total = PR_AtomicAdd((PRInt32 *) &mPendingCount, bytesWritten); if (total > bytesWritten) { LOG(("nsStreamListenerProxy: Piggy-backing pending event [total=%u, chan=%x]\n", - total, aRequest)); + total, aChannel)); return NS_OK; } @@ -309,7 +309,7 @@ nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, // Post an event for the number of bytes actually written. // nsOnDataAvailableEvent *ev = - new nsOnDataAvailableEvent(this, aRequest, aContext, mPipeIn, aOffset); + new nsOnDataAvailableEvent(this, aChannel, aContext, mPipeIn, aOffset); if (!ev) return NS_ERROR_OUT_OF_MEMORY; rv = ev->FireEvent(GetEventQueue()); @@ -374,23 +374,23 @@ nsStreamListenerProxy::OnEmpty(nsIInputStream *aInputStream) { LOG(("nsStreamListenerProxy: OnEmpty\n")); // - // The pipe has been emptied by the listener. If the request + // The pipe has been emptied by the listener. If the channel // has been suspended (waiting for the pipe to be emptied), then // go ahead and resume it. But take care not to resume while // holding the "ChannelToResume" lock. // - nsCOMPtr req; + nsCOMPtr chan; { nsAutoLock lock(mLock); - if (mRequestToResume) { - req = mRequestToResume; - mRequestToResume = 0; + if (mChannelToResume) { + chan = mChannelToResume; + mChannelToResume = 0; } mPipeEmptied = PR_TRUE; // Flag this call } - if (req) { - LOG(("nsStreamListenerProxy: Resuming request\n")); - req->Resume(); + if (chan) { + LOG(("nsStreamListenerProxy: Resuming channel\n")); + chan->Resume(); } return NS_OK; } diff --git a/mozilla/netwerk/base/src/nsStreamListenerProxy.h b/mozilla/netwerk/base/src/nsStreamListenerProxy.h index 99265db8752..f77d3b8fe99 100644 --- a/mozilla/netwerk/base/src/nsStreamListenerProxy.h +++ b/mozilla/netwerk/base/src/nsStreamListenerProxy.h @@ -42,7 +42,7 @@ public: protected: nsCOMPtr mPipeIn; nsCOMPtr mPipeOut; - nsCOMPtr mRequestToResume; + nsCOMPtr mChannelToResume; PRLock *mLock; PRUint32 mPendingCount; PRBool mPipeEmptied; diff --git a/mozilla/netwerk/base/src/nsStreamLoader.cpp b/mozilla/netwerk/base/src/nsStreamLoader.cpp index eb9cce7920a..c63e62cef85 100644 --- a/mozilla/netwerk/base/src/nsStreamLoader.cpp +++ b/mozilla/netwerk/base/src/nsStreamLoader.cpp @@ -35,14 +35,16 @@ nsStreamLoader::Init(nsIURI* aURL, nsISupports* context, nsILoadGroup* aGroup, nsIInterfaceRequestor* notificationCallbacks, - nsLoadFlags loadAttributes) + nsLoadFlags loadAttributes, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize) { nsresult rv = NS_OK; mObserver = observer; mContext = context; rv = NS_OpenURI(this, nsnull, aURL, nsnull, aGroup, notificationCallbacks, - loadAttributes); + loadAttributes, bufferSegmentSize, bufferMaxSize); if (NS_FAILED(rv) && mObserver) { // don't callback synchronously as it puts the caller // in a recursive situation and breaks the asynchronous @@ -94,27 +96,26 @@ nsStreamLoader::GetNumBytesRead(PRUint32* aNumBytes) return NS_OK; } -/* readonly attribute nsIRequest request; */ NS_IMETHODIMP -nsStreamLoader::GetRequest(nsIRequest * *aRequest) +nsStreamLoader::GetChannel(nsIChannel** aChannel) { - NS_IF_ADDREF(*aRequest=mRequest); - return NS_OK; + *aChannel = mChannel.get(); + NS_IF_ADDREF(*aChannel); + return NS_OK; } - NS_IMETHODIMP -nsStreamLoader::OnStartRequest(nsIRequest* request, nsISupports *ctxt) +nsStreamLoader::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { return NS_OK; } NS_IMETHODIMP -nsStreamLoader::OnStopRequest(nsIRequest* request, nsISupports *ctxt, +nsStreamLoader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - mRequest = request; + mChannel = channel; rv = mObserver->OnStreamComplete(this, mContext, aStatus, mData.Length(), mData.GetBuffer()); @@ -124,7 +125,7 @@ nsStreamLoader::OnStopRequest(nsIRequest* request, nsISupports *ctxt, #define BUF_SIZE 1024 NS_IMETHODIMP -nsStreamLoader::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, +nsStreamLoader::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { diff --git a/mozilla/netwerk/base/src/nsStreamLoader.h b/mozilla/netwerk/base/src/nsStreamLoader.h index 3d8deaa6c2d..f6f07cacba9 100644 --- a/mozilla/netwerk/base/src/nsStreamLoader.h +++ b/mozilla/netwerk/base/src/nsStreamLoader.h @@ -47,7 +47,7 @@ protected: nsCOMPtr mObserver; nsCOMPtr mContext; // the observer's context nsCString mData; - nsCOMPtr mRequest; + nsCOMPtr mChannel; /// nsCOMPtr mLoadGroup; }; diff --git a/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp b/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp index 6e9e515b86a..3df29809b2d 100644 --- a/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp +++ b/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp @@ -39,10 +39,10 @@ static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); //---------------------------------------------------------------------------- // nsStreamObserverEvent::nsStreamObserverEvent(nsStreamProxyBase *aProxy, - nsIRequest *aRequest, + nsIChannel *aChannel, nsISupports *aContext) : mProxy(aProxy) - , mRequest(aRequest) + , mChannel(aChannel) , mContext(aContext) { NS_IF_ADDREF(mProxy); @@ -94,9 +94,9 @@ class nsOnStartRequestEvent : public nsStreamObserverEvent { public: nsOnStartRequestEvent(nsStreamProxyBase *aProxy, - nsIRequest *aRequest, + nsIChannel *aChannel, nsISupports *aContext) - : nsStreamObserverEvent(aProxy, aRequest, aContext) + : nsStreamObserverEvent(aProxy, aChannel, aContext) { MOZ_COUNT_CTOR(nsOnStartRequestEvent); } @@ -112,8 +112,8 @@ public: NS_IMETHODIMP nsOnStartRequestEvent::HandleEvent() { - LOG(("nsOnStartRequestEvent: HandleEvent [event=%x req=%x]\n", - this, mRequest.get())); + LOG(("nsOnStartRequestEvent: HandleEvent [event=%x chan=%x]\n", + this, mChannel.get())); nsCOMPtr observer = mProxy->GetReceiver(); if (!observer) { @@ -121,7 +121,7 @@ nsOnStartRequestEvent::HandleEvent() return NS_ERROR_FAILURE; } - return observer->OnStartRequest(mRequest, mContext); + return observer->OnStartRequest(mChannel, mContext); } // @@ -133,9 +133,9 @@ class nsOnStopRequestEvent : public nsStreamObserverEvent { public: nsOnStopRequestEvent(nsStreamProxyBase *aProxy, - nsIRequest *aRequest, nsISupports *aContext, + nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) - : nsStreamObserverEvent(aProxy, aRequest, aContext) + : nsStreamObserverEvent(aProxy, aChannel, aContext) , mStatus(aStatus) , mStatusText(aStatusText) { @@ -157,8 +157,8 @@ protected: NS_IMETHODIMP nsOnStopRequestEvent::HandleEvent() { - LOG(("nsOnStopRequestEvent: HandleEvent [event=%x req=%x]\n", - this, mRequest.get())); + LOG(("nsOnStopRequestEvent: HandleEvent [event=%x chan=%x]\n", + this, mChannel.get())); nsCOMPtr observer = mProxy->GetReceiver(); if (!observer) { @@ -171,7 +171,7 @@ nsOnStopRequestEvent::HandleEvent() // mProxy->SetReceiver(nsnull); - return observer->OnStopRequest(mRequest, + return observer->OnStopRequest(mChannel, mContext, mStatus, mStatusText.GetUnicode()); @@ -191,12 +191,12 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsStreamProxyBase, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamProxyBase::OnStartRequest(nsIRequest *aRequest, +nsStreamProxyBase::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { - LOG(("nsStreamProxyBase: OnStartRequest [this=%x req=%x]\n", this, aRequest)); + LOG(("nsStreamProxyBase: OnStartRequest [this=%x chan=%x]\n", this, aChannel)); nsOnStartRequestEvent *ev = - new nsOnStartRequestEvent(this, aRequest, aContext); + new nsOnStartRequestEvent(this, aChannel, aContext); if (!ev) return NS_ERROR_OUT_OF_MEMORY; @@ -207,15 +207,15 @@ nsStreamProxyBase::OnStartRequest(nsIRequest *aRequest, } NS_IMETHODIMP -nsStreamProxyBase::OnStopRequest(nsIRequest *aRequest, +nsStreamProxyBase::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { - LOG(("nsStreamProxyBase: OnStopRequest [this=%x req=%x status=%x]\n", - this, aRequest, aStatus)); + LOG(("nsStreamProxyBase: OnStopRequest [this=%x chan=%x status=%x]\n", + this, aChannel, aStatus)); nsOnStopRequestEvent *ev = - new nsOnStopRequestEvent(this, aRequest, aContext, aStatus, aStatusText); + new nsOnStopRequestEvent(this, aChannel, aContext, aStatus, aStatusText); if (!ev) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/base/src/nsStreamObserverProxy.h b/mozilla/netwerk/base/src/nsStreamObserverProxy.h index 8add5d2ee47..6466f1fffe2 100644 --- a/mozilla/netwerk/base/src/nsStreamObserverProxy.h +++ b/mozilla/netwerk/base/src/nsStreamObserverProxy.h @@ -70,7 +70,7 @@ class nsStreamObserverEvent { public: nsStreamObserverEvent(nsStreamProxyBase *proxy, - nsIRequest *request, nsISupports *context); + nsIChannel *channel, nsISupports *context); virtual ~nsStreamObserverEvent(); nsresult FireEvent(nsIEventQueue *); @@ -82,7 +82,7 @@ protected: PLEvent mEvent; nsStreamProxyBase *mProxy; - nsCOMPtr mRequest; + nsCOMPtr mChannel; nsCOMPtr mContext; }; diff --git a/mozilla/netwerk/base/src/nsStreamProviderProxy.cpp b/mozilla/netwerk/base/src/nsStreamProviderProxy.cpp index cc24f5984c5..c931b187962 100644 --- a/mozilla/netwerk/base/src/nsStreamProviderProxy.cpp +++ b/mozilla/netwerk/base/src/nsStreamProviderProxy.cpp @@ -33,12 +33,12 @@ // Design Overview // // A stream provider proxy maintains a pipe. When requested to provide data -// to the request, whatever data is in the pipe (up to the amount requested) -// is provided to the request. If there is no data in the pipe, then the +// to the channel, whatever data is in the pipe (up to the amount requested) +// is provided to the channel. If there is no data in the pipe, then the // proxy posts an asynchronous event for more data, and returns WOULD_BLOCK -// indicating that the request should suspend itself. +// indicating that the channel should suspend itself. // -// The request is only resumed once the event has been successfully handled; +// The channel is only resumed once the event has been successfully handled; // meaning that data has been written to the pipe. //---------------------------------------------------------------------------- // @@ -59,12 +59,12 @@ class nsOnDataWritableEvent : public nsStreamObserverEvent { public: nsOnDataWritableEvent(nsStreamProxyBase *aProxy, - nsIRequest *aRequest, + nsIChannel *aChannel, nsISupports *aContext, nsIOutputStream *aSink, PRUint32 aOffset, PRUint32 aCount) - : nsStreamObserverEvent(aProxy, aRequest, aContext) + : nsStreamObserverEvent(aProxy, aChannel, aContext) , mSink(aSink) , mOffset(aOffset) , mCount(aCount) @@ -89,7 +89,7 @@ NS_IMETHODIMP nsOnDataWritableEvent::HandleEvent() { LOG(("nsOnDataWritableEvent: HandleEvent [event=%x chan=%x]", - this, mRequest.get())); + this, mChannel.get())); nsStreamProviderProxy *providerProxy = NS_STATIC_CAST(nsStreamProviderProxy *, mProxy); @@ -101,18 +101,18 @@ nsOnDataWritableEvent::HandleEvent() } nsresult status = NS_OK; - nsresult rv = mRequest->GetStatus(&status); + nsresult rv = mChannel->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); // - // We should only forward this event to the provider if the request is + // We should only forward this event to the provider if the channel is // still in a "good" state. Because these events are being processed // asynchronously, there is a very real chance that the provider might - // have cancelled the request after _this_ event was triggered. + // have cancelled the channel after _this_ event was triggered. // if (NS_SUCCEEDED(status)) { LOG(("nsOnDataWritableEvent: Calling the consumer's OnDataWritable\n")); - rv = provider->OnDataWritable(mRequest, mContext, mSink, mOffset, mCount); + rv = provider->OnDataWritable(mChannel, mContext, mSink, mOffset, mCount); LOG(("nsOnDataWritableEvent: Done with the consumer's OnDataWritable [rv=%x]\n", rv)); // @@ -122,11 +122,11 @@ nsOnDataWritableEvent::HandleEvent() rv != NS_BASE_STREAM_WOULD_BLOCK ? rv : NS_OK); // - // The request is already suspended, so unless the provider returned - // NS_BASE_STREAM_WOULD_BLOCK, we should wake up the request. + // The channel is already suspended, so unless the provider returned + // NS_BASE_STREAM_WOULD_BLOCK, we should wake up the channel. // if (rv != NS_BASE_STREAM_WOULD_BLOCK) - mRequest->Resume(); + mChannel->Resume(); } else LOG(("nsOnDataWritableEvent: Not calling OnDataWritable")); @@ -149,14 +149,14 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsStreamProviderProxy, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamProviderProxy::OnStartRequest(nsIRequest *request, +nsStreamProviderProxy::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { - return nsStreamProxyBase::OnStartRequest(request, aContext); + return nsStreamProxyBase::OnStartRequest(aChannel, aContext); } NS_IMETHODIMP -nsStreamProviderProxy::OnStopRequest(nsIRequest* request, +nsStreamProviderProxy::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) @@ -167,7 +167,7 @@ nsStreamProviderProxy::OnStopRequest(nsIRequest* request, mPipeIn = 0; mPipeOut = 0; - return nsStreamProxyBase::OnStopRequest(request, aContext, + return nsStreamProxyBase::OnStopRequest(aChannel, aContext, aStatus, aStatusText); } @@ -189,7 +189,7 @@ nsWriteToSink(nsIInputStream *source, } NS_IMETHODIMP -nsStreamProviderProxy::OnDataWritable(nsIRequest *aRequest, +nsStreamProviderProxy::OnDataWritable(nsIChannel *aChannel, nsISupports *aContext, nsIOutputStream *aSink, PRUint32 aOffset, @@ -215,7 +215,7 @@ nsStreamProviderProxy::OnDataWritable(nsIRequest *aRequest, } // - // Provide the request with whatever data is already in the pipe (not + // Provide the channel with whatever data is already in the pipe (not // exceeding aCount). // PRUint32 count; @@ -236,7 +236,7 @@ nsStreamProviderProxy::OnDataWritable(nsIRequest *aRequest, // Post an event requesting the provider for more data. // nsOnDataWritableEvent *ev = - new nsOnDataWritableEvent(this, aRequest, aContext, + new nsOnDataWritableEvent(this, aChannel, aContext, mPipeOut, aOffset, aCount); if (!ev) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/base/src/nsSyncStreamListener.cpp b/mozilla/netwerk/base/src/nsSyncStreamListener.cpp index 7f32fd4a2cd..ee589e19b9f 100644 --- a/mozilla/netwerk/base/src/nsSyncStreamListener.cpp +++ b/mozilla/netwerk/base/src/nsSyncStreamListener.cpp @@ -55,13 +55,13 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsSyncStreamListener, nsIStreamObserver) NS_IMETHODIMP -nsSyncStreamListener::OnStartRequest(nsIRequest* request, nsISupports* context) +nsSyncStreamListener::OnStartRequest(nsIChannel* channel, nsISupports* context) { return NS_OK; } NS_IMETHODIMP -nsSyncStreamListener::OnStopRequest(nsIRequest* request, nsISupports* context, +nsSyncStreamListener::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { // XXX what do we do with the status and error message? @@ -69,7 +69,7 @@ nsSyncStreamListener::OnStopRequest(nsIRequest* request, nsISupports* context, } NS_IMETHODIMP -nsSyncStreamListener::OnDataAvailable(nsIRequest* request, +nsSyncStreamListener::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, diff --git a/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.cpp b/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.cpp index 952a3f28428..7cd893ac84d 100644 --- a/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.cpp +++ b/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.cpp @@ -68,7 +68,7 @@ nsDiskCacheRecord::nsDiskCacheRecord(nsIDBAccessor* db, nsNetDiskCache* aCache) mDB(db) , mInfo(0) , mInfoSize(0) , - mNumTransports(0) , + mNumChannels(0) , mDiskCache(aCache) { NS_INIT_REFCNT(); @@ -284,7 +284,7 @@ nsDiskCacheRecord::SetSecurityInfo (nsISupports * o_SecurityInfo) NS_IMETHODIMP nsDiskCacheRecord::Delete(void) { - if(mNumTransports) + if(mNumChannels) return NS_ERROR_NOT_AVAILABLE ; // Delete any file associated with this entry. Remember we might @@ -333,20 +333,19 @@ nsDiskCacheRecord::GetFile(nsIFile * *aFile) } NS_IMETHODIMP -nsDiskCacheRecord::NewTransport(nsILoadGroup *loadGroup, nsITransport **_retval) +nsDiskCacheRecord::NewChannel(nsILoadGroup *loadGroup, nsIChannel **_retval) { - nsDiskCacheRecordTransport* transport = - new nsDiskCacheRecordTransport(this, loadGroup); - if(!transport) - return NS_ERROR_OUT_OF_MEMORY; + nsDiskCacheRecordChannel* channel = new nsDiskCacheRecordChannel(this, loadGroup) ; + if(!channel) + return NS_ERROR_OUT_OF_MEMORY ; - nsresult rv = transport->Init(); + nsresult rv = channel->Init() ; if(NS_FAILED(rv)) - return rv; + return rv ; - NS_ADDREF(transport); - *_retval = NS_STATIC_CAST(nsITransport*, transport); - return NS_OK; + NS_ADDREF(channel) ; + *_retval = NS_STATIC_CAST(nsIChannel*, channel) ; + return NS_OK ; } ////////////////////////////////////////////////////////////////////////// @@ -562,4 +561,3 @@ nsDiskCacheRecord::UpdateFileInfo() mFile = spec; return rv; } - diff --git a/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.h b/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.h index 7730ae8634a..cdae2a22b04 100644 --- a/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.h +++ b/mozilla/netwerk/cache/filecache/nsDiskCacheRecord.h @@ -34,7 +34,8 @@ class nsDiskCacheRecord : public nsINetDataCacheRecord { -public: + public: + NS_DECL_ISUPPORTS NS_DECL_NSINETDATACACHERECORD @@ -45,15 +46,15 @@ public: // we need to invalidate the mFile's stat cache. NS_IMETHOD WriteComplete(); -protected: + protected: - nsDiskCacheRecord(nsIDBAccessor* db, nsNetDiskCache* aCache); - virtual ~nsDiskCacheRecord(); + nsDiskCacheRecord(nsIDBAccessor* db, nsNetDiskCache* aCache) ; + virtual ~nsDiskCacheRecord() ; - NS_IMETHOD RetrieveInfo(void* aInfo, PRUint32 aInfoLength); - NS_IMETHOD Init(const char* key, PRUint32 length, PRInt32 ID); + NS_IMETHOD RetrieveInfo(void* aInfo, PRUint32 aInfoLength) ; + NS_IMETHOD Init(const char* key, PRUint32 length, PRInt32 ID) ; - nsresult GenInfo(void); + nsresult GenInfo(void) ; // The mFile we store might be out of date. Atlease @@ -63,23 +64,23 @@ protected: // file info. NS_IMETHOD UpdateFileInfo(); -private: + private: - char* mKey; - PRUint32 mKeyLength; - PRInt32 mRecordID; - char* mMetaData; - PRUint32 mMetaDataLength; - nsCOMPtr mFile; - nsCOMPtr mDB; - void* mInfo; - PRUint32 mInfoSize; - PRUint32 mNumTransports; - nsNetDiskCache* mDiskCache; + char* mKey ; + PRUint32 mKeyLength ; + PRInt32 mRecordID ; + char* mMetaData ; + PRUint32 mMetaDataLength ; + nsCOMPtr mFile ; + nsCOMPtr mDB ; + void* mInfo ; + PRUint32 mInfoSize ; + PRUint32 mNumChannels ; + nsNetDiskCache* mDiskCache ; - friend class nsDiskCacheRecordTransport; - friend class nsDBEnumerator; - friend class nsNetDiskCache; -}; + friend class nsDiskCacheRecordChannel ; + friend class nsDBEnumerator ; + friend class nsNetDiskCache ; +} ; #endif // _NET_CACHEDDISKDATA_H_ diff --git a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp index 337969ebe31..797a1477f6a 100644 --- a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp +++ b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp @@ -45,19 +45,19 @@ static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); class WriteStreamWrapper : public nsIOutputStream { public: - WriteStreamWrapper(nsDiskCacheRecordTransport* aTransport, + WriteStreamWrapper(nsDiskCacheRecordChannel* aChannel, nsIOutputStream *aBaseStream); virtual ~WriteStreamWrapper(); static nsresult - Create(nsDiskCacheRecordTransport* aTransport, nsIOutputStream *aBaseStream, nsIOutputStream* *aWrapper); + Create(nsDiskCacheRecordChannel* aChannel, nsIOutputStream *aBaseStream, nsIOutputStream* *aWrapper); NS_DECL_ISUPPORTS NS_DECL_NSIOUTPUTSTREAM private: - nsDiskCacheRecordTransport* mTransport; + nsDiskCacheRecordChannel* mChannel; nsCOMPtr mBaseStream; PRUint32 mTotalSize; PRUint32 mOldLength; @@ -66,24 +66,24 @@ class WriteStreamWrapper : public nsIOutputStream // implement nsISupports NS_IMPL_THREADSAFE_ISUPPORTS1(WriteStreamWrapper, nsIOutputStream) -WriteStreamWrapper::WriteStreamWrapper(nsDiskCacheRecordTransport* aTransport, +WriteStreamWrapper::WriteStreamWrapper(nsDiskCacheRecordChannel* aChannel, nsIOutputStream *aBaseStream) - : mTransport(aTransport), mBaseStream(aBaseStream), mTotalSize(0), mOldLength(0) + : mChannel(aChannel), mBaseStream(aBaseStream), mTotalSize(0), mOldLength(0) { NS_INIT_REFCNT(); - NS_ADDREF(mTransport); - mTransport->mRecord->GetStoredContentLength(&mOldLength); + NS_ADDREF(mChannel); + mChannel->mRecord->GetStoredContentLength(&mOldLength); } WriteStreamWrapper::~WriteStreamWrapper() { - NS_RELEASE(mTransport); + NS_RELEASE(mChannel); } nsresult -WriteStreamWrapper::Create(nsDiskCacheRecordTransport*aTransport, nsIOutputStream *aBaseStream, nsIOutputStream* * aWrapper) +WriteStreamWrapper::Create(nsDiskCacheRecordChannel*aChannel, nsIOutputStream *aBaseStream, nsIOutputStream* * aWrapper) { - WriteStreamWrapper *wrapper = new WriteStreamWrapper(aTransport, aBaseStream); + WriteStreamWrapper *wrapper = new WriteStreamWrapper(aChannel, aBaseStream); if (!wrapper) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(wrapper); *aWrapper = wrapper; @@ -153,35 +153,36 @@ WriteStreamWrapper::Close() nsresult rv = mBaseStream->Close(); // Tell the record we finished write to the file - mTransport->mRecord->WriteComplete(); + mChannel->mRecord->WriteComplete(); if (mTotalSize < mOldLength) { // Truncate the file if we have to. It should have been already but that // would be too easy wouldn't it!!! - mTransport->mRecord->SetStoredContentLength(mTotalSize); + mChannel->mRecord->SetStoredContentLength(mTotalSize); } else if (mTotalSize > mOldLength) { - mTransport->NotifyStorageInUse(mTotalSize - mOldLength); + mChannel->NotifyStorageInUse(mTotalSize - mOldLength); } return rv; } -nsDiskCacheRecordTransport::nsDiskCacheRecordTransport(nsDiskCacheRecord *aRecord, +nsDiskCacheRecordChannel::nsDiskCacheRecordChannel(nsDiskCacheRecord *aRecord, nsILoadGroup *aLoadGroup) : mRecord(aRecord), mLoadGroup(aLoadGroup), + mLoadAttributes(nsIChannel::LOAD_NORMAL), mStatus(NS_OK) { NS_INIT_REFCNT(); NS_ADDREF(mRecord); - mRecord->mNumTransports++; + mRecord->mNumChannels++; } -nsDiskCacheRecordTransport::~nsDiskCacheRecordTransport() +nsDiskCacheRecordChannel::~nsDiskCacheRecordChannel() { - mRecord->mNumTransports--; + mRecord->mNumChannels--; NS_RELEASE(mRecord); } @@ -204,7 +205,7 @@ nsDiskCacheRecordTransport::~nsDiskCacheRecordTransport() // conversions for every cache file we open. nsresult -nsDiskCacheRecordTransport::Init(void) +nsDiskCacheRecordChannel::Init(void) { nsresult rv = mRecord->mFile->Clone(getter_AddRefs(mSpec)) ; #if 0 @@ -225,125 +226,110 @@ nsDiskCacheRecordTransport::Init(void) } nsresult -nsDiskCacheRecordTransport::NotifyStorageInUse(PRInt32 aBytesUsed) +nsDiskCacheRecordChannel::NotifyStorageInUse(PRInt32 aBytesUsed) { return mRecord->mDiskCache->mStorageInUse += aBytesUsed; } // implement nsISupports -NS_IMPL_THREADSAFE_ISUPPORTS5(nsDiskCacheRecordTransport, - nsITransport, - nsITransportRequest, - nsIRequest, - nsIStreamListener, - nsIStreamObserver) +NS_IMPL_THREADSAFE_ISUPPORTS4(nsDiskCacheRecordChannel, + nsIChannel, + nsIRequest, + nsIStreamListener, + nsIStreamObserver) // implement nsIRequest NS_IMETHODIMP -nsDiskCacheRecordTransport::GetName(PRUnichar* *result) +nsDiskCacheRecordChannel::GetName(PRUnichar* *result) { - NS_NOTREACHED("nsDiskCacheRecordTransport::GetName"); + NS_NOTREACHED("nsDiskCacheRecordChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsDiskCacheRecordTransport::IsPending(PRBool *aIsPending) +nsDiskCacheRecordChannel::IsPending(PRBool *aIsPending) { *aIsPending = PR_FALSE; - if(!mCurrentReadRequest) + if(!mFileTransport) return NS_OK; - return mCurrentReadRequest->IsPending(aIsPending); + return mFileTransport->IsPending(aIsPending); } NS_IMETHODIMP -nsDiskCacheRecordTransport::GetStatus(nsresult *status) +nsDiskCacheRecordChannel::GetStatus(nsresult *status) { *status = mStatus; return NS_OK; } NS_IMETHODIMP -nsDiskCacheRecordTransport::Cancel(nsresult status) +nsDiskCacheRecordChannel::Cancel(nsresult status) { NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code"); mStatus = status; - if(!mCurrentReadRequest) + if(!mFileTransport) return NS_ERROR_FAILURE; - return mCurrentReadRequest->Cancel(status); + return mFileTransport->Cancel(status); } NS_IMETHODIMP -nsDiskCacheRecordTransport::Suspend(void) +nsDiskCacheRecordChannel::Suspend(void) { - if(!mCurrentReadRequest) + if(!mFileTransport) return NS_ERROR_FAILURE; - return mCurrentReadRequest->Suspend(); + return mFileTransport->Suspend(); } NS_IMETHODIMP -nsDiskCacheRecordTransport::Resume(void) +nsDiskCacheRecordChannel::Resume(void) { - if(!mCurrentReadRequest) + if(!mFileTransport) return NS_ERROR_FAILURE; - return mCurrentReadRequest->Resume(); + return mFileTransport->Resume(); } -NS_IMETHODIMP -nsDiskCacheRecordTransport::GetTransport(nsITransport **result) -{ - NS_ENSURE_ARG_POINTER(result); - NS_ADDREF(*result = this); - return NS_OK; -} - - -#if 0 // implement nsIChannel NS_IMETHODIMP -nsDiskCacheRecordTransport::GetOriginalURI(nsIURI* *aURI) +nsDiskCacheRecordChannel::GetOriginalURI(nsIURI* *aURI) { // FUR - might need to implement this - not sure - NS_NOTREACHED("nsDiskCacheRecordTransport::GetOriginalURI"); + NS_NOTREACHED("nsDiskCacheRecordChannel::GetOriginalURI"); return NS_ERROR_NOT_IMPLEMENTED ; } NS_IMETHODIMP -nsDiskCacheRecordTransport::SetOriginalURI(nsIURI* aURI) +nsDiskCacheRecordChannel::SetOriginalURI(nsIURI* aURI) { // FUR - might need to implement this - not sure - NS_NOTREACHED("nsDiskCacheRecordTransport::SetOriginalURI"); + NS_NOTREACHED("nsDiskCacheRecordChannel::SetOriginalURI"); return NS_ERROR_NOT_IMPLEMENTED ; } NS_IMETHODIMP -nsDiskCacheRecordTransport::GetURI(nsIURI* *aURI) +nsDiskCacheRecordChannel::GetURI(nsIURI* *aURI) { if(!mFileTransport) return NS_ERROR_FAILURE; - return mFileTransport->GetURI(aURI); // no-op + return mFileTransport->GetURI(aURI); } NS_IMETHODIMP -nsDiskCacheRecordTransport::SetURI(nsIURI* aURI) +nsDiskCacheRecordChannel::SetURI(nsIURI* aURI) { if(!mFileTransport) return NS_ERROR_FAILURE; - return mFileTransport->SetURI(aURI); // no-op + return mFileTransport->SetURI(aURI); } -#endif NS_IMETHODIMP -nsDiskCacheRecordTransport::OpenInputStream(PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIInputStream* *aResult) +nsDiskCacheRecordChannel::OpenInputStream(nsIInputStream* *aResult) { nsresult rv; @@ -353,19 +339,14 @@ nsDiskCacheRecordTransport::OpenInputStream(PRUint32 transferOffset, NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if(NS_FAILED(rv)) return rv; - rv = fts->CreateTransport(mSpec, - PR_RDONLY, - PR_IRUSR | PR_IWUSR, + rv = fts->CreateTransport(mSpec, PR_RDONLY, PR_IRUSR | PR_IWUSR, getter_AddRefs(mFileTransport)); if(NS_FAILED(rv)) return rv; - // we don't need to worry about progress notification + // we don't need to worry about notification callbacks - rv = mFileTransport->OpenInputStream(transferOffset, - transferCount, - transferFlags, - aResult); + rv = mFileTransport->OpenInputStream(aResult); if(NS_FAILED(rv)) mFileTransport = nsnull; @@ -373,10 +354,7 @@ nsDiskCacheRecordTransport::OpenInputStream(PRUint32 transferOffset, } NS_IMETHODIMP -nsDiskCacheRecordTransport::OpenOutputStream(PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIOutputStream* *aResult) +nsDiskCacheRecordChannel::OpenOutputStream(nsIOutputStream* *aResult) { nsresult rv; NS_ENSURE_ARG(aResult); @@ -389,19 +367,14 @@ nsDiskCacheRecordTransport::OpenOutputStream(PRUint32 transferOffset, NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if(NS_FAILED(rv)) return rv; - rv = fts->CreateTransport(mSpec, - PR_WRONLY | PR_CREATE_FILE, - PR_IRUSR | PR_IWUSR, + rv = fts->CreateTransport(mSpec, PR_WRONLY | PR_CREATE_FILE, PR_IRUSR | PR_IWUSR, getter_AddRefs(mFileTransport)); if(NS_FAILED(rv)) return rv; // we don't need to worry about notification callbacks - rv = mFileTransport->OpenOutputStream(transferOffset, - transferCount, - transferFlags, - getter_AddRefs(outputStream)); + rv = mFileTransport->OpenOutputStream(getter_AddRefs(outputStream)); if(NS_FAILED(rv)) { mFileTransport = nsnull; return rv; @@ -411,12 +384,8 @@ nsDiskCacheRecordTransport::OpenOutputStream(PRUint32 transferOffset, } NS_IMETHODIMP -nsDiskCacheRecordTransport::AsyncRead(nsIStreamListener *aListener, - nsISupports *aContext, - PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIRequest **_retval) +nsDiskCacheRecordChannel::AsyncRead(nsIStreamListener *aListener, + nsISupports *aContext) { nsresult rv; @@ -426,8 +395,6 @@ nsDiskCacheRecordTransport::AsyncRead(nsIStreamListener *aListener, mRealListener = aListener; nsCOMPtr tempListener = this; -// XXX Only channels are added to load groups -#if 0 if (mLoadGroup) { nsCOMPtr factory; // @@ -440,48 +407,36 @@ nsDiskCacheRecordTransport::AsyncRead(nsIStreamListener *aListener, if (NS_SUCCEEDED(rv)) { mRealListener = newListener; NS_RELEASE(newListener); + } } - } - rv = mLoadGroup->AddRequest(this, nsnull); - if (NS_FAILED(rv)) return rv; + rv = mLoadGroup->AddChannel(this, nsnull); + if (NS_FAILED(rv)) return rv; } -#endif NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = fts->CreateTransport(mSpec, - PR_RDONLY, - PR_IRUSR | PR_IWUSR, + rv = fts->CreateTransport(mSpec, PR_RDONLY, PR_IRUSR | PR_IWUSR, getter_AddRefs(mFileTransport)); if (NS_FAILED(rv)) return rv; // no callbacks - rv = mFileTransport->AsyncRead(tempListener, aContext, - transferOffset, - transferCount, - transferFlags, - getter_AddRefs(mCurrentReadRequest)); + rv = mFileTransport->AsyncRead(tempListener, aContext); if (NS_FAILED(rv)) { // release the transport so that we don't think we're in progress mFileTransport = nsnull; } - - NS_ADDREF(*_retval=this); return rv; } NS_IMETHODIMP -nsDiskCacheRecordTransport::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt, - PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIRequest **_retval) +nsDiskCacheRecordChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) + { /* if(!mFileTransport) @@ -496,66 +451,279 @@ nsDiskCacheRecordTransport::AsyncWrite(nsIStreamProvider *provider, // I can't do this since the write is not monitored, and I won't be // able to updata the storage. - NS_NOTREACHED("nsDiskCacheRecordTransport::AsyncWrite"); + NS_NOTREACHED("nsDiskCacheRecordChannel::AsyncWrite"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -nsDiskCacheRecordTransport::GetSecurityInfo(nsISupports * *aSecurityInfo) +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) { - *aSecurityInfo = nsnull; + *aLoadAttributes = mLoadAttributes; return NS_OK; } NS_IMETHODIMP -nsDiskCacheRecordTransport::GetProgressEventSink(nsIProgressEventSink **aResult) +nsDiskCacheRecordChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) { + mLoadAttributes = aLoadAttributes; + return NS_OK; +} + +#define DUMMY_TYPE "application/x-unknown-content-type" + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetContentType(char * *aContentType) +{ +// Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsDiskCacheRecordChannel::GetContentType"); + return NS_ERROR_NOT_IMPLEMENTED; +// This was the pre nsIFile stuff. Not sure if I have to implement this routines since +// the memory cache doesn't +#if 0 + nsresult rv; + PRBool isDirectory; + if ( NS_SUCCEEDED(mSpec->IsDirectory(&isDirectory)) && isDirectory) { + *aContentType = nsCRT::strdup("application/http-index-format"); + return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + } + else { + // I wish I can make this simplier + + + char* urlStr; + mRecord->mFile->GetURLString(&urlStr); + + // file: URLs (currently) have no additional structure beyond that provided by standard + // URLs, so there is no "outer" given to CreateInstance + + nsCOMPtr url; + rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull, + NS_GET_IID(nsIURI), + //(void**)&url); + getter_AddRefs(url)); + if (NS_FAILED(rv)) return rv; + + rv = url->SetSpec((char*)urlStr); + if (NS_FAILED(rv)) + return rv; + nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + + rv = MIMEService->GetTypeFromURI(url, aContentType); + if (NS_SUCCEEDED(rv)) return rv; + + } + + *aContentType = nsCRT::strdup(DUMMY_TYPE); + if (!*aContentType) { + return NS_ERROR_OUT_OF_MEMORY; + } else { + return NS_OK; + } +#endif +} + +NS_IMETHODIMP nsDiskCacheRecordChannel::SetContentType(const char * aContentType) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::SetContentType"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetContentLength(PRInt32 *aContentLength) +{ + nsresult rv; + PRUint32 length; + + PRInt64 fileSize; + rv = mRecord->mFile->GetFileSize( &fileSize); + LL_L2UI( length, fileSize ); + + + if (NS_SUCCEEDED(rv)) { + *aContentLength = (PRInt32)length; + } else { + *aContentLength = -1; + } + return rv; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetContentLength(PRInt32 aContentLength) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::SetContentLength"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + nsresult rv = NS_ERROR_FAILURE; + if ( mFileTransport ) + rv = mFileTransport->GetTransferOffset( aTransferOffset ); + return rv; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + nsresult rv = NS_OK; + if ( mFileTransport ) + rv = mFileTransport->SetTransferOffset( aTransferOffset ); + return rv; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsDiskCacheRecordChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetLocalFile(nsIFile* *file) +{ + *file = mSpec; + NS_ADDREF(*file); + return NS_OK; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsDiskCacheRecordTransport::SetProgressEventSink(nsIProgressEventSink *aProgress) +nsDiskCacheRecordChannel::GetOwner(nsISupports* *aOwner) { + *aOwner = mOwner.get(); + NS_IF_ADDREF(*aOwner); + return NS_OK; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetOwner(nsISupports* aOwner) +{ + mOwner = aOwner; + return NS_OK; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_ASSERTION(0, "nsDiskCacheRecordChannel method unexpectedly called"); + return NS_OK; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_ASSERTION(0, "nsDiskCacheRecordChannel method unexpectedly called"); + return NS_OK; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsDiskCacheRecordChannel::GetNotificationCallbacks"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsDiskCacheRecordChannel::SetNotificationCallbacks"); return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +{ + *aSecurityInfo = nsnull; + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // nsIStreamListener methods: //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsDiskCacheRecordTransport::OnStartRequest(nsIRequest *request, nsISupports* context) +nsDiskCacheRecordChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) { NS_ASSERTION(mRealListener, "No listener..."); return mRealListener->OnStartRequest(this, context); } NS_IMETHODIMP -nsDiskCacheRecordTransport::OnStopRequest(nsIRequest *request, nsISupports* context, +nsDiskCacheRecordChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; rv = mRealListener->OnStopRequest(this, context, aStatus, aStatusArg); -// XXX Only channels are added to load groups -#if 0 if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } -#endif // Release the reference to the consumer stream listener... - mRealListener = 0; - mFileTransport = 0; - mCurrentReadRequest = 0; + mRealListener = null_nsCOMPtr(); + mFileTransport = null_nsCOMPtr(); return rv; } NS_IMETHODIMP -nsDiskCacheRecordTransport::OnDataAvailable(nsIRequest *request, nsISupports* context, +nsDiskCacheRecordChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -569,44 +737,9 @@ nsDiskCacheRecordTransport::OnDataAvailable(nsIRequest *request, nsISupports* co // insure that the transport will go away even if it is blocked waiting // for the consumer to empty the pipe... // - if (NS_FAILED(rv) && mCurrentReadRequest) { - mCurrentReadRequest->Cancel(rv); + if (NS_FAILED(rv) && mFileTransport) { + mFileTransport->Cancel(rv); } return rv; } -// XXX No reason to implement nsIFileChannel -#if 0 -/* void init (in nsIFile file, in long ioFlags, in long perm); */ -NS_IMETHODIMP nsDiskCacheRecordTransport::Init(nsIFile *file, PRInt32 ioFlags, PRInt32 perm) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute nsIFile file; */ -NS_IMETHODIMP nsDiskCacheRecordTransport::GetFile(nsIFile * *result) -{ - NS_ADDREF(*result = mSpec); - return NS_OK; -} - -/* attribute long ioFlags; */ -NS_IMETHODIMP nsDiskCacheRecordTransport::GetIoFlags(PRInt32 *aIoFlags) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsDiskCacheRecordTransport::SetIoFlags(PRInt32 aIoFlags) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* attribute long permissions; */ -NS_IMETHODIMP nsDiskCacheRecordTransport::GetPermissions(PRInt32 *aPermissions) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsDiskCacheRecordTransport::SetPermissions(PRInt32 aPermissions) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -#endif diff --git a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h index 7d49f01661f..c2250402467 100644 --- a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h +++ b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h @@ -24,49 +24,55 @@ #ifndef _ns_DiskCacheRecordChannel_h_ #define _ns_DiskCacheRecordChannel_h_ -#include "nsITransport.h" +#include "nsIChannel.h" #include "nsCOMPtr.h" #include "nsDiskCacheRecord.h" #include "nsIStreamListener.h" #include "nsIFile.h" - /* - * This class is plagiarized from nsMemCacheTransport + * This class is plagiarized from nsMemCacheChannel */ -class nsDiskCacheRecordTransport : public nsITransport, - public nsITransportRequest, - public nsIStreamListener +class nsDiskCacheRecordChannel : public nsIChannel, + public nsIStreamListener { -public: + public: - nsDiskCacheRecordTransport(nsDiskCacheRecord *aRecord, nsILoadGroup *aLoadGroup); - virtual ~nsDiskCacheRecordTransport(); + nsDiskCacheRecordChannel(nsDiskCacheRecord *aRecord, nsILoadGroup *aLoadGroup); + virtual ~nsDiskCacheRecordChannel() ; + // Declare nsISupports methods NS_DECL_ISUPPORTS + + // Declare nsIRequest methods NS_DECL_NSIREQUEST - NS_DECL_NSITRANSPORTREQUEST - NS_DECL_NSITRANSPORT + + // Declare nsIChannel methods + NS_DECL_NSICHANNEL + + // Declare nsIStreamObserver methods NS_DECL_NSISTREAMOBSERVER + + // Declare nsIStreamListener methods NS_DECL_NSISTREAMLISTENER - nsresult Init(void); + nsresult Init(void) ; -private: + private: - nsresult NotifyStorageInUse(PRInt32 aBytesUsed); + nsresult NotifyStorageInUse(PRInt32 aBytesUsed) ; - nsDiskCacheRecord* mRecord; - nsCOMPtr mLoadGroup; + nsDiskCacheRecord* mRecord ; + nsCOMPtr mLoadGroup ; nsLoadFlags mLoadAttributes; - nsCOMPtr mFileTransport; - nsCOMPtr mCurrentReadRequest; - nsCOMPtr< nsIFile > mSpec; + nsCOMPtr mOwner ; + nsCOMPtr mFileTransport ; + nsCOMPtr< nsIFile > mSpec ; nsCOMPtr mRealListener; nsresult mStatus; - friend class WriteStreamWrapper; -}; + friend class WriteStreamWrapper ; +} ; #endif // _ns_DiskCacheRecordChannel_h_ diff --git a/mozilla/netwerk/cache/filecache/nsNetDiskCache.h b/mozilla/netwerk/cache/filecache/nsNetDiskCache.h index b50fc26c922..65f3e1b373d 100644 --- a/mozilla/netwerk/cache/filecache/nsNetDiskCache.h +++ b/mozilla/netwerk/cache/filecache/nsNetDiskCache.h @@ -58,21 +58,21 @@ class nsNetDiskCache : public nsINetDataDiskCache, public nsIObserver, public ns NS_DECL_NSINETDATADISKCACHE NS_DECL_NSIOBSERVER - NS_IMETHOD Init(void); + NS_IMETHOD Init(void) ; nsNetDiskCache() ; - virtual ~nsNetDiskCache(); + virtual ~nsNetDiskCache() ; protected: NS_IMETHOD ShutdownDB(); - NS_IMETHOD InitDB(void); - NS_IMETHOD CreateDir(nsIFile* dir_spec); - NS_IMETHOD GetSizeEntry(void); - NS_IMETHOD SetSizeEntry(void); - NS_IMETHOD SetSizeEntryExplicit(PRUint32 numEntries, PRUint32 storageInUse); + NS_IMETHOD InitDB(void) ; + NS_IMETHOD CreateDir(nsIFile* dir_spec) ; + NS_IMETHOD GetSizeEntry(void) ; + NS_IMETHOD SetSizeEntry(void) ; + NS_IMETHOD SetSizeEntryExplicit(PRUint32 numEntries, PRUint32 storageInUse) ; - NS_IMETHOD RenameCacheSubDirs(void); - NS_IMETHOD DBRecovery(void); + NS_IMETHOD RenameCacheSubDirs(void) ; + NS_IMETHOD DBRecovery(void) ; private: NS_IMETHODIMP InitCacheFolder(); @@ -80,22 +80,22 @@ class nsNetDiskCache : public nsINetDataDiskCache, public nsIObserver, public ns PRBool fixCacheVersion (const char *cache_dir, unsigned version); void removeAllFiles (const char *dir, const char *tagFile = NULL); - PRBool mEnabled; - PRUint32 mNumEntries; - nsCOMPtr mpNextCache; - nsCOMPtr mDiskCacheFolder; - nsCOMPtr mDBFile; + PRBool mEnabled ; + PRUint32 mNumEntries ; + nsCOMPtr mpNextCache ; + nsCOMPtr mDiskCacheFolder ; + nsCOMPtr mDBFile ; - PRUint32 mMaxEntries; - PRUint32 mStorageInUse; - nsIDBAccessor* mDB; + PRUint32 mMaxEntries ; + PRUint32 mStorageInUse ; + nsIDBAccessor* mDB ; // this is used to indicate a db corruption - PRBool mDBCorrupted; + PRBool mDBCorrupted ; - friend class nsDiskCacheRecord; - friend class nsDiskCacheRecordTransport; - friend class nsDBEnumerator; -}; + friend class nsDiskCacheRecord ; + friend class nsDiskCacheRecordChannel ; + friend class nsDBEnumerator ; +} ; #endif /* __gen_nsNetDiskCache_h__ */ diff --git a/mozilla/netwerk/cache/memcache/nsMemCache.h b/mozilla/netwerk/cache/memcache/nsMemCache.h index 592deaf47b2..1c847eea71d 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCache.h +++ b/mozilla/netwerk/cache/memcache/nsMemCache.h @@ -77,7 +77,7 @@ protected: NS_METHOD Delete(nsMemCacheRecord* aRecord); friend class nsMemCacheRecord; - friend class nsMemCacheTransport; + friend class nsMemCacheChannel; }; #endif // _nsMemCache_h_ diff --git a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp index 281de9d2ea1..a900bfc1fab 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp +++ b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp @@ -33,13 +33,10 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); -NS_IMPL_THREADSAFE_ISUPPORTS3(nsMemCacheTransport, - nsITransport, - nsITransportRequest, - nsIRequest) +NS_IMPL_THREADSAFE_ISUPPORTS1(nsMemCacheChannel, nsIChannel) void -nsMemCacheTransport::NotifyStorageInUse(PRInt32 aBytesUsed) +nsMemCacheChannel::NotifyStorageInUse(PRInt32 aBytesUsed) { mRecord->mCache->mOccupancy += aBytesUsed; } @@ -53,9 +50,9 @@ class AsyncReadStreamAdaptor : public nsIInputStream, public nsIStreamListener { public: - AsyncReadStreamAdaptor(nsMemCacheTransport* aChannel, nsIInputStream *aSyncStream): + AsyncReadStreamAdaptor(nsMemCacheChannel* aChannel, nsIInputStream *aSyncStream): mSyncStream(aSyncStream), mDataAvailCursor(0), - mRemaining((PRUint32)-1), mAvailable(0), mChannel(aChannel), mAbortStatus(NS_OK), mSuspended(PR_FALSE) + mRemaining(-1), mAvailable(0), mChannel(aChannel), mAbortStatus(NS_OK), mSuspended(PR_FALSE) { NS_INIT_REFCNT(); NS_ADDREF(mChannel); @@ -78,10 +75,8 @@ public: Cancel(nsresult status) { if (NS_SUCCEEDED(mAbortStatus)) { mAbortStatus = status; - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; return mEventQueueStreamListener ? - mEventQueueStreamListener->OnStopRequest(mChannel->mCurrentReadRequest, mContext, status, nsnull): + mEventQueueStreamListener->OnStopRequest(mChannel, mContext, status, nsnull): status; } else { // Cancel has already been called... Do not fire another OnStopRequest! @@ -109,14 +104,11 @@ public: // event to the downstream listener and causes another OnDataAvailable() // event to be enqueued. NS_IMETHOD - OnDataAvailable(nsIRequest* request, nsISupports *aContext, + OnDataAvailable(nsIChannel *channel, nsISupports *aContext, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv; - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; - - rv = mDownstreamListener->OnDataAvailable(mChannel->mCurrentReadRequest, aContext, inStr, sourceOffset, count); + rv = mDownstreamListener->OnDataAvailable(mChannel, aContext, inStr, sourceOffset, count); if (NS_FAILED(rv)) { Cancel(rv); return rv; @@ -132,15 +124,13 @@ public: } NS_IMETHOD - OnStartRequest(nsIRequest* request, nsISupports *aContext) { + OnStartRequest(nsIChannel *channel, nsISupports *aContext) { nsresult rv = NS_OK; NS_ASSERTION(mDownstreamListener, "no downstream listener"); if (mDownstreamListener) { - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; - rv = mDownstreamListener->OnStartRequest(mChannel->mCurrentReadRequest, aContext); + rv = mDownstreamListener->OnStartRequest(mChannel, aContext); } if (NS_FAILED(rv)) @@ -149,7 +139,7 @@ public: } NS_IMETHOD - OnStopRequest(nsIRequest* request, nsISupports *aContext, + OnStopRequest(nsIChannel *channel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -157,9 +147,7 @@ public: NS_ASSERTION(mDownstreamListener, "no downstream listener"); if (mDownstreamListener) { - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; - rv = mDownstreamListener->OnStopRequest(mChannel->mCurrentReadRequest, aContext, aStatus, aStatusArg); + rv = mDownstreamListener->OnStopRequest(mChannel, aContext, aStatus, aStatusArg); mDownstreamListener = 0; } // Tricky: causes this instance to be free'ed because mEventQueueStreamListener @@ -232,9 +220,7 @@ public: } nsresult - AsyncRead(nsIStreamListener* aListener, nsISupports* aContext, - PRUint32 transferOffset, PRUint32 transferCount, - PRUint32 flags, nsIRequest **_retval) { + AsyncRead(nsIStreamListener* aListener, nsISupports* aContext) { nsresult rv; nsIEventQueue *eventQ; @@ -256,10 +242,7 @@ public: NS_RELEASE(eventQ); if (NS_FAILED(rv)) return rv; - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; - - rv = mEventQueueStreamListener->OnStartRequest(mChannel->mCurrentReadRequest, aContext); + rv = mEventQueueStreamListener->OnStartRequest(mChannel, aContext); if (NS_FAILED(rv)) return rv; return NextListenerEvent(); @@ -269,12 +252,8 @@ protected: nsresult Fail(void) { - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; - mAbortStatus = NS_BINDING_ABORTED; - return mEventQueueStreamListener->OnStopRequest(mChannel->mCurrentReadRequest, mContext, - NS_BINDING_FAILED, nsnull); + return mEventQueueStreamListener->OnStopRequest(mChannel, mContext, NS_BINDING_FAILED, nsnull); } // If more data remains in the source stream that the downstream consumer @@ -288,19 +267,16 @@ protected: available -= mAvailable; available = PR_MIN(available, mRemaining); - if (!mChannel->mCurrentReadRequest) - return NS_ERROR_FAILURE; - if (available) { PRUint32 size = PR_MIN(available, MEM_CACHE_SEGMENT_SIZE); - rv = mEventQueueStreamListener->OnDataAvailable(mChannel->mCurrentReadRequest, mContext, this, + rv = mEventQueueStreamListener->OnDataAvailable(mChannel, mContext, this, mDataAvailCursor, size); mDataAvailCursor += size; mRemaining -= size; mAvailable += size; return rv; } else { - rv = mEventQueueStreamListener->OnStopRequest(mChannel->mCurrentReadRequest, mContext, NS_OK, nsnull); + rv = mEventQueueStreamListener->OnStopRequest(mChannel, mContext, NS_OK, nsnull); AsyncReadStreamAdaptor* thisAlias = this; NS_RELEASE(thisAlias); return rv; @@ -317,7 +293,7 @@ private: PRUint32 mRemaining; // Size of AsyncRead request less bytes for // consumer OnDataAvailable's that were fired PRUint32 mAvailable; // Number of bytes for which OnDataAvailable fired - nsMemCacheTransport* mChannel; // Associated memory cache channel, strong link + nsMemCacheChannel* mChannel; // Associated memory cache channel, strong link // but can not use nsCOMPtr nsresult mAbortStatus; // Abort() has been called PRBool mSuspended; // Suspend() has been called @@ -330,7 +306,7 @@ NS_IMPL_ISUPPORTS3(AsyncReadStreamAdaptor, nsIInputStream, // overall occupancy as new data flows into the cache entry. class MemCacheWriteStreamWrapper : public nsIOutputStream { public: - MemCacheWriteStreamWrapper(nsMemCacheTransport* aChannel, nsIOutputStream *aBaseStream): + MemCacheWriteStreamWrapper(nsMemCacheChannel* aChannel, nsIOutputStream *aBaseStream): mBaseStream(aBaseStream), mChannel(aChannel) { NS_INIT_REFCNT(); @@ -340,7 +316,7 @@ public: virtual ~MemCacheWriteStreamWrapper() { NS_RELEASE(mChannel); }; static nsresult - Create(nsMemCacheTransport* aChannel, nsIOutputStream *aBaseStream, nsIOutputStream* *aWrapper) { + Create(nsMemCacheChannel* aChannel, nsIOutputStream *aBaseStream, nsIOutputStream* *aWrapper) { MemCacheWriteStreamWrapper *wrapper = new MemCacheWriteStreamWrapper(aChannel, aBaseStream); if (!wrapper) return NS_ERROR_OUT_OF_MEMORY; @@ -403,32 +379,33 @@ public: private: nsCOMPtr mBaseStream; - nsMemCacheTransport* mChannel; + nsMemCacheChannel* mChannel; }; NS_IMPL_THREADSAFE_ISUPPORTS1(MemCacheWriteStreamWrapper, nsIOutputStream) -nsMemCacheTransport::nsMemCacheTransport(nsMemCacheRecord *aRecord, nsILoadGroup *aLoadGroup) - : mRecord(aRecord), mStartOffset(0), mStatus(NS_OK) +nsMemCacheChannel::nsMemCacheChannel(nsMemCacheRecord *aRecord, nsILoadGroup *aLoadGroup) + : mRecord(aRecord), mStartOffset(0), mStatus(NS_OK), + mLoadAttributes(nsIChannel::LOAD_NORMAL) { NS_INIT_REFCNT(); - mRecord->mNumTransports++; + mRecord->mNumChannels++; } -nsMemCacheTransport::~nsMemCacheTransport() +nsMemCacheChannel::~nsMemCacheChannel() { - mRecord->mNumTransports--; + mRecord->mNumChannels--; } NS_IMETHODIMP -nsMemCacheTransport::GetName(PRUnichar* *result) +nsMemCacheChannel::GetName(PRUnichar* *result) { - NS_NOTREACHED("nsMemCacheTransport::GetName"); + NS_NOTREACHED("nsMemCacheChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsMemCacheTransport::IsPending(PRBool* aIsPending) +nsMemCacheChannel::IsPending(PRBool* aIsPending) { *aIsPending = PR_FALSE; if (!mAsyncReadStream) @@ -437,14 +414,14 @@ nsMemCacheTransport::IsPending(PRBool* aIsPending) } NS_IMETHODIMP -nsMemCacheTransport::GetStatus(nsresult *status) +nsMemCacheChannel::GetStatus(nsresult *status) { *status = mStatus; return NS_OK; } NS_IMETHODIMP -nsMemCacheTransport::Cancel(nsresult status) +nsMemCacheChannel::Cancel(nsresult status) { mStatus = status; if (!mAsyncReadStream) @@ -453,7 +430,7 @@ nsMemCacheTransport::Cancel(nsresult status) } NS_IMETHODIMP -nsMemCacheTransport::Suspend(void) +nsMemCacheChannel::Suspend(void) { if (!mAsyncReadStream) return NS_ERROR_FAILURE; @@ -461,60 +438,54 @@ nsMemCacheTransport::Suspend(void) } NS_IMETHODIMP -nsMemCacheTransport::Resume(void) +nsMemCacheChannel::Resume(void) { if (!mAsyncReadStream) return NS_ERROR_FAILURE; return mAsyncReadStream->Resume(); } -#if 0 NS_IMETHODIMP -nsMemCacheTransport::GetOriginalURI(nsIURI* *aURI) +nsMemCacheChannel::GetOriginalURI(nsIURI* *aURI) { // Not required - NS_NOTREACHED("nsMemCacheTransport::GetOriginalURI"); + NS_NOTREACHED("nsMemCacheChannel::GetOriginalURI"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsMemCacheTransport::SetOriginalURI(nsIURI* aURI) +nsMemCacheChannel::SetOriginalURI(nsIURI* aURI) { // Not required - NS_NOTREACHED("nsMemCacheTransport::SetOriginalURI"); + NS_NOTREACHED("nsMemCacheChannel::SetOriginalURI"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsMemCacheTransport::GetURI(nsIURI* *aURI) +nsMemCacheChannel::GetURI(nsIURI* *aURI) { // Not required to be implemented, since it is implemented by cache manager - NS_NOTREACHED("nsMemCacheTransport::GetURI"); + NS_NOTREACHED("nsMemCacheChannel::GetURI"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsMemCacheTransport::SetURI(nsIURI* aURI) +nsMemCacheChannel::SetURI(nsIURI* aURI) { // Not required to be implemented, since it is implemented by cache manager - NS_NOTREACHED("nsMemCacheTransport::SetURI"); + NS_NOTREACHED("nsMemCacheChannel::SetURI"); return NS_ERROR_NOT_IMPLEMENTED; } -#endif NS_IMETHODIMP -nsMemCacheTransport::OpenInputStream(PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIInputStream* *aResult) - +nsMemCacheChannel::OpenInputStream(nsIInputStream* *aResult) { nsresult rv; NS_ENSURE_ARG(aResult); if (mInputStream) return NS_ERROR_NOT_AVAILABLE; - rv = mRecord->mStorageStream->NewInputStream(transferOffset, getter_AddRefs(mInputStream)); + rv = mRecord->mStorageStream->NewInputStream(mStartOffset, getter_AddRefs(mInputStream)); if (NS_FAILED(rv)) return rv; *aResult = mInputStream; NS_ADDREF(*aResult); @@ -522,10 +493,7 @@ nsMemCacheTransport::OpenInputStream(PRUint32 transferOffset, } NS_IMETHODIMP -nsMemCacheTransport::OpenOutputStream(PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIOutputStream* *aResult) +nsMemCacheChannel::OpenOutputStream(nsIOutputStream* *aResult) { nsresult rv; NS_ENSURE_ARG(aResult); @@ -534,24 +502,19 @@ nsMemCacheTransport::OpenOutputStream(PRUint32 transferOffset, PRUint32 oldLength; mRecord->mStorageStream->GetLength(&oldLength); - rv = mRecord->mStorageStream->GetOutputStream(transferOffset, getter_AddRefs(outputStream)); + rv = mRecord->mStorageStream->GetOutputStream(mStartOffset, getter_AddRefs(outputStream)); if (NS_FAILED(rv)) return rv; - if (transferOffset < oldLength) - NotifyStorageInUse(transferOffset - oldLength); + if (mStartOffset < oldLength) + NotifyStorageInUse(mStartOffset - oldLength); return MemCacheWriteStreamWrapper::Create(this, outputStream, aResult); } NS_IMETHODIMP -nsMemCacheTransport::AsyncRead(nsIStreamListener *aListener, - nsISupports *aContext, - PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIRequest **_retval) +nsMemCacheChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext) { nsCOMPtr inputStream; - nsresult rv = OpenInputStream(0, 0, 0, getter_AddRefs(inputStream)); + nsresult rv = OpenInputStream(getter_AddRefs(inputStream)); if (NS_FAILED(rv)) return rv; AsyncReadStreamAdaptor *asyncReadStreamAdaptor; @@ -561,56 +524,197 @@ nsMemCacheTransport::AsyncRead(nsIStreamListener *aListener, NS_ADDREF(asyncReadStreamAdaptor); mAsyncReadStream = asyncReadStreamAdaptor; - rv = asyncReadStreamAdaptor->AsyncRead(aListener, aContext, - transferOffset, - transferCount, - transferFlags, - getter_AddRefs(mCurrentReadRequest)); + rv = asyncReadStreamAdaptor->AsyncRead(aListener, aContext); if (NS_FAILED(rv)) { mAsyncReadStream = nsnull; NS_RELEASE(asyncReadStreamAdaptor); } - - NS_ADDREF(*_retval=this); return rv; } NS_IMETHODIMP -nsMemCacheTransport::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt, - PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIRequest **_retval) +nsMemCacheChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { // Not required to be implemented - NS_NOTREACHED("nsMemCacheTransport::AsyncWrite"); + NS_NOTREACHED("nsMemCacheChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mStartOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + mStartOffset = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsMemCacheChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsMemCacheChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsMemCacheChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsMemCacheChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsMemCacheChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsMemCacheChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetContentLength(PRInt32 aContentLength) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) +{ + *aLoadAttributes = mLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) +{ + mLoadAttributes = aLoadAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetContentType(char* *aContentType) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsMemCacheChannel::GetContentType"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetContentType(const char *aContentType) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsMemCacheChannel::SetContentType"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetContentLength(PRInt32 *aContentLength) +{ + PRUint32 cl = 0; + mRecord->GetStoredContentLength(&cl); + + *aContentLength = (PRInt32) cl; + + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetOwner(nsISupports* *aOwner) +{ + *aOwner = mOwner.get(); + NS_IF_ADDREF(*aOwner); + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetOwner(nsISupports* aOwner) +{ + // Not required to be implemented, since it is implemented by cache manager + mOwner = aOwner; + return NS_OK; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsMemCacheChannel::GetLoadGroup"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsMemCacheChannel::SetLoadGroup"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsMemCacheChannel::GetNotificationCallbacks"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) +{ + // Not required to be implemented, since it is implemented by cache manager + NS_NOTREACHED("nsMemCacheChannel::SetNotificationCallbacks"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsMemCacheTransport::GetSecurityInfo(nsISupports * *aSecurityInfo) +nsMemCacheChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { *aSecurityInfo = nsnull; return NS_OK; } - -NS_IMETHODIMP -nsMemCacheTransport::GetProgressEventSink(nsIProgressEventSink **aResult) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsMemCacheTransport::SetProgressEventSink(nsIProgressEventSink *aProgress) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsMemCacheTransport::GetTransport(nsITransport **result) -{ - NS_ENSURE_ARG_POINTER(result); - NS_ADDREF(*result = this); - return NS_OK; -} diff --git a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h index c44bda32828..a2c608ddbc5 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h +++ b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h @@ -23,36 +23,41 @@ #define _nsMemCacheChannel_h_ #include "nsMemCacheRecord.h" -#include "nsITransport.h" -#include "nsIRequest.h" +#include "nsIChannel.h" #include "nsIInputStream.h" #include "nsCOMPtr.h" class AsyncReadStreamAdaptor; -class nsMemCacheTransport : public nsITransport, public nsITransportRequest +class nsMemCacheChannel : public nsIChannel { public: // Constructors and Destructor - nsMemCacheTransport(nsMemCacheRecord *aRecord, nsILoadGroup *aLoadGroup); - virtual ~nsMemCacheTransport(); + nsMemCacheChannel(nsMemCacheRecord *aRecord, nsILoadGroup *aLoadGroup); + virtual ~nsMemCacheChannel(); + // Declare nsISupports methods NS_DECL_ISUPPORTS + + // Declare nsIRequest methods NS_DECL_NSIREQUEST - NS_DECL_NSITRANSPORTREQUEST - NS_DECL_NSITRANSPORT + + // Declare nsIChannel methods + NS_DECL_NSICHANNEL protected: void NotifyStorageInUse(PRInt32 aBytesUsed); nsCOMPtr mRecord; nsCOMPtr mInputStream; - nsCOMPtr mCurrentReadRequest; + nsCOMPtr mOwner; AsyncReadStreamAdaptor* mAsyncReadStream; // non-owning pointer PRUint32 mStartOffset; nsresult mStatus; + nsLoadFlags mLoadAttributes; + friend class MemCacheWriteStreamWrapper; friend class AsyncReadStreamAdaptor; }; diff --git a/mozilla/netwerk/cache/memcache/nsMemCacheRecord.cpp b/mozilla/netwerk/cache/memcache/nsMemCacheRecord.cpp index 9057468bc57..72078cc1094 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCacheRecord.cpp +++ b/mozilla/netwerk/cache/memcache/nsMemCacheRecord.cpp @@ -28,7 +28,7 @@ static NS_DEFINE_IID(kINetDataCacheRecord, NS_INETDATACACHERECORD_IID); nsMemCacheRecord::nsMemCacheRecord() - : mKey(0), mKeyLength(0), mMetaData(0), mMetaDataLength(0), mNumTransports(0) + : mKey(0), mKeyLength(0), mMetaData(0), mMetaDataLength(0), mNumChannels(0) { NS_INIT_REFCNT(); } @@ -156,7 +156,7 @@ nsMemCacheRecord::SetSecurityInfo (nsISupports * o_SecurityInfo) NS_IMETHODIMP nsMemCacheRecord::Delete(void) { - if (mNumTransports) + if (mNumChannels) return NS_ERROR_NOT_AVAILABLE; return mCache->Delete(this); @@ -169,16 +169,16 @@ nsMemCacheRecord::GetFile(nsIFile* *aFilename) } NS_IMETHODIMP -nsMemCacheRecord::NewTransport(nsILoadGroup *aLoadGroup, nsITransport* *aResult) +nsMemCacheRecord::NewChannel(nsILoadGroup *aLoadGroup, nsIChannel* *aResult) { NS_ENSURE_ARG(aResult); - nsMemCacheTransport* transport = new nsMemCacheTransport(this, aLoadGroup); - if (!transport) + nsMemCacheChannel* channel = new nsMemCacheChannel(this, aLoadGroup); + if (!channel) return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(transport); - *aResult = NS_STATIC_CAST(nsITransport*, transport); + NS_ADDREF(channel); + *aResult = NS_STATIC_CAST(nsIChannel*, channel); return NS_OK; } diff --git a/mozilla/netwerk/cache/memcache/nsMemCacheRecord.h b/mozilla/netwerk/cache/memcache/nsMemCacheRecord.h index 89a19b66a2e..61ee8862a0d 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCacheRecord.h +++ b/mozilla/netwerk/cache/memcache/nsMemCacheRecord.h @@ -56,10 +56,10 @@ protected: // that this record inhabits nsCOMPtr mStorageStream; - PRUint32 mNumTransports; // Count un-Release'ed nsITransports + PRUint32 mNumChannels; // Count un-Release'ed nsIChannels friend class nsMemCache; - friend class nsMemCacheTransport; + friend class nsMemCacheChannel; private: nsCOMPtr mSecurityInfo; diff --git a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp index 8b060785433..d1450f419c1 100644 --- a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp +++ b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp @@ -30,33 +30,35 @@ #include "nsIStreamListener.h" #include "nsMemory.h" -nsCacheEntryTransport::nsCacheEntryTransport( +nsCacheEntryChannel::nsCacheEntryChannel( nsCachedNetData* aCacheEntry, - nsITransport* aTransport, + nsIChannel* aChannel, nsILoadGroup* aLoadGroup): + nsChannelProxy(aChannel), mCacheEntry(aCacheEntry), - mLoadGroup(aLoadGroup), - mTransport(aTransport) + mLoadGroup(aLoadGroup) { - NS_ASSERTION(aCacheEntry->mTransportCount < 0xFF, "Overflowed transport counter"); - mCacheEntry->mTransportCount++; + NS_ASSERTION(aCacheEntry->mChannelCount < 0xFF, "Overflowed channel counter"); + mCacheEntry->mChannelCount++; NS_INIT_REFCNT(); } -nsCacheEntryTransport::~nsCacheEntryTransport() +nsCacheEntryChannel::~nsCacheEntryChannel() { - mCacheEntry->mTransportCount--; + mCacheEntry->mChannelCount--; } -NS_IMPL_THREADSAFE_ISUPPORTS1(nsCacheEntryTransport, - nsITransport) +NS_IMPL_THREADSAFE_ISUPPORTS3(nsCacheEntryChannel, + nsISupports, + nsIChannel, + nsIRequest) // A proxy for nsIOutputStream class CacheOutputStream : public nsIOutputStream { public: CacheOutputStream(nsIOutputStream *aOutputStream, - nsCachedNetData *aCacheEntry): + nsCachedNetData *aCacheEntry): mOutputStream(aOutputStream), mCacheEntry(aCacheEntry), mStartTime(PR_IntervalNow()) @@ -134,18 +136,37 @@ protected: NS_IMPL_THREADSAFE_ISUPPORTS1(CacheOutputStream, nsIOutputStream) NS_IMETHODIMP -nsCacheEntryTransport::OpenOutputStream(PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIOutputStream* *aOutputStream) +nsCacheEntryChannel::GetTransferOffset(PRUint32 *aStartPosition) +{ + return mChannel->GetTransferOffset(aStartPosition); +} + +NS_IMETHODIMP +nsCacheEntryChannel::SetTransferOffset(PRUint32 aStartPosition) +{ + mCacheEntry->mLogicalLength = aStartPosition; + return mChannel->SetTransferOffset(aStartPosition); +} + +NS_IMETHODIMP +nsCacheEntryChannel::GetTransferCount(PRInt32 *aReadCount) +{ + return mChannel->GetTransferCount(aReadCount); +} + +NS_IMETHODIMP +nsCacheEntryChannel::SetTransferCount(PRInt32 aReadCount) +{ + return mChannel->SetTransferCount(aReadCount); +} + +NS_IMETHODIMP +nsCacheEntryChannel::OpenOutputStream(nsIOutputStream* *aOutputStream) { nsresult rv; nsCOMPtr baseOutputStream; - rv = mTransport->OpenOutputStream(transferOffset, - transferCount, - transferFlags, - getter_AddRefs(baseOutputStream)); + rv = mChannel->OpenOutputStream(getter_AddRefs(baseOutputStream)); if (NS_FAILED(rv)) return rv; mCacheEntry->NoteAccess(); @@ -159,26 +180,15 @@ nsCacheEntryTransport::OpenOutputStream(PRUint32 transferOffset, } NS_IMETHODIMP -nsCacheEntryTransport::OpenInputStream(PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIInputStream* *aInputStream) +nsCacheEntryChannel::OpenInputStream(nsIInputStream* *aInputStream) { mCacheEntry->NoteAccess(); - return mTransport->OpenInputStream(transferOffset, - transferCount, - transferFlags, - aInputStream); + return mChannel->OpenInputStream(aInputStream); } NS_IMETHODIMP -nsCacheEntryTransport::AsyncRead(nsIStreamListener *aListener, - nsISupports *aContext, - PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIRequest **_retval) +nsCacheEntryChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext) { nsresult rv; @@ -186,59 +196,43 @@ nsCacheEntryTransport::AsyncRead(nsIStreamListener *aListener, mCacheEntry->NoteAccess(); - rv = mTransport->AsyncRead(aListener, - aContext, - transferOffset, - transferCount, - transferFlags, - _retval); + rv = mChannel->AsyncRead(aListener, aContext); return rv; } // No async writes allowed to the cache yet NS_IMETHODIMP -nsCacheEntryTransport::AsyncWrite(nsIStreamProvider *aProvider, - nsISupports *ctxt, - PRUint32 transferOffset, - PRUint32 transferCount, - PRUint32 transferFlags, - nsIRequest **_retval) +nsCacheEntryChannel::AsyncWrite(nsIStreamProvider *aProvider, + nsISupports *aContext) { - NS_NOTREACHED("nsCacheEntryTransport::AsyncWrite"); + NS_NOTREACHED("nsCacheEntryChannel::AsyncWrite"); return NS_ERROR_NOT_IMPLEMENTED; } -#if 0 -NS_IMETHODIMP -nsCacheEntryTransport::SetLoadGroup(nsILoadGroup * aLoadGroup) -{ - return mTransport->SetLoadGroup(aLoadGroup); -} - NS_IMETHODIMP -nsCacheEntryTransport::GetLoadGroup(nsILoadGroup* *aLoadGroup) +nsCacheEntryChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { *aLoadGroup = mLoadGroup; return NS_OK; } NS_IMETHODIMP -nsCacheEntryTransport::GetLoadAttributes(nsLoadFlags *aLoadAttributes) +nsCacheEntryChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) { - return mTransport->GetLoadAttributes(aLoadAttributes); + return mChannel->GetLoadAttributes(aLoadAttributes); } NS_IMETHODIMP -nsCacheEntryTransport::SetLoadAttributes(nsLoadFlags aLoadAttributes) +nsCacheEntryChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) { - return mTransport->SetLoadAttributes(aLoadAttributes); + return mChannel->SetLoadAttributes(aLoadAttributes); } static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); NS_IMETHODIMP -nsCacheEntryTransport::GetURI(nsIURI * *aURI) +nsCacheEntryChannel::GetURI(nsIURI * *aURI) { char* spec; nsresult rv; @@ -255,65 +249,9 @@ nsCacheEntryTransport::GetURI(nsIURI * *aURI) } NS_IMETHODIMP -nsCacheEntryTransport::SetURI(nsIURI * aOriginalURI) -{ - return mTransport->SetURI(aOriginalURI); -} - - -NS_IMETHODIMP -nsCacheEntryTransport::SetOriginalURI(nsIURI * aOriginalURI) -{ - return mTransport->SetOriginalURI(aOriginalURI); -} - -NS_IMETHODIMP -nsCacheEntryTransport::GetOriginalURI(nsIURI * *aURI) +nsCacheEntryChannel::GetOriginalURI(nsIURI * *aURI) { - // FIXME - should return original URI passed into NewTransport() ? - NS_NOTREACHED("nsCacheEntryTransport::GetOriginalURI"); + // FIXME - should return original URI passed into NewChannel() ? + NS_NOTREACHED("nsCacheEntryChannel::GetOriginalURI"); return NS_ERROR_NOT_IMPLEMENTED; } - -NS_IMETHODIMP -nsCacheEntryTransport::GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) -{ - return mTransport->GetNotificationCallbacks(aNotificationCallbacks); -} - -NS_IMETHODIMP -nsCacheEntryTransport::SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) -{ - return mTransport->SetNotificationCallbacks(aNotificationCallbacks); -} - -NS_IMETHODIMP -nsCacheEntryTransport::GetOwner(nsISupports * *aOwner) -{ - return mTransport->GetOwner(aOwner); -} - -NS_IMETHODIMP -nsCacheEntryTransport::SetOwner(nsISupports * aOwner) -{ - return mTransport->SetOwner(aOwner); -} -#endif - -NS_IMETHODIMP -nsCacheEntryTransport::GetSecurityInfo(nsISupports * *aSecurityInfo) -{ - return mTransport->GetSecurityInfo(aSecurityInfo); -} - -NS_IMETHODIMP -nsCacheEntryTransport::GetProgressEventSink(nsIProgressEventSink **aResult) -{ - return mTransport->GetProgressEventSink(aResult); -} - -NS_IMETHODIMP -nsCacheEntryTransport::SetProgressEventSink(nsIProgressEventSink *aProgress) -{ - return mTransport->SetProgressEventSink(aProgress); -} diff --git a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h index 58b68cd5e1b..9f38336c53e 100644 --- a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h +++ b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h @@ -26,31 +26,55 @@ #define _nsCacheEntryChannel_h_ #include "nsCOMPtr.h" -#include "nsITransport.h" +#include "nsIChannel.h" #include "nsCachedNetData.h" #include "nsILoadGroup.h" class nsIStreamListener; -// Override several nsITransport methods so that they interact with the cache manager -class nsCacheEntryTransport : public nsITransport { +// A proxy for an nsIChannel, useful when only a few nsIChannel +// methods must be overridden +class nsChannelProxy : public nsIChannel { + +public: + NS_FORWARD_NSICHANNEL(mChannel->) + NS_FORWARD_NSIREQUEST(mChannel->) + +protected: + nsChannelProxy(nsIChannel* aChannel):mChannel(aChannel) {}; + virtual ~nsChannelProxy() {}; + nsCOMPtr mChannel; +}; + +// Override several nsIChannel methods so that they interact with the cache manager +class nsCacheEntryChannel : public nsChannelProxy { public: NS_DECL_ISUPPORTS - NS_DECL_NSITRANSPORT + + NS_IMETHOD GetTransferOffset(PRUint32 *aStartPosition); + NS_IMETHOD SetTransferOffset(PRUint32 aStartPosition); + NS_IMETHOD GetTransferCount(PRInt32 *aReadCount); + NS_IMETHOD SetTransferCount(PRInt32 aReadCount); + NS_IMETHOD OpenOutputStream(nsIOutputStream* *aOutputStream); + NS_IMETHOD OpenInputStream(nsIInputStream* *aInputStream); + NS_IMETHOD AsyncRead(nsIStreamListener *aListener, nsISupports *aContext); + NS_IMETHOD AsyncWrite(nsIStreamProvider *aProvider, nsISupports *aContext); + NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes); + NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes); + NS_IMETHOD GetLoadGroup(nsILoadGroup* *aLoadGroup); + NS_IMETHOD GetURI(nsIURI * *aURI); + NS_IMETHOD GetOriginalURI(nsIURI * *aURI); protected: - nsCacheEntryTransport(nsCachedNetData* aCacheEntry, - nsITransport* aTransport, - nsILoadGroup* aLoadGroup); - virtual ~nsCacheEntryTransport(); + nsCacheEntryChannel(nsCachedNetData* aCacheEntry, nsIChannel* aChannel, nsILoadGroup* aLoadGroup); + virtual ~nsCacheEntryChannel(); friend class nsCachedNetData; private: nsCOMPtr mCacheEntry; nsCOMPtr mLoadGroup; - nsCOMPtr mTransport; }; #endif // _nsCacheEntryChannel_h_ diff --git a/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp b/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp index 128727861af..f6c21f32676 100644 --- a/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp +++ b/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp @@ -645,7 +645,7 @@ nsCachedNetData::GetInUse(PRBool *aInUse) rv = GetUpdateInProgress(aInUse); if (NS_FAILED(rv)) return rv; if (!*aInUse) - *aInUse = (mTransportCount != 0); + *aInUse = (mChannelCount != 0); return NS_OK; } @@ -1122,22 +1122,24 @@ nsCachedNetData::GetCache(nsINetDataCache* *aCache) } NS_IMETHODIMP -nsCachedNetData::NewTransport(nsILoadGroup* aLoadGroup, nsITransport* *aTransport) +nsCachedNetData::NewChannel(nsILoadGroup* aLoadGroup, nsIChannel* *aChannel) { nsresult rv; - nsCOMPtr transport; + nsCOMPtr channel; CHECK_AVAILABILITY(); - rv = mRecord->NewTransport(0, getter_AddRefs(transport)); + rv = mRecord->NewChannel(0, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - nsCacheEntryTransport *cacheEntryTransport; - cacheEntryTransport = new nsCacheEntryTransport(this, transport, aLoadGroup); - if (!cacheEntryTransport) + nsCacheEntryChannel *cacheEntryChannel; + cacheEntryChannel = new nsCacheEntryChannel(this, channel, aLoadGroup); + if (!cacheEntryChannel) return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(*aTransport = cacheEntryTransport); + *aChannel = cacheEntryChannel; + NS_ADDREF(*aChannel); + return NS_OK; } @@ -1173,19 +1175,22 @@ public: // Just in case the protocol handler forgot to set this flag... mCacheEntry->SetFlag(nsCachedNetData::UPDATE_IN_PROGRESS); - rv = mCacheEntry->NewTransport(nsnull, getter_AddRefs(mTransport)); + rv = mCacheEntry->NewChannel(0, getter_AddRefs(mChannel)); if (NS_FAILED(rv)) return rv; - return mTransport->OpenOutputStream(0, -1, 0, getter_AddRefs(mCacheStream)); + rv = mChannel->SetTransferOffset(aStartingOffset); + if (NS_FAILED(rv)) return rv; + + return mChannel->OpenOutputStream(getter_AddRefs(mCacheStream)); } NS_DECL_ISUPPORTS - NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { - return mOriginalListener->OnStartRequest(request, ctxt); + NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { + return mOriginalListener->OnStartRequest(channel, ctxt); } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { if (NS_FAILED(aStatus)) { mCacheEntry->SetFlag(nsCachedNetData::TRUNCATED_CONTENT); @@ -1203,14 +1208,14 @@ public: // Tell any stream-as-file observers that the file has been completely written mCacheEntry->Notify(nsIStreamAsFileObserver::NOTIFY_AVAILABLE, NS_OK); - return mOriginalListener->OnStopRequest(request, ctxt, aStatus, aStatusArg); + return mOriginalListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); } - NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { mOriginalStream = inStr; - return mOriginalListener->OnDataAvailable(request, ctxt, + return mOriginalListener->OnDataAvailable(channel, ctxt, NS_STATIC_CAST(nsIInputStream*, this), sourceOffset, count); } @@ -1301,7 +1306,7 @@ private: nsCOMPtr mCacheStream; nsCOMPtr mOriginalStream; - nsCOMPtr mTransport; + nsCOMPtr mChannel; }; diff --git a/mozilla/netwerk/cache/mgr/nsCachedNetData.h b/mozilla/netwerk/cache/mgr/nsCachedNetData.h index e411d504868..4b9f2ce9e9a 100644 --- a/mozilla/netwerk/cache/mgr/nsCachedNetData.h +++ b/mozilla/netwerk/cache/mgr/nsCachedNetData.h @@ -143,7 +143,7 @@ protected: friend class nsReplacementPolicy; friend class nsCacheManager; friend class StreamAsFile; - friend class nsCacheEntryTransport; + friend class nsCacheEntryChannel; friend class CacheOutputStream; friend class InterceptStreamListener; @@ -193,8 +193,8 @@ private: protected: - // Number of nsCacheEntryTransport's referring to this record - PRUint8 mTransportCount; + // Number of nsCacheEntryChannels referring to this record + PRUint8 mChannelCount; // Below members are statistics kept per cache-entry, used to decide how // profitable it will be to evict a record from the cache relative to other diff --git a/mozilla/netwerk/cache/public/nsICachedNetData.idl b/mozilla/netwerk/cache/public/nsICachedNetData.idl index 07b6613f1a0..01f9305361e 100644 --- a/mozilla/netwerk/cache/public/nsICachedNetData.idl +++ b/mozilla/netwerk/cache/public/nsICachedNetData.idl @@ -20,11 +20,13 @@ * Contributor(s): */ +#include "nsrootidl.idl" #include "nsISupports.idl" + interface nsIURI; interface nsIObserver; -interface nsITransport; +interface nsIChannel; interface nsINetDataCache; interface nsINetDataCacheRecord; interface nsILoadGroup; @@ -212,14 +214,19 @@ interface nsICachedNetData : nsISupports readonly attribute nsINetDataCache cache; /** - * Create a transport for reading or writing a stream of content into the - * entry. + * Create a channel for reading or writing a stream of content into the + * entry. It is expected that many of the nsIChannel methods return + * NS_NOT_IMPLEMENTED, including: * - * Though nsITransport provides for both async and synchronous I/O APIs, - * both may not be implemented. Only AsyncRead() and OpenOutputStream() - * is required. + * + GetURI() + * + GetContentType() + * + GetContentLength() + * + * Though nsIChannel provides for both async and synchronous I/O APIs, both + * may not be implemented. Only AsyncRead() and OpenOutputStream() is + * required. */ - nsITransport newTransport(in nsILoadGroup aLoadGroup); + nsIChannel newChannel(in nsILoadGroup aLoadGroup); /** * This method can be used by a caching protocol handler to store data in diff --git a/mozilla/netwerk/cache/public/nsINetDataCacheRecord.idl b/mozilla/netwerk/cache/public/nsINetDataCacheRecord.idl index fc72597a6cb..11daaffa459 100644 --- a/mozilla/netwerk/cache/public/nsINetDataCacheRecord.idl +++ b/mozilla/netwerk/cache/public/nsINetDataCacheRecord.idl @@ -21,9 +21,10 @@ */ #include "nsISupports.idl" +#include "nsrootidl.idl" interface nsIFile; -interface nsITransport; +interface nsIChannel; interface nsINetDataCache; /** @@ -107,10 +108,15 @@ interface nsINetDataCacheRecord : nsISupports void delete(); /** - * Create a transport for reading or writing a stream of content into the - * entry. + * Create a channel for reading or writing a stream of content into the + * entry. However, many of the nsIChannel methods may return + * NS_NOT_IMPLEMENTED, including: + * + * + GetURI() + * + GetContentType() + * + GetContentLength() */ - nsITransport newTransport(in nsILoadGroup loadGroup); + nsIChannel newChannel(in nsILoadGroup loadGroup); /** * If a cache is implemented such that it stores each URI's content in an diff --git a/mozilla/netwerk/cache/public/nsIStreamAsFile.idl b/mozilla/netwerk/cache/public/nsIStreamAsFile.idl index 5d03de38b22..600342e8090 100644 --- a/mozilla/netwerk/cache/public/nsIStreamAsFile.idl +++ b/mozilla/netwerk/cache/public/nsIStreamAsFile.idl @@ -21,7 +21,7 @@ * Contributor(s): * Scott Furman, fur@netscape.com */ - +#include "nsrootidl.idl" #include "nsISupports.idl" interface nsIFile; diff --git a/mozilla/netwerk/macbuild/netwerk.mcp b/mozilla/netwerk/macbuild/netwerk.mcp index 8cf00b99d3901498213e277ee6bd131a3f7351ba..86bceba16371cad5204bcf7578d9d057719de771 100644 GIT binary patch delta 733 zcmXZYO-lkn9LMn;FBx{JLn&_RO7uh!W*JiMj-irL!0oq^E!{Z05dQPb8rzZ30d9<1^DSa>M|_AOSl5BgzVK&+xe+gv8p{eiCC`7 zp`EG)J}lx$32wkmxCOW24%~%%a33BBS(&=6OE^S5lJ%K-`L(@MxAj}cvYE7(H%Iid lkGB!*?}DfBOtBskOtH*Mx|+^4ABe5Pc3+P*>oGF>^A9q>mwx~N delta 129 zcmezImgC1;jty>-?8_C7{Qv((Z?c1%;^qU_J~M7klrB`%VPasYcJuUc1=2N8x)w^; zLFsxZExvt^C}S<-ZM%RZqX8pO!*Ryx{4$J!U_Sw!3R0akf zAd>;ePs=aLP0cIK1@c%j^HM5`Q#UtAZ)9Z5pR6a_vU!`V2%`wdFrc(65GODJ2_O!h z=qNf_M^$Pwue=>2qw7S+?9JO19C>;2iakS$67z}+@{39)U)Zj&IpKLT^W^1*eC*4) zSN;Eg=J@9Qo#ITBFB?m-FJ~_UI$-+d!ouH-li!<)fdu~lKR+8N@PlzPi$yN`WOs$! z&G+mD7+F9zZvP?4$j>x+(q4s$0a2T)onJ5JfI6&Tv)nfWmd*2CFW}+;sRTL^B-GEc z`RXq#IY#yE0+Ngdj2v#BKCU1g+a07BZ!og31%I=ct|G(uol#=Dj4Wd}v+OybMuFUt Xf=q}Xfg~8%-vfrH$o3-&j0ac%+%9QQ diff --git a/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp b/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp index 5f5e0fd8bb9..b4f34b8d8db 100644 --- a/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp +++ b/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp @@ -28,7 +28,7 @@ #include "nsCOMPtr.h" #include "nsXPIDLString.h" #include "nsEnumeratorUtils.h" -#include "nsITransport.h" +#include "nsIChannel.h" #include "nsIFileTransportService.h" #include "nsIInputStream.h" #include "nsIOutputStream.h" @@ -289,18 +289,18 @@ NS_IMETHODIMP nsXMLMIMEDataSource::Serialize() { nsresult rv = NS_OK; - nsCOMPtr transport; + nsCOMPtr channel; NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv) ; if(NS_FAILED(rv)) return rv ; - rv = fts->CreateTransport(mFile, PR_WRONLY|PR_CREATE_FILE, PR_IRWXU, getter_AddRefs(transport)) ; + rv = fts->CreateTransport( mFile,PR_WRONLY|PR_CREATE_FILE, PR_IRWXU, getter_AddRefs(channel)) ; if(NS_FAILED(rv)) return rv ; // we don't need to worry about notification callbacks nsCOMPtr stream; - rv = transport->OpenOutputStream(0, -1, 0, getter_AddRefs( stream ) ) ; + rv = channel->OpenOutputStream( getter_AddRefs( stream ) ) ; if(NS_FAILED(rv)) return rv ; nsCOMPtr enumerator; @@ -683,19 +683,20 @@ private: nsresult nsXMLMIMEDataSource::InitFromFile( nsIFile* aFile ) { - nsresult rv; - nsCOMPtr transport; - NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv) ; - if(NS_FAILED(rv)) return rv ; - // Made second parameter 0 since I really don't know what it is used for - rv = fts->CreateTransport(aFile, PR_RDONLY, PR_IRWXU, getter_AddRefs(transport)) ; - if(NS_FAILED(rv)) - return rv ; + nsresult rv; + nsCOMPtr channel; + + NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv) ; + if(NS_FAILED(rv)) return rv ; + // Made second parameter 0 since I really don't know what it is used for + rv = fts->CreateTransport(aFile, PR_RDONLY, PR_IRWXU, getter_AddRefs(channel)) ; + if(NS_FAILED(rv)) + return rv ; // we don't need to worry about notification callbacks nsCOMPtr stream; - rv = transport->OpenInputStream(0, -1, 0, getter_AddRefs( stream ) ) ; + rv = channel->OpenInputStream( getter_AddRefs( stream ) ) ; if(NS_FAILED(rv)) return rv ; PRUint32 streamLength; diff --git a/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp b/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp index 7ec85a896ce..bb6882e5542 100644 --- a/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp +++ b/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp @@ -305,15 +305,26 @@ nsDataChannel::SetURI(nsIURI* aURI) // This class NS_IMETHODIMP -nsDataChannel::Open(nsIInputStream **_retval) +nsDataChannel::OpenInputStream(nsIInputStream **_retval) { - NS_ENSURE_ARG_POINTER(_retval); - NS_ADDREF(*_retval = mDataStream); + // XXX we should honor the startPosition and count passed in. + + *_retval = mDataStream; + NS_ADDREF(*_retval); + return NS_OK; } NS_IMETHODIMP -nsDataChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) +nsDataChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + // you can't write to a data url + NS_NOTREACHED("nsDataChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDataChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt) { nsresult rv; nsCOMPtr eventQ; @@ -341,9 +352,19 @@ nsDataChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) if (NS_FAILED(rv)) return rv; rv = listener->OnStopRequest(this, ctxt, NS_OK, nsnull); + return rv; } +NS_IMETHODIMP +nsDataChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + // you can't write to a data url + NS_NOTREACHED("nsDataChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsDataChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) { @@ -395,6 +416,83 @@ nsDataChannel::SetContentLength(PRInt32 aContentLength) return NS_OK; } +NS_IMETHODIMP +nsDataChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsDataChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDataChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsDataChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDataChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsDataChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDataChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsDataChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDataChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsDataChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsDataChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsDataChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsDataChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsDataChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsDataChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsDataChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -428,7 +526,6 @@ nsDataChannel::SetOwner(nsISupports* aOwner) NS_IMETHODIMP nsDataChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) { - NS_ENSURE_ARG_POINTER(aNotificationCallbacks); *aNotificationCallbacks = mCallbacks.get(); NS_IF_ADDREF(*aNotificationCallbacks); return NS_OK; @@ -441,10 +538,9 @@ nsDataChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCall return NS_OK; } -NS_IMETHODIMP -nsDataChannel::GetSecurityInfo(nsISupports **sec) +NS_IMETHODIMP +nsDataChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - NS_ENSURE_ARG_POINTER(sec); - *sec = nsnull; + *aSecurityInfo = nsnull; return NS_OK; } diff --git a/mozilla/netwerk/protocol/data/src/nsDataChannel.h b/mozilla/netwerk/protocol/data/src/nsDataChannel.h index 6e0ee4b7b2c..c1694c237e3 100644 --- a/mozilla/netwerk/protocol/data/src/nsDataChannel.h +++ b/mozilla/netwerk/protocol/data/src/nsDataChannel.h @@ -63,6 +63,8 @@ protected: nsCString mContentType; PRInt32 mContentLength; nsCOMPtr mOwner; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; }; #endif /* nsFTPChannel_h___ */ diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp index e92e99dc207..082a0a6cc27 100644 --- a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp @@ -28,8 +28,6 @@ #include "nsIInterfaceRequestor.h" #include "nsXPIDLString.h" #include "nsISocketTransportService.h" -#include "nsITransport.h" -#include "nsIProgressEventSink.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -43,11 +41,7 @@ nsDateTimeChannel::nsDateTimeChannel() { nsDateTimeChannel::~nsDateTimeChannel() { } -NS_IMPL_ISUPPORTS4(nsDateTimeChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamObserver) +NS_IMPL_ISUPPORTS4(nsDateTimeChannel, nsIChannel, nsIRequest, nsIStreamListener, nsIStreamObserver) nsresult nsDateTimeChannel::Init(nsIURI* uri) @@ -162,48 +156,57 @@ nsDateTimeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsDateTimeChannel::Open(nsIInputStream **_retval) +nsDateTimeChannel::OpenInputStream(nsIInputStream **_retval) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - transport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; - return transport->OpenInputStream(0, -1, 0, _retval); + return channel->OpenInputStream(_retval); } NS_IMETHODIMP -nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) +nsDateTimeChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("nsDateTimeChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener, + nsISupports *ctxt) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(transport)); + nsCOMPtr channel; + rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - transport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; mListener = aListener; - - nsCOMPtr request; - return transport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(request)); + + return channel->AsyncRead(this, ctxt); +} + +NS_IMETHODIMP +nsDateTimeChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + NS_NOTREACHED("nsDateTimeChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -253,6 +256,83 @@ nsDateTimeChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsDateTimeChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsDateTimeChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsDateTimeChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsDateTimeChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsDateTimeChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsDateTimeChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsDateTimeChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsDateTimeChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsDateTimeChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsDateTimeChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsDateTimeChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -265,11 +345,11 @@ NS_IMETHODIMP nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) { if (mLoadGroup) // if we already had a load group remove ourselves... - (void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); + (void)mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); mLoadGroup = aLoadGroup; if (mLoadGroup) { - return mLoadGroup->AddRequest(this, nsnull); + return mLoadGroup->AddChannel(this, nsnull); } return NS_OK; } @@ -304,26 +384,25 @@ nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification return NS_OK; } -NS_IMETHODIMP -nsDateTimeChannel::GetSecurityInfo(nsISupports **sec) +NS_IMETHODIMP +nsDateTimeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - NS_ENSURE_ARG_POINTER(sec); - *sec = nsnull; + *aSecurityInfo = nsnull; return NS_OK; } // nsIStreamObserver methods NS_IMETHODIMP -nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { +nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { return mListener->OnStartRequest(this, aContext); } NS_IMETHODIMP -nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, +nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { if (mLoadGroup) { - nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); + nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } return mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); @@ -332,7 +411,7 @@ nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext, +nsDateTimeChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { mContentLength = aLength; diff --git a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h index 278f9c7a198..e80a83681c8 100644 --- a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h @@ -39,10 +39,7 @@ #include "nsIStreamListener.h" -class nsDateTimeChannel -: public nsIChannel, - public nsIStreamListener { - +class nsDateTimeChannel : public nsIChannel, public nsIStreamListener { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -70,6 +67,8 @@ protected: nsCString mContentType; PRInt32 mContentLength; nsCOMPtr mOwner; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; PRInt32 mPort; nsXPIDLCString mHost; diff --git a/mozilla/netwerk/protocol/file/public/nsIFileChannel.idl b/mozilla/netwerk/protocol/file/public/nsIFileChannel.idl index fecc229fa77..0d31cc4be18 100644 --- a/mozilla/netwerk/protocol/file/public/nsIFileChannel.idl +++ b/mozilla/netwerk/protocol/file/public/nsIFileChannel.idl @@ -1 +1,131 @@ -/* see nsIChannel.idl */ \ No newline at end of file +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nsIChannel.idl" + +interface nsISimpleEnumerator; +native nsFileSpec(nsFileSpec); + +%{C++ +#include "nsFileSpec.h" +%} + +[scriptable, uuid(73025830-0ce2-11d3-9331-00104ba0fd40)] +interface nsIFileChannel : nsIChannel +{ + /** + * Returns the last modification date of the URL. + */ + readonly attribute PRTime ModDate; + + /** + * Returns the size of the file referred to by the URL. + * @return NS_ERROR_FAILURE if the URL refers to a directory. + */ + readonly attribute unsigned long FileSize; + + /** + * Returns the parent directory of a URL. + */ + readonly attribute nsIFileChannel Parent; + + /** + * Returns an enumeration of the elements in a directory. Each + * element in the enumeration is an nsIFileChannel. + * @return NS_ERROR_FAILURE if the current nsIFileChannel does + * not specify a directory. + */ + readonly attribute nsISimpleEnumerator Children; + + /** + * Returns a native path string suitable to be passes to native platform + * routines. + */ + readonly attribute string NativePath; + + /** + * Returns true if the file exists. + */ + boolean Exists(); + + /** + * Creates an empty file if the file does not exist. + */ + void Create(); + + /** + * Returns true if the file exists. + */ + void Delete(); + + /** + * Move or rename a file. + */ + void MoveFrom(in nsIURI src); + + /** + * Copies the contents of a file to a new destination. Creates the + * destination file if it doesn't already exist, otherwise overwrites + * it. + */ + void CopyFrom(in nsIURI src); + + /** + * Returns true if the file URL specifies a directory. Note that this + * may be the case even if the file URL does not terminate with a slash. + */ + boolean IsDirectory(); + + /** + * Returns true if the file URL specifies a file and not a directory. + */ + boolean IsFile(); + + /** + * Returns true if the specified file is a symbolic link (on unix), + * alias (on Mac) or shortcut (on Windows). + */ + boolean IsLink(); + + /** + * Returns a file URL to the destination of a link (alias or shortcut). + */ + nsIFileChannel ResolveLink(); + + /** + * Returns a new unique unique file channel for the directory of the current URL. + */ + nsIFileChannel MakeUnique(in string baseName); + + /** + * Executes a program specified by the file channel. + * @param args - The program arguments to run with. If not specified, + * the Query portion of the URI is used as the argument string. + */ + void Execute(in string args); + + /** + * XXX Until we eliminate nsFileSpec... + */ + [noscript] void GetFileSpec(out nsFileSpec spec); +}; + diff --git a/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl b/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl index 837df187d6b..1e2e0a4df7b 100644 --- a/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl +++ b/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl @@ -1 +1,38 @@ -/* remove */ \ No newline at end of file +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nsIProtocolHandler.idl" + +interface nsIFileChannel; +interface nsIFile; + +[scriptable, uuid(fa1941f2-3102-11d3-8cd0-0060b0fc14a3)] +interface nsIFileProtocolHandler : nsIProtocolHandler +{ + nsIFileChannel newFileChannel(in nsIFile file, + in nsILoadGroup aLoadGroup, + in nsIInterfaceRequestor notificationCallbacks, + in nsLoadFlags loadAttributes, + in nsIURI originalURI, + in unsigned long bufferSegmentSize, + in unsigned long bufferMaxSize); +}; diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index b0f51bee115..77be1784ed1 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -88,13 +88,13 @@ nsFileChannel::~nsFileChannel() } NS_IMPL_THREADSAFE_ISUPPORTS7(nsFileChannel, - nsIFileChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamObserver, - nsIProgressEventSink, - nsIInterfaceRequestor) + nsIFileChannel, + nsIChannel, + nsIRequest, + nsIStreamListener, + nsIStreamObserver, + nsIProgressEventSink, + nsIInterfaceRequestor) NS_METHOD nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) @@ -118,8 +118,8 @@ nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) NS_IMETHODIMP nsFileChannel::GetName(PRUnichar* *result) { - if (mCurrentRequest) - return mCurrentRequest->GetName(result); + if (mFileTransport) + return mFileTransport->GetName(result); nsresult rv; nsXPIDLCString urlStr; rv = mURI->GetSpec(getter_Copies(urlStr)); @@ -133,8 +133,8 @@ nsFileChannel::GetName(PRUnichar* *result) NS_IMETHODIMP nsFileChannel::IsPending(PRBool *result) { - if (mCurrentRequest) - return mCurrentRequest->IsPending(result); + if (mFileTransport) + return mFileTransport->IsPending(result); *result = PR_FALSE; return NS_OK; } @@ -155,8 +155,8 @@ nsFileChannel::Cancel(nsresult status) "wrong thread calling this routine"); #endif mStatus = status; - if (mCurrentRequest) - return mCurrentRequest->Cancel(status); + if (mFileTransport) + return mFileTransport->Cancel(status); return NS_OK; } @@ -167,8 +167,8 @@ nsFileChannel::Suspend() NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif - if (mCurrentRequest) - return mCurrentRequest->Suspend(); + if (mFileTransport) + return mFileTransport->Suspend(); return NS_OK; } @@ -179,8 +179,8 @@ nsFileChannel::Resume() NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif - if (mCurrentRequest) - return mCurrentRequest->Resume(); + if (mFileTransport) + return mFileTransport->Resume(); return NS_OK; } @@ -230,14 +230,35 @@ nsFileChannel::EnsureTransport() getter_AddRefs(mFileTransport)); if (NS_FAILED(rv)) return rv; - if (mCallbacks && !(mLoadAttributes & LOAD_BACKGROUND)) - (void)mFileTransport->SetProgressEventSink(this); - + if (mLoadAttributes != LOAD_NORMAL) { + rv = mFileTransport->SetLoadAttributes(mLoadAttributes); + if (NS_FAILED(rv)) return rv; + } + if (mBufferSegmentSize) { + rv = mFileTransport->SetBufferSegmentSize(mBufferSegmentSize); + if (NS_FAILED(rv)) return rv; + } + if (mBufferMaxSize) { + rv = mFileTransport->SetBufferMaxSize(mBufferMaxSize); + if (NS_FAILED(rv)) return rv; + } + if (mCallbacks) { + rv = mFileTransport->SetNotificationCallbacks(this); + if (NS_FAILED(rv)) return rv; + } + if (mTransferOffset) { + rv = mFileTransport->SetTransferOffset(mTransferOffset); + if (NS_FAILED(rv)) return rv; + } + if (mTransferCount >= 0) { + rv = mFileTransport->SetTransferCount(mTransferCount); + if (NS_FAILED(rv)) return rv; + } return rv; } NS_IMETHODIMP -nsFileChannel::Open(nsIInputStream **result) +nsFileChannel::OpenInputStream(nsIInputStream **result) { nsresult rv; @@ -247,7 +268,7 @@ nsFileChannel::Open(nsIInputStream **result) rv = EnsureTransport(); if (NS_FAILED(rv)) goto done; - rv = mFileTransport->OpenInputStream(0, -1, 0, result); + rv = mFileTransport->OpenInputStream(result); done: if (NS_FAILED(rv)) { // release the transport so that we don't think we're in progress @@ -256,14 +277,12 @@ nsFileChannel::Open(nsIInputStream **result) return rv; } -// XXX What does OpenOutputStream mean for a file "channel" -#if 0 NS_IMETHODIMP -nsFileChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **result) +nsFileChannel::OpenOutputStream(nsIOutputStream **result) { nsresult rv; - if (mCurrentRequest) + if (mFileTransport) return NS_ERROR_IN_PROGRESS; mIOFlags |= PR_WRONLY; @@ -271,19 +290,18 @@ nsFileChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, rv = EnsureTransport(); if (NS_FAILED(rv)) goto done; - rv = mFileTransport->OpenOutputStream(transferOffset, transferCount, result); + rv = mFileTransport->OpenOutputStream(result); done: if (NS_FAILED(rv)) { // release the transport so that we don't think we're in progress mFileTransport = nsnull; - mCurrentRequest = nsnull; } return rv; } -#endif NS_IMETHODIMP -nsFileChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +nsFileChannel::AsyncRead(nsIStreamListener *listener, + nsISupports *ctxt) { nsresult rv; @@ -315,23 +333,72 @@ nsFileChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) } } - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } rv = EnsureTransport(); if (NS_FAILED(rv)) goto done; - - rv = mFileTransport->AsyncRead(tempListener, ctxt, 0, -1, 0, - getter_AddRefs(mCurrentRequest)); + + rv = mFileTransport->AsyncRead(tempListener, ctxt); done: if (NS_FAILED(rv)) { - nsresult rv2 = mLoadGroup->RemoveRequest(this, ctxt, rv, nsnull); // XXX fix error message - NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveRequest failed"); + nsresult rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); // XXX fix error message + NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); + // release the transport so that we don't think we're in progress + mFileTransport = nsnull; + } + return rv; +} + +NS_IMETHODIMP +nsFileChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + nsresult rv; + +#ifdef DEBUG + NS_ASSERTION(mInitiator == nsnull || mInitiator == PR_CurrentThread(), + "wrong thread calling this routine"); + mInitiator = PR_CurrentThread(); +#endif + + if (mFileTransport) + return NS_ERROR_IN_PROGRESS; + + mIOFlags |= PR_WRONLY; + + 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; + } + + rv = EnsureTransport(); + if (NS_FAILED(rv)) goto done; + + rv = mFileTransport->AsyncWrite(provider, ctxt); + + done: + if (NS_FAILED(rv)) { + nsresult rv2 = mLoadGroup->RemoveChannel(this, ctxt, rv, nsnull); // XXX fix error message + NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); // release the transport so that we don't think we're in progress mFileTransport = nsnull; - mCurrentRequest = nsnull; } return rv; } @@ -363,7 +430,7 @@ nsFileChannel::GetContentType(char * *aContentType) mContentType = "application/http-index-format"; } else { - nsCOMPtr MIMEService(do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); + nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; rv = MIMEService->GetTypeFromFile(mFile, aContentType); @@ -414,6 +481,84 @@ nsFileChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsFileChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + mTransferOffset = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::SetTransferCount(PRInt32 aTransferCount) +{ + mTransferCount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::GetLocalFile(nsIFile* *file) +{ + *file = mFile; + NS_ADDREF(*file); + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsFileChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsFileChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -478,7 +623,7 @@ nsFileChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileChannel::OnStartRequest(nsIRequest* request, nsISupports* context) +nsFileChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) { #ifdef DEBUG NS_ASSERTION(mInitiator == PR_CurrentThread(), @@ -493,7 +638,7 @@ nsFileChannel::OnStartRequest(nsIRequest* request, nsISupports* context) } NS_IMETHODIMP -nsFileChannel::OnStopRequest(nsIRequest* request, nsISupports* context, +nsFileChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { #ifdef DEBUG @@ -508,19 +653,18 @@ nsFileChannel::OnStopRequest(nsIRequest* request, nsISupports* context, if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } // Release the reference to the consumer stream listener... - mRealListener = 0; - mFileTransport = 0; - mCurrentRequest = 0; + mRealListener = null_nsCOMPtr(); + mFileTransport = null_nsCOMPtr(); return rv; } NS_IMETHODIMP -nsFileChannel::OnDataAvailable(nsIRequest* request, nsISupports* context, +nsFileChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -539,8 +683,8 @@ nsFileChannel::OnDataAvailable(nsIRequest* request, nsISupports* context, // insure that the transport will go away even if it is blocked waiting // for the consumer to empty the pipe... // - if (NS_FAILED(rv) && mCurrentRequest) { - mCurrentRequest->Cancel(rv); + if (NS_FAILED(rv)) { + mFileTransport->Cancel(rv); } return rv; } @@ -569,7 +713,7 @@ nsFileChannel::GetInterface(const nsIID &anIID, void **aResult ) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileChannel::OnStatus(nsIRequest *request, nsISupports* ctxt, +nsFileChannel::OnStatus(nsIChannel *aChannel, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -580,7 +724,7 @@ nsFileChannel::OnStatus(nsIRequest *request, nsISupports* ctxt, } NS_IMETHODIMP -nsFileChannel::OnProgress(nsIRequest *request, +nsFileChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.h b/mozilla/netwerk/protocol/file/src/nsFileChannel.h index 2ec12647eb2..f4a82c91f19 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.h +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.h @@ -38,7 +38,6 @@ #include "nsCOMPtr.h" #include "nsIFile.h" /* Solaris/gcc needed this here. */ #include "nsIProgressEventSink.h" -#include "nsITransport.h" class nsFileChannel : public nsIFileChannel, public nsIInterfaceRequestor, @@ -73,7 +72,7 @@ protected: nsCOMPtr mCallbacks; PRInt32 mIOFlags; PRInt32 mPerm; - nsCOMPtr mFileTransport; + nsCOMPtr mFileTransport; nsCString mContentType; PRUint32 mLoadAttributes; nsCOMPtr mLoadGroup; @@ -85,7 +84,6 @@ protected: PRUint32 mBufferMaxSize; nsresult mStatus; nsCOMPtr mProgress; - nsCOMPtr mCurrentRequest; #ifdef DEBUG PRThread* mInitiator; #endif diff --git a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.cpp b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.cpp index c43dadd3a62..f85e08414cf 100644 --- a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.cpp +++ b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.cpp @@ -32,7 +32,6 @@ #include "nsMimeTypes.h" #include "nsIStreamConverterService.h" #include "nsITXTToHTMLConv.h" -#include "nsIProgressEventSink.h" #include "nsNetUtil.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -54,11 +53,8 @@ nsFingerChannel::nsFingerChannel() nsFingerChannel::~nsFingerChannel() { } -NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamObserver) +NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel, nsIChannel, nsIRequest, + nsIStreamListener, nsIStreamObserver) nsresult nsFingerChannel::Init(nsIURI* uri) @@ -148,8 +144,8 @@ nsFingerChannel::Cancel(nsresult status) nsresult rv = NS_ERROR_FAILURE; mStatus = status; - if (mTransportRequest) { - rv = mTransportRequest->Cancel(status); + if (mTransport) { + rv = mTransport->Cancel(status); } return rv; } @@ -202,48 +198,60 @@ nsFingerChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsFingerChannel::Open(nsIInputStream **_retval) +nsFingerChannel::OpenInputStream(nsIInputStream **_retval) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; + nsCOMPtr channel; rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, - BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); + BUFFER_MAX_SIZE, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - mTransport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; - return mTransport->OpenInputStream(0, -1, 0, _retval); + return channel->OpenInputStream(_retval); } NS_IMETHODIMP -nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) +nsFingerChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("nsFingerChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt) { nsresult rv = NS_OK; NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; + nsCOMPtr channel; rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, - BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); + BUFFER_MAX_SIZE, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - mTransport->SetProgressEventSink(sink); - } + rv = channel->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; mListener = aListener; mResponseContext = ctxt; + mTransport = channel; - return SendRequest(mTransport); + return SendRequest(channel); +} + +NS_IMETHODIMP +nsFingerChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + NS_NOTREACHED("nsFingerChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -293,6 +301,83 @@ nsFingerChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsFingerChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsFingerChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsFingerChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsFingerChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsFingerChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsFingerChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsFingerChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsFingerChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsFingerChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFingerChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsFingerChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsFingerChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsFingerChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -347,7 +432,7 @@ nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) // nsIStreamObserver methods NS_IMETHODIMP -nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { +nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { if (!mActAsObserver) { // acting as a listener return mListener->OnStartRequest(this, mResponseContext); @@ -360,14 +445,14 @@ nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { NS_IMETHODIMP -nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, +nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (NS_FAILED(aStatus) || !mActAsObserver) { if (mLoadGroup) { - rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); + rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } rv = mListener->OnStopRequest(this, mResponseContext, aStatus, aStatusArg); @@ -402,8 +487,7 @@ nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, converter->PreFormatHTML(PR_TRUE); } - return mTransport->AsyncRead(converterListener, mResponseContext, 0,-1, 0, - getter_AddRefs(mTransportRequest)); + return aChannel->AsyncRead(converterListener, mResponseContext); } } @@ -411,7 +495,7 @@ nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext, +nsFingerChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { mContentLength = aLength; @@ -419,7 +503,7 @@ nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext, } nsresult -nsFingerChannel::SendRequest(nsITransport* aTransport) { +nsFingerChannel::SendRequest(nsIChannel* aChannel) { // The text to send should already be in mUser nsresult rv = NS_OK; @@ -428,7 +512,7 @@ nsFingerChannel::SendRequest(nsITransport* aTransport) { nsCString requestBuffer(mUser); if (mLoadGroup) { - mLoadGroup->AddRequest(this, nsnull); + mLoadGroup->AddChannel(this, nsnull); } requestBuffer.Append(CRLF); @@ -441,10 +525,9 @@ nsFingerChannel::SendRequest(nsITransport* aTransport) { charstream = do_QueryInterface(result, &rv); if (NS_FAILED(rv)) return rv; - rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest), - aTransport, charstream, - 0, requestBuffer.Length(), 0, - this, nsnull); + rv = aChannel->SetTransferCount(requestBuffer.Length()); + if (NS_FAILED(rv)) return rv; + rv = NS_AsyncWriteFromStream(aChannel, charstream, this, nsnull); return rv; } diff --git a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h index e77455dc689..dc24c0e6d24 100644 --- a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h +++ b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h @@ -33,12 +33,9 @@ #include "nsIURI.h" #include "nsFingerHandler.h" #include "nsIStreamListener.h" -#include "nsITransport.h" -class nsFingerChannel -: public nsIChannel, - public nsIStreamListener { +class nsFingerChannel : public nsIChannel, public nsIStreamListener { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -77,12 +74,11 @@ protected: nsXPIDLCString mRequest; nsCOMPtr mResponseContext; - nsCOMPtr mTransport; - nsCOMPtr mTransportRequest; + nsCOMPtr mTransport; nsresult mStatus; protected: - nsresult SendRequest(nsITransport* aTransport); + nsresult SendRequest(nsIChannel* aChannel); }; #endif /* nsFingerChannel_h___ */ diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 074591e459e..6e69cc6984f 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -49,6 +49,8 @@ nsFTPChannel::nsFTPChannel() mAmount(0), mContentLength(-1), mFTPState(nsnull), + mBufferSegmentSize(0), + mBufferMaxSize(0), mLock(nsnull), mStatus(NS_OK), mProxyPort(-1), @@ -72,7 +74,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS8(nsFTPChannel, nsIChannel, nsIFTPChannel, nsIProxy, - nsIRequest, + nsIRequest, nsIInterfaceRequestor, nsIProgressEventSink, nsIStreamListener, @@ -224,20 +226,29 @@ nsFTPChannel::SetURI(nsIURI* aURL) } NS_IMETHODIMP -nsFTPChannel::Open(nsIInputStream **result) +nsFTPChannel::OpenInputStream(nsIInputStream **result) { if (mProxyChannel) - return mProxyChannel->Open(result); - NS_NOTREACHED("nsFTPChannel::Open"); + return mProxyChannel->OpenInputStream(result); + NS_NOTREACHED("nsFTPChannel::OpenInputStream"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +nsFTPChannel::OpenOutputStream(nsIOutputStream **result) +{ + if (mProxyChannel) + return mProxyChannel->OpenOutputStream(result); + NS_NOTREACHED("nsFTPChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsFTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; - PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFTPChannel::AsyncOpen() called\n")); + PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFTPChannel::AsyncRead() called\n")); mListener = listener; mUserContext = ctxt; @@ -251,12 +262,17 @@ nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) } if (mLoadGroup) { - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } if (mProxyChannel) { - return mProxyChannel->AsyncOpen(this, ctxt); + // rjc says: ignore errors on SetTransferOffset() and + // SetTransferCount() as they may be unimplemented + rv = mProxyChannel->SetTransferOffset(mSourceOffset); + rv = mProxyChannel->SetTransferCount(mAmount); + + return mProxyChannel->AsyncRead(this, ctxt); } //////////////////////////////// @@ -266,7 +282,8 @@ nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) if (!mFTPState) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mFTPState); } - rv = mFTPState->Init(this, mPrompter); + rv = mFTPState->Init(this, mPrompter, + mBufferSegmentSize, mBufferMaxSize); if (NS_FAILED(rv)) return rv; rv = mFTPState->SetStreamListener(this, ctxt); @@ -275,6 +292,52 @@ nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) return mFTPState->Connect(); } +NS_IMETHODIMP +nsFTPChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + nsresult rv = NS_OK; + + mObserver = provider; + mUserContext = ctxt; + + if (mProxyChannel) { + rv = mProxyChannel->SetTransferOffset(mSourceOffset); + if (NS_FAILED(rv)) return rv; + rv = mProxyChannel->SetTransferCount(mAmount); + if (NS_FAILED(rv)) return rv; + return mProxyChannel->AsyncWrite(provider, ctxt); + } + + return NS_ERROR_NOT_IMPLEMENTED; +#if 0 + NS_ASSERTION(mAmount > 0, "FTP requires stream len info"); + if (mAmount < 1) return NS_ERROR_NOT_INITIALIZED; + + if (!mFTPState) { + NS_NEWXPCOM(mFTPState, nsFtpState); + if (!mFTPState) return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(mFTPState); + } + + rv = mFTPState->Init(this, mPrompter, + mBufferSegmentSize, mBufferMaxSize); + if (NS_FAILED(rv)) return rv; + + rv = mFTPState->SetWriteStream(fromStream, mAmount); + if (NS_FAILED(rv)) return rv; + + rv = mFTPState->SetStreamObserver(this, ctxt); + if (NS_FAILED(rv)) return rv; + + if (mLoadGroup) { + rv = mLoadGroup->AddChannel(this, nsnull); + if (NS_FAILED(rv)) return rv; + } + return mFTPState->Connect(); +#endif +} + NS_IMETHODIMP nsFTPChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) { @@ -346,6 +409,83 @@ nsFTPChannel::SetContentLength(PRInt32 aContentLength) return NS_OK; } +NS_IMETHODIMP +nsFTPChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mSourceOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + mSourceOffset = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mAmount; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::SetTransferCount(PRInt32 aTransferCount) +{ + mAmount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsFTPChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -419,9 +559,10 @@ nsFTPChannel::GetInterface(const nsIID &anIID, void **aResult ) { } } + // nsIProgressEventSink methods NS_IMETHODIMP -nsFTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext, +nsFTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { if (!mEventSink) @@ -439,7 +580,7 @@ nsFTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext, } NS_IMETHODIMP -nsFTPChannel::OnProgress(nsIRequest *request, nsISupports* aContext, +nsFTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { return mEventSink ? mEventSink->OnProgress(this, aContext, aProgress, (PRUint32) mContentLength) : NS_OK; } @@ -447,13 +588,13 @@ nsFTPChannel::OnProgress(nsIRequest *request, nsISupports* aContext, // nsIStreamObserver methods. NS_IMETHODIMP -nsFTPChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, +nsFTPChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mLoadGroup) { - rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); + rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } @@ -470,7 +611,7 @@ nsFTPChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, } NS_IMETHODIMP -nsFTPChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { +nsFTPChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { nsresult rv = NS_OK; if (mObserver) { rv = mObserver->OnStartRequest(this, aContext); @@ -487,7 +628,7 @@ nsFTPChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { // nsIStreamListener method NS_IMETHODIMP -nsFTPChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext, +nsFTPChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength); diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h index d3f75902e5c..b58db0f1087 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -42,18 +42,6 @@ #include "nsIFTPChannel.h" #include "nsIProxy.h" -#define FTP_COMMAND_CHANNEL_SEG_SIZE 64 -#define FTP_COMMAND_CHANNEL_MAX_SIZE 512 - -#define NS_FTP_BUFFER_READ_SIZE (8*1024) -#define NS_FTP_BUFFER_WRITE_SIZE (8*1024) - -#define FTP_CACHE_CONTROL_CONNECTION 1 -//#define FTP_NO_HTTP_INDEX_FORMAT -//#define FTP_SIMULATE_DROPPED_CONTROL_CONNECTION - - - class nsFTPChannel : public nsIFTPChannel, public nsIProxy, public nsIInterfaceRequestor, @@ -104,13 +92,14 @@ protected: nsCOMPtr mObserver; nsFtpState* mFTPState; - + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; + nsCOMPtr mProxyChannel; // a proxy channel nsXPIDLCString mHost; PRLock* mLock; nsCOMPtr mUserContext; nsresult mStatus; - nsCOMPtr mProxyChannel; // a proxy channel nsCAutoString mProxyHost; PRInt32 mProxyPort; nsCAutoString mProxyType; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index 029143f37e6..9d4a327a0ce 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -19,7 +19,6 @@ * * Contributor(s): */ -#include "nsFTPChannel.h" #include "nsFtpConnectionThread.h" #include "nsFtpControlConnection.h" #include "nsFtpProtocolHandler.h" @@ -48,86 +47,17 @@ static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CI static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); +#define FTP_COMMAND_CHANNEL_SEG_SIZE 64 +#define FTP_COMMAND_CHANNEL_MAX_SIZE 512 + +#define FTP_CACHE_CONTROL_CONNECTION 1 +//#define FTP_NO_HTTP_INDEX_FORMAT +//#define FTP_SIMULATE_DROPPED_CONTROL_CONNECTION + #if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; #endif /* PR_LOGGING */ - - - -class DataRequestForwarder : public nsIChannel, public nsIStreamListener -{ -public: - DataRequestForwarder(); - virtual ~DataRequestForwarder(); - nsresult Init(nsIRequest *request, nsIStreamListener *listener); - - NS_DECL_ISUPPORTS - NS_DECL_NSISTREAMLISTENER - NS_DECL_NSISTREAMOBSERVER - - NS_FORWARD_NSIREQUEST(mRequest->) - NS_FORWARD_NSICHANNEL(mChannel->) - -protected: - nsCOMPtr mRequest; - nsCOMPtr mChannel; - nsCOMPtr mListener; - -}; - - -NS_IMPL_THREADSAFE_ISUPPORTS4(DataRequestForwarder, - nsIStreamListener, - nsIStreamObserver, - nsIChannel, - nsIRequest); - - -DataRequestForwarder::DataRequestForwarder() -{ - NS_INIT_ISUPPORTS(); -} - -DataRequestForwarder::~DataRequestForwarder() -{ -} - -nsresult -DataRequestForwarder::Init(nsIRequest *request, nsIStreamListener *listener) -{ - mRequest = request; - mChannel = do_QueryInterface(request); - mListener = listener; - - if (!mRequest || !mChannel || !mListener) - return NS_ERROR_FAILURE; - - return NS_OK; -} - - -NS_IMETHODIMP -DataRequestForwarder::OnStartRequest(nsIRequest *request, nsISupports *ctxt) -{ - return mListener->OnStartRequest(this, ctxt); -} - -NS_IMETHODIMP -DataRequestForwarder::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult statusCode, const PRUnichar *statusText) -{ - return mListener->OnStopRequest(this, ctxt, statusCode, statusText); -} - -NS_IMETHODIMP -DataRequestForwarder::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *input, PRUint32 offset, PRUint32 count) -{ - return mListener->OnDataAvailable(this, ctxt, input, offset, count); -} - - - - NS_IMPL_THREADSAFE_ISUPPORTS3(nsFtpState, nsIStreamListener, nsIStreamObserver, @@ -151,7 +81,9 @@ nsFtpState::nsFtpState() { mLastModified = LL_ZERO; mWriteCount = 0; - + mBufferSegmentSize = 0; + mBufferMaxSize = 0; + mControlReadContinue = PR_FALSE; mControlReadBrokenLine = PR_FALSE; @@ -170,11 +102,11 @@ nsFtpState::~nsFtpState() // nsIStreamListener implementation NS_IMETHODIMP -nsFtpState::OnDataAvailable(nsIRequest *request, - nsISupports *aContext, - nsIInputStream *aInStream, - PRUint32 aOffset, - PRUint32 aCount) +nsFtpState::OnDataAvailable(nsIChannel *aChannel, + nsISupports *aContext, + nsIInputStream *aInStream, + PRUint32 aOffset, + PRUint32 aCount) { if (aCount == 0) return NS_OK; /*** should this be an error?? */ @@ -195,11 +127,6 @@ nsFtpState::OnDataAvailable(nsIRequest *request, nsCString logString(buffer); logString.ReplaceChar(CRLF, ' '); PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) reading %d bytes: \"%s\"", this, aCount, logString.GetBuffer())); - -#ifdef DEBUG_dougt -//printf("@@@ %s\n", logString.GetBuffer()); -#endif - #endif // get the response code out. @@ -290,7 +217,7 @@ nsFtpState::OnDataAvailable(nsIRequest *request, // nsIStreamObserver implementation NS_IMETHODIMP -nsFtpState::OnStartRequest(nsIRequest *request, nsISupports *aContext) +nsFtpState::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { #if defined(PR_LOGGING) nsXPIDLCString spec; @@ -303,7 +230,7 @@ nsFtpState::OnStartRequest(nsIRequest *request, nsISupports *aContext) } NS_IMETHODIMP -nsFtpState::OnStopRequest(nsIRequest *request, nsISupports *aContext, +nsFtpState::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) nsFtpState::OnStopRequest() rv=%d\n", this, aStatus)); @@ -351,14 +278,17 @@ nsFtpState::EstablishControlConnection() rv = mURL->GetHost(getter_Copies(host)); if (NS_FAILED(rv)) return rv; - nsCOMPtr transport; + nsCOMPtr channel; // build our own - rv = CreateTransport(host, mPort, getter_AddRefs(transport)); // the command transport + rv = CreateTransport(host, mPort, + FTP_COMMAND_CHANNEL_SEG_SIZE, + FTP_COMMAND_CHANNEL_MAX_SIZE, + getter_AddRefs(channel)); // the command channel if (NS_FAILED(rv)) return rv; mState = FTP_READ_BUF; - mControlConnection = new nsFtpControlConnection(transport); + mControlConnection = new nsFtpControlConnection(channel); if (!mControlConnection) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mControlConnection); @@ -1196,6 +1126,7 @@ nsFtpState::R_cwd() { // update mURL->SetPath(mCwd); + #ifdef FTP_NO_HTTP_INDEX_FORMAT nsresult rv = mChannel->SetContentType("text/html"); #else @@ -1231,7 +1162,7 @@ nsFtpState::R_size() { if (mResponseCode/100 == 2) { PRInt32 conversionError; PRInt32 length = mResponseMsg.ToInteger(&conversionError); - if (NS_FAILED(mChannel->SetContentLength(length))) return FTP_ERROR; + if (NS_FAILED(mChannel->SetContentLength(length))) return FTP_ERROR; } return FTP_S_MDTM; @@ -1321,18 +1252,12 @@ nsFtpState::S_list() { } mFireCallbacks = PR_FALSE; // listener callbacks will be handled by the transport. - DataRequestForwarder *forwarder = new DataRequestForwarder; - if (!forwarder) return NS_ERROR_FAILURE; - NS_ADDREF(forwarder); - #ifdef FTP_NO_HTTP_INDEX_FORMAT - fowarder->Init(mChannel, mListener); + return mDPipe->AsyncRead(mListener, nsnull); #else - forwarder->Init(mChannel, converterListener); + return mDPipe->AsyncRead(converterListener, mListenerContext); #endif - rv = mDPipe->AsyncRead(forwarder, mListenerContext, 0, -1, 0, getter_AddRefs(mDPipeRequest)); - NS_RELEASE(forwarder); // let the transport worry about this objects lifespan - return rv; + } FTP_STATE @@ -1356,15 +1281,7 @@ nsFtpState::S_retr() { mFireCallbacks = PR_FALSE; // listener callbacks will be handled by the transport. - DataRequestForwarder *forwarder = new DataRequestForwarder; - if (!forwarder) return NS_ERROR_FAILURE; - NS_ADDREF(forwarder); - forwarder->Init(mChannel, mListener); - - rv = mDPipe->AsyncRead(forwarder, mListenerContext, 0, -1, 0, getter_AddRefs(mDPipeRequest)); - - NS_RELEASE(forwarder); // let the transport worry about this objects lifespan - return rv; + return mDPipe->AsyncRead(mListener, mListenerContext); } FTP_STATE @@ -1406,12 +1323,12 @@ nsFtpState::S_stor() { NS_ASSERTION(mWriteStream, "we're trying to upload without any data"); + rv = mDPipe->SetTransferCount(mWriteCount); if (NS_FAILED(rv)) return rv; mFireCallbacks = PR_FALSE; // observer callbacks will be handled by the transport. PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) writing on Data Transport\n", this)); - return NS_AsyncWriteFromStream(getter_AddRefs(mDPipeRequest), mDPipe, mWriteStream, - 0, mWriteCount, 0, mObserver, mObserverContext); + return NS_AsyncWriteFromStream(mDPipe, mWriteStream, mObserver, mObserverContext); } FTP_STATE @@ -1431,8 +1348,8 @@ nsFtpState::S_pasv() { // Find IPv6 socket address, if server is IPv6 mIPv6Checked = PR_TRUE; PR_ASSERT(mIPv6ServerAddress == 0); - nsCOMPtr controlSocket; - mControlConnection->GetTransport(getter_AddRefs(controlSocket)); + nsCOMPtr controlSocket; + mControlConnection->GetChannel(getter_AddRefs(controlSocket)); if (!controlSocket) return FTP_ERROR; nsCOMPtr sTrans = do_QueryInterface(controlSocket, &rv); @@ -1543,7 +1460,8 @@ nsFtpState::R_pasv() { const char* hostStr = mIPv6ServerAddress ? mIPv6ServerAddress : host.GetBuffer(); // now we know where to connect our data channel - rv = CreateTransport(hostStr, port, getter_AddRefs(mDPipe)); // the data channel + rv = CreateTransport(hostStr, port, mBufferSegmentSize, mBufferMaxSize, + getter_AddRefs(mDPipe)); // the data channel if (NS_FAILED(rv)) return FTP_ERROR; PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) Created Data Transport (%s:%d)\n", this, hostStr, port)); @@ -1554,16 +1472,12 @@ nsFtpState::R_pasv() { if (NS_FAILED(sTrans->SetReuseConnection(PR_FALSE))) return FTP_ERROR; // hook ourself up as a proxy for progress notifications - nsCOMPtr requestor(do_QueryInterface(mChannel)); - if (requestor) { - nsCOMPtr sink = do_GetInterface(requestor); - if (sink) - mDPipe->SetProgressEventSink(sink); - } + nsCOMPtr progressProxy(do_QueryInterface(mChannel)); + rv = mDPipe->SetNotificationCallbacks(progressProxy); + if (NS_FAILED(rv)) return FTP_ERROR; // we're connected figure out what type of transfer we're doing (ascii or binary) nsXPIDLCString type; - rv = mChannel->GetContentType(getter_Copies(type)); nsCAutoString typeStr; if (NS_FAILED(rv) || !type) @@ -1656,11 +1570,15 @@ nsFtpState::IsPending(PRBool *result) nsresult rv = NS_OK; *result = PR_FALSE; - nsCOMPtr request; - mControlConnection->GetReadRequest(getter_AddRefs(request)); + nsCOMPtr controlSocket; + mControlConnection->GetChannel(getter_AddRefs(controlSocket)); - if (request) { - rv = request->IsPending(result); + if (controlSocket) { + rv = controlSocket->IsPending(result); + if (NS_FAILED(rv)) return rv; + } + if (mDPipe) { + rv = mDPipe->IsPending(result); if (NS_FAILED(rv)) return rv; } return rv; @@ -1689,8 +1607,8 @@ nsFtpState::Cancel(nsresult status) mCanceled = PR_TRUE; // kill the data connection immediately. - if (mDPipeRequest) { - mDPipeRequest->Cancel(status); + if (mDPipe) { + mDPipe->Cancel(status); } return NS_OK; @@ -1707,18 +1625,15 @@ nsFtpState::Suspend(void) // enough. if (mSuspendCount < 1) { mSuspendCount++; + nsCOMPtr controlSocket; + mControlConnection->GetChannel(getter_AddRefs(controlSocket)); - // only worry about the read request. - nsCOMPtr request; - mControlConnection->GetReadRequest(getter_AddRefs(request)); - - if (request) { - rv = request->Suspend(); + if (controlSocket) { + rv = controlSocket->Suspend(); if (NS_FAILED(rv)) return rv; } - - if (mDPipeRequest) { - rv = mDPipeRequest->Suspend(); + if (mDPipe) { + rv = mDPipe->Suspend(); if (NS_FAILED(rv)) return rv; } } @@ -1735,16 +1650,16 @@ nsFtpState::Resume(void) // cause the FTP state machine to unblock and // go on about it's business. if (mSuspendCount) { - // only worry about the read request. - nsCOMPtr request; - mControlConnection->GetReadRequest(getter_AddRefs(request)); - - if (request) { - rv = request->Resume(); + // only a suspended thread can be resumed + nsCOMPtr controlSocket; + mControlConnection->GetChannel(getter_AddRefs(controlSocket)); + + if (controlSocket) { + rv = controlSocket->Resume(); if (NS_FAILED(rv)) return rv; } - if (mDPipeRequest) { - rv = mDPipeRequest->Resume(); + if (mDPipe) { + rv = mDPipe->Resume(); if (NS_FAILED(rv)) return rv; } rv = NS_OK; @@ -1755,15 +1670,20 @@ nsFtpState::Resume(void) nsresult nsFtpState::Init(nsIFTPChannel* aChannel, - nsIPrompt* aPrompter) { + nsIPrompt* aPrompter, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize) { nsresult rv = NS_OK; mKeepRunning = PR_TRUE; mPrompter = aPrompter; + mBufferSegmentSize = bufferSegmentSize; + mBufferMaxSize = bufferMaxSize; + // parameter validation - NS_ASSERTION(aChannel, "FTP: needs a channel"); + NS_ASSERTION(aChannel, "FTP: thread needs a channel"); mChannel = aChannel; // a straight com ptr to the channel @@ -1848,9 +1768,8 @@ nsFtpState::KillControlConnnection() { // if the control goes away, the data socket goes away... if (mDPipe) { - mDPipe->SetProgressEventSink(nsnull); + mDPipe->SetNotificationCallbacks(nsnull); mDPipe = 0; - mDPipeRequest = 0; } mIPv6Checked = PR_FALSE; @@ -1904,12 +1823,9 @@ nsFtpState::StopProcessing() { // Clean up the event loop mKeepRunning = PR_FALSE; - - nsCOMPtr request = do_QueryInterface(mChannel); - - if (NS_FAILED(mInternalError) && mChannel && request) { - if (request) - request->Cancel(mInternalError); + + if (NS_FAILED(mInternalError) && mChannel) { + mChannel->Cancel(mInternalError); } KillControlConnnection(); @@ -1923,7 +1839,7 @@ nsFtpState::StopProcessing() { // we only want to fire OnStop. No OnStart has been fired, and // we only want to propagate an error. - rv = asyncObserver->OnStopRequest(request, mObserverContext, mInternalError, nsnull); + rv = asyncObserver->OnStopRequest(mChannel, mObserverContext, mInternalError, nsnull); if (NS_FAILED(rv)) return rv; } @@ -1934,7 +1850,7 @@ nsFtpState::StopProcessing() { // we only want to fire OnStop. No OnStart has been fired, and // we only want to propagate an error. - rv = asyncListener->OnStopRequest(request, mListenerContext, mInternalError, nsnull); + rv = asyncListener->OnStopRequest(mChannel, mListenerContext, mInternalError, nsnull); if (NS_FAILED(rv)) return rv; } } @@ -1993,7 +1909,10 @@ nsFtpState::SetDirMIMEType(nsString& aString) { } nsresult -nsFtpState::CreateTransport(const char * host, PRInt32 port, nsITransport** o_pTrans) +nsFtpState::CreateTransport(const char * host, PRInt32 port, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans) { nsresult rv; @@ -2020,26 +1939,23 @@ nsFtpState::CreateTransport(const char * host, PRInt32 port, nsITransport** o_pT rv = channelProxy->GetProxyPort(&proxyPort); if (NS_FAILED(rv)) return rv; - + rv = channelProxy->GetProxyType(getter_Copies(proxyType)); if (NS_SUCCEEDED(rv) && nsCRT::strcasecmp(proxyType, "socks") == 0) { - return sts->CreateTransportOfType("socks", host, port, proxyHost, proxyPort, - FTP_COMMAND_CHANNEL_SEG_SIZE, - FTP_COMMAND_CHANNEL_MAX_SIZE, o_pTrans); + return sts->CreateTransportOfType("socks", host, port, proxyHost, proxyPort, bufferSegmentSize, + bufferMaxSize, o_pTrans); } - return sts->CreateTransport(host, port, proxyHost, proxyPort, - FTP_COMMAND_CHANNEL_SEG_SIZE, - FTP_COMMAND_CHANNEL_MAX_SIZE, o_pTrans); + return sts->CreateTransport(host, port, proxyHost, proxyPort, bufferSegmentSize, + bufferMaxSize, o_pTrans); } } - return sts->CreateTransport(host, port, nsnull, -1, - FTP_COMMAND_CHANNEL_SEG_SIZE, - FTP_COMMAND_CHANNEL_MAX_SIZE, o_pTrans); + return sts->CreateTransport(host, port, nsnull, -1, bufferSegmentSize, + bufferMaxSize, o_pTrans); } nsresult @@ -2047,17 +1963,6 @@ nsFtpState::ControlAsyncWrite(nsCString& command) { NS_ASSERTION(mControlConnection, "null control connection"); -#if defined(PR_LOGGING) - nsCString logString(command); - logString.ReplaceChar(CRLF, ' '); - PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) Writing \"%s\"\n", this, logString.GetBuffer())); - -#ifdef DEBUG_dougt -//printf("!!! %s\n", logString.GetBuffer()); -#endif - -#endif - if (mControlConnection) return mControlConnection->Write(command); return NS_ERROR_FAILURE; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h index 9db0e392ecb..ebd7207727a 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -40,7 +40,6 @@ #include "nsAutoLock.h" #include "nsIEventQueueService.h" #include "nsIPrompt.h" -#include "nsITransport.h" #include "nsFtpControlConnection.h" @@ -86,7 +85,7 @@ typedef enum _FTP_STATE { typedef enum _FTP_ACTION { GET, PUT, MKDIR, DEL} FTP_ACTION; class nsFtpState : public nsIStreamListener, - public nsIRequest { + public nsIRequest { public: NS_DECL_ISUPPORTS NS_DECL_NSISTREAMLISTENER @@ -96,7 +95,10 @@ public: nsFtpState(); virtual ~nsFtpState(); - nsresult Init(nsIFTPChannel *aChannel, nsIPrompt *aPrompter); + nsresult Init(nsIFTPChannel *aChannel, + nsIPrompt *aPrompter, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize); // use this to set an observer. nsresult SetStreamObserver(nsIStreamObserver *aObserver, nsISupports *aContext); @@ -141,7 +143,9 @@ private: nsresult Process(); virtual nsresult CreateTransport(const char * host, PRInt32 port, - nsITransport** o_pTrans); + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans); void KillControlConnnection(); nsresult StopProcessing(); @@ -161,8 +165,8 @@ private: // ****** channel/transport/stream vars nsFtpControlConnection* mControlConnection;// cacheable control connection (owns mCPipe) - nsCOMPtr mDPipe; // the data transport - nsCOMPtr mDPipeRequest; + nsCOMPtr mDPipe; // the data channel transport + // ****** consumer vars nsCOMPtr mListener; // the consumer of our read events nsCOMPtr mListenerContext; // the context we pass through our read events @@ -212,5 +216,7 @@ private: }; +#define NS_FTP_BUFFER_READ_SIZE (8*1024) +#define NS_FTP_BUFFER_WRITE_SIZE (8*1024) #endif //__nsFtpState__h_ diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp b/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp index b5ce505b84c..4547cb79dd9 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp @@ -25,7 +25,7 @@ #include "prlog.h" #include "nsIPipe.h" #include "nsIInputStream.h" -#include "nsIStreamProvider.h" +#include "nsNetUtil.h" #if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; @@ -35,19 +35,19 @@ class nsFtpStreamProvider : public nsIStreamProvider { public: NS_DECL_ISUPPORTS - nsFtpStreamProvider() { NS_INIT_ISUPPORTS(); } + nsFtpStreamProvider() { NS_INIT_REFCNT();} virtual ~nsFtpStreamProvider() {} // // nsIStreamObserver implementation ... // - NS_IMETHODIMP OnStartRequest(nsIRequest *req, nsISupports *ctxt) { return NS_OK; } - NS_IMETHODIMP OnStopRequest(nsIRequest *req, nsISupports *ctxt, nsresult status, const PRUnichar *statusText) { return NS_OK; } + NS_IMETHODIMP OnStartRequest(nsIChannel *chan, nsISupports *ctxt) { return NS_OK; } + NS_IMETHODIMP OnStopRequest(nsIChannel *chan, nsISupports *ctxt, nsresult status, const PRUnichar *statusText) { return NS_OK; } // // nsIStreamProvider implementation ... // - NS_IMETHODIMP OnDataWritable(nsIRequest *aRequest, nsISupports *aContext, + NS_IMETHODIMP OnDataWritable(nsIChannel *aChannel, nsISupports *aContext, nsIOutputStream *aOutStream, PRUint32 aOffset, PRUint32 aCount) { @@ -83,9 +83,9 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsFtpStreamProvider, // nsFtpControlConnection implementation ... // -NS_IMPL_THREADSAFE_QUERY_INTERFACE2(nsFtpControlConnection, - nsIStreamListener, - nsIStreamObserver); +NS_IMPL_THREADSAFE_QUERY_INTERFACE2(nsFtpControlConnection, + nsIStreamListener, + nsIStreamObserver) NS_IMPL_THREADSAFE_ADDREF(nsFtpControlConnection); nsrefcnt nsFtpControlConnection::Release(void) @@ -110,7 +110,7 @@ nsrefcnt nsFtpControlConnection::Release(void) return count; } -nsFtpControlConnection::nsFtpControlConnection(nsITransport* socketTransport) +nsFtpControlConnection::nsFtpControlConnection(nsIChannel* socketTransport) : mCPipe(socketTransport) { NS_INIT_REFCNT(); @@ -154,17 +154,11 @@ nsFtpControlConnection::Connect() NS_STATIC_CAST(nsFtpStreamProvider*, NS_STATIC_CAST(nsIStreamProvider*, provider))->mInStream = inStream; - rv = mCPipe->AsyncWrite(provider, - NS_STATIC_CAST(nsISupports*, this), - 0, 0, 0, - getter_AddRefs(mWriteRequest)); + rv = mCPipe->AsyncWrite(provider, NS_STATIC_CAST(nsISupports*, this)); if (NS_FAILED(rv)) return rv; // get the ball rolling by reading on the control socket. - rv = mCPipe->AsyncRead(NS_STATIC_CAST(nsIStreamListener*, this), - nsnull, 0, -1, 0, - getter_AddRefs(mReadRequest)); - + rv = mCPipe->AsyncRead(NS_STATIC_CAST(nsIStreamListener*, this), nsnull); if (NS_FAILED(rv)) return rv; mConnected = PR_TRUE; @@ -178,8 +172,7 @@ nsFtpControlConnection::Disconnect() PR_LOG(gFTPLog, PR_LOG_ALWAYS, ("(%x) nsFtpControlConnection disconnecting", this)); mConnected = PR_FALSE; - if (mWriteRequest) mWriteRequest->Cancel(NS_BINDING_ABORTED); - if (mReadRequest) mReadRequest->Cancel(NS_BINDING_ABORTED); + if (mCPipe) mCPipe->Cancel(NS_BINDING_ABORTED); return NS_OK; } @@ -188,6 +181,11 @@ nsFtpControlConnection::Write(nsCString& command) { if (!mConnected) return NS_ERROR_FAILURE; +#if defined(PR_LOGGING) + nsCString logString(command); + logString.ReplaceChar(CRLF, ' '); + PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) Writing \"%s\"\n", this, logString.GetBuffer())); +#endif PRUint32 len = command.Length(); PRUint32 cnt; @@ -195,7 +193,7 @@ nsFtpControlConnection::Write(nsCString& command) if (NS_SUCCEEDED(rv) && len==cnt) { if (mSuspendedWrite) { mSuspendedWrite = PR_FALSE; - mWriteRequest->Resume(); + mCPipe->Resume(); } return NS_OK; } @@ -205,9 +203,9 @@ nsFtpControlConnection::Write(nsCString& command) } nsresult -nsFtpControlConnection::GetTransport(nsITransport** controlTransport) +nsFtpControlConnection::GetChannel(nsIChannel** controlChannel) { - NS_IF_ADDREF(*controlTransport = mCPipe); + NS_IF_ADDREF(*controlChannel = mCPipe); return NS_OK; } @@ -220,7 +218,7 @@ nsFtpControlConnection::SetStreamListener(nsIStreamListener *aListener) } NS_IMETHODIMP -nsFtpControlConnection::OnStartRequest(nsIRequest *request, nsISupports *aContext) +nsFtpControlConnection::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { if (!mConnected) return NS_OK; @@ -237,11 +235,11 @@ nsFtpControlConnection::OnStartRequest(nsIRequest *request, nsISupports *aContex if (!myListener) return NS_OK; - return myListener->OnStartRequest(request, aContext); + return myListener->OnStartRequest(aChannel, aContext); } NS_IMETHODIMP -nsFtpControlConnection::OnStopRequest(nsIRequest *request, nsISupports *aContext, +nsFtpControlConnection::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { @@ -260,12 +258,12 @@ nsFtpControlConnection::OnStopRequest(nsIRequest *request, nsISupports *aContext if (!myListener) return NS_OK; - return myListener->OnStopRequest(request, aContext, aStatus, aStatusArg); + return myListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } NS_IMETHODIMP -nsFtpControlConnection::OnDataAvailable(nsIRequest *request, +nsFtpControlConnection::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aInStream, PRUint32 aOffset, @@ -281,6 +279,6 @@ nsFtpControlConnection::OnDataAvailable(nsIRequest *request, if (!myListener) return NS_OK; - return myListener->OnDataAvailable(request, aContext, aInStream, + return myListener->OnDataAvailable(aChannel, aContext, aInStream, aOffset, aCount); } diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.h b/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.h index 9ef86f458e9..cf2c7bf7507 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.h @@ -27,7 +27,7 @@ #include "nsIStreamListener.h" #include "nsIRequest.h" -#include "nsITransport.h" +#include "nsIChannel.h" #include "nsString.h" #include "nsIOutputStream.h" #include "nsAutoLock.h" @@ -39,18 +39,15 @@ public: NS_DECL_NSISTREAMLISTENER NS_DECL_NSISTREAMOBSERVER - nsFtpControlConnection(nsITransport* socketTransport); + nsFtpControlConnection(nsIChannel* socketTransport); virtual ~nsFtpControlConnection(); nsresult Connect(); nsresult Disconnect(); nsresult Write(nsCString& command); PRBool IsConnected() { return mConnected; } - - void GetReadRequest(nsIRequest** request) { NS_ADDREF(*request=mReadRequest); } - void GetWriteRequest(nsIRequest** request) { NS_ADDREF(*request=mWriteRequest); } - - nsresult GetTransport(nsITransport** controlTransport); + + nsresult GetChannel(nsIChannel** controlChannel); nsresult SetStreamListener(nsIStreamListener *aListener); PRUint32 mServerType; // what kind of server is it. @@ -62,14 +59,10 @@ public: private: PRLock* mLock; // protects mListener. - - nsCOMPtr mReadRequest; - nsCOMPtr mWriteRequest; - nsCOMPtr mCPipe; - nsCOMPtr mOutStream; + nsCOMPtr mCPipe; + nsCOMPtr mOutStream; nsCOMPtr mListener; - PRPackedBool mConnected; - PRPackedBool mWriteSuspened; + PRBool mConnected; }; diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl index ce2ed64de97..99cedbf944d 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl @@ -119,9 +119,9 @@ interface nsIHTTPChannel : nsIChannel /** * This is a kludge which tells the channel to create a separate thread with the - * even queue for Open() or not + * even queue for OpenInputStream or not */ - attribute boolean openHasEventQueue; + attribute boolean openInputStreamHasEventQueue; }; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index 505471607ca..62f55a09a87 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -80,7 +80,7 @@ extern PRLogModuleInfo* gHTTPLog; nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL, nsHTTPHandler* i_Handler): mResponse(nsnull), mHandler(dont_QueryInterface(i_Handler)), - mRequest(nsnull), + mRequest (nsnull), mHTTPServerListener(nsnull), mResponseContext(nsnull), mCachedResponse(nsnull), @@ -93,18 +93,20 @@ nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL, nsHTTPHandler* i_Handler): mCachedContentIsValid(PR_FALSE), mFiredOnHeadersAvailable(PR_FALSE), mFiredOpenOnStartRequest(PR_FALSE), - mFiredOpenOnStopRequest(PR_FALSE), + mFiredOpenOnStopRequest (PR_FALSE), mAuthTriedWithPrehost(PR_FALSE), mAuthRealm(nsnull), mProxy(0), mProxyPort(-1), mProxyType(nsnull), mProxyTransparent(PR_FALSE), + mBufferSegmentSize(0), + mBufferMaxSize(0), mStatus(NS_OK), - mPipeliningAllowed(PR_TRUE), - mPipelinedRequest(nsnull), + mPipeliningAllowed (PR_TRUE), + mPipelinedRequest (nsnull), mApplyConversion(PR_TRUE), - mOpenHasEventQueue(PR_TRUE) + mOpenInputStreamHasEventQueue (PR_TRUE) { NS_INIT_REFCNT(); NS_NewISupportsArray(getter_AddRefs(mStreamAsFileObserverArray)); @@ -246,25 +248,25 @@ nsHTTPChannel::SetURI(nsIURI* o_URL) } NS_IMETHODIMP -nsHTTPChannel::GetOpenHasEventQueue (PRBool * hasEventQueue) +nsHTTPChannel::GetOpenInputStreamHasEventQueue (PRBool * hasEventQueue) { if (!hasEventQueue) return NS_ERROR_NULL_POINTER; - *hasEventQueue = mOpenHasEventQueue; + *hasEventQueue = mOpenInputStreamHasEventQueue; return NS_OK; } NS_IMETHODIMP -nsHTTPChannel::SetOpenHasEventQueue (PRBool hasEventQueue) +nsHTTPChannel::SetOpenInputStreamHasEventQueue (PRBool hasEventQueue) { - mOpenHasEventQueue = hasEventQueue; + mOpenInputStreamHasEventQueue = hasEventQueue; return NS_OK; } NS_IMETHODIMP -nsHTTPChannel::Open(nsIInputStream **o_Stream) +nsHTTPChannel::OpenInputStream(nsIInputStream **o_Stream) { nsresult rv; if (mConnected) return NS_ERROR_ALREADY_CONNECTED; @@ -278,26 +280,34 @@ nsHTTPChannel::Open(nsIInputStream **o_Stream) if (NS_FAILED(rv)) return rv; - if (mOpenHasEventQueue) { - rv = AsyncOpen(listener, nsnull); + if (mOpenInputStreamHasEventQueue) + { + rv = AsyncRead (listener, nsnull); return rv; } - nsSyncHelper *helper = new nsSyncHelper(); + nsSyncHelper *helper = new nsSyncHelper (); if (!helper) return NS_ERROR_OUT_OF_MEMORY; - rv = helper->Init(NS_STATIC_CAST (nsIChannel*, this), listener); + rv = helper -> Init (NS_STATIC_CAST (nsIChannel*, this), listener); if (NS_FAILED(rv)) return rv; // spin up a new helper thread. nsCOMPtr helperThread; - return NS_NewThread(getter_AddRefs(helperThread), NS_STATIC_CAST(nsIRunnable*, helper)); + return NS_NewThread (getter_AddRefs(helperThread), NS_STATIC_CAST(nsIRunnable*, helper)); } NS_IMETHODIMP -nsHTTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) +nsHTTPChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("nsHTTPChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *aContext) { nsresult rv = NS_OK; @@ -322,7 +332,7 @@ nsHTTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) mResponseContext = aContext; - Begin(); + Open(); // If the data in the cache hasn't expired, then there's no need to talk // with the server. Create a stream from the cache, synthesizing all the @@ -330,9 +340,37 @@ nsHTTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) if (mCachedContentIsValid) { ReadFromCache(); } + return rv; } +NS_IMETHODIMP +nsHTTPChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + NS_NOTREACHED("nsHTTPChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +#if 0 + nsresult rv = NS_OK; + + // parameter validation + if (!fromStream) return NS_ERROR_NULL_POINTER; + // currently we are allowing a null observer... fire and forget... + + if (mResponseDataListener) { + return NS_ERROR_IN_PROGRESS; // too late... + } + + mResponseContext = ctxt; + mRequestStream = fromStream; + mWriteObserver = observer; + + Open(); + + return rv; +#endif +} + NS_IMETHODIMP nsHTTPChannel::GetLoadAttributes(PRUint32 *aLoadAttributes) { @@ -442,6 +480,89 @@ nsHTTPChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsHTTPChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsHTTPChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTTPChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsHTTPChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTTPChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsHTTPChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTTPChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsHTTPChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsHTTPChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::GetLocalFile(nsIFile* *file) +{ + nsresult rv; + rv = GetFile(file); + if (NS_FAILED(rv)) + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + if (aPipeliningAllowed == NULL) + return NS_ERROR_NULL_POINTER; + + *aPipeliningAllowed = mPipeliningAllowed; + return NS_OK; +} + +NS_IMETHODIMP +nsHTTPChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + mPipeliningAllowed = aPipeliningAllowed; + return NS_OK; +} + NS_IMETHODIMP nsHTTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup) { @@ -494,18 +615,25 @@ nsHTTPChannel::SetNotificationCallbacks(nsIInterfaceRequestor* mCallbacks = aNotificationCallbacks; // Verify that the event sink is http - if (mCallbacks) { - mRealEventSink = do_GetInterface(mCallbacks); - mRealPrompter = do_GetInterface(mCallbacks); - mRealProgressEventSink = do_GetInterface(mCallbacks); + if (mCallbacks) + { + mCallbacks -> GetInterface (NS_GET_IID(nsIHTTPEventSink), + getter_AddRefs(mRealEventSink)); + + mCallbacks -> GetInterface(NS_GET_IID(nsIPrompt), + getter_AddRefs(mRealPrompter)); + + mCallbacks -> GetInterface (NS_GET_IID(nsIProgressEventSink), + getter_AddRefs(mRealProgressEventSink)); - rv = BuildNotificationProxies(); + rv = BuildNotificationProxies (); + } return rv; } nsresult -nsHTTPChannel::BuildNotificationProxies() +nsHTTPChannel::BuildNotificationProxies () { nsresult rv = NS_OK; @@ -516,11 +644,11 @@ nsHTTPChannel::BuildNotificationProxies() nsCOMPtr eventQ; - rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ)); + rv = eventQService -> GetThreadEventQueue (NS_CURRENT_THREAD, getter_AddRefs (eventQ)); if (NS_FAILED (rv)) return rv; - NS_WITH_SERVICE(nsIProxyObjectManager, proxyManager, kProxyObjectManagerCID, &rv); + NS_WITH_SERVICE ( nsIProxyObjectManager, proxyManager, kProxyObjectManagerCID, &rv); if (NS_FAILED(rv)) return rv; @@ -586,7 +714,7 @@ NS_IMETHODIMP nsHTTPChannel::GetResponseHeader(nsIAtom* i_Header, char* *o_Value) { if (!mConnected) - Begin(); + Open(); if (mResponse) return mResponse->GetHeader(i_Header, o_Value); else @@ -600,7 +728,7 @@ nsHTTPChannel::GetResponseHeaderEnumerator(nsISimpleEnumerator** aResult) nsresult rv; if (!mConnected) { - Begin(); + Open(); } if (mResponse) { @@ -617,7 +745,7 @@ nsHTTPChannel::SetResponseHeader(nsIAtom* i_Header, const char* i_HeaderValue) { nsresult rv = NS_OK; if (!mConnected) { - rv = Begin(); + rv = Open(); if (NS_FAILED(rv)) return rv; } @@ -639,7 +767,7 @@ NS_IMETHODIMP nsHTTPChannel::GetResponseStatus(PRUint32 *o_Status) { if (!mConnected) - Begin(); + Open(); if (mResponse) return mResponse->GetStatus(o_Status); return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ? @@ -649,7 +777,7 @@ NS_IMETHODIMP nsHTTPChannel::GetResponseString(char* *o_String) { if (!mConnected) - Begin(); + Open(); if (mResponse) return mResponse->GetStatusString(o_String); return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ? @@ -766,7 +894,7 @@ nsHTTPChannel::GetInterface(const nsIID &anIID, void **aResult ) // nsIProgressEventSink methods NS_IMETHODIMP -nsHTTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext, +nsHTTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -777,7 +905,7 @@ nsHTTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext, } NS_IMETHODIMP -nsHTTPChannel::OnProgress(nsIRequest *request, nsISupports* aContext, +nsHTTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { // These progreess notifications are coming from the raw socket and are not // as interesting as the progress of HTTP channel (pushing the real data @@ -797,7 +925,7 @@ nsresult nsHTTPChannel::Init() Set up a request object - later set to a clone of a default request from the handler. TODO */ - mRequest = new nsHTTPRequest(mURI, mHandler); + mRequest = new nsHTTPRequest(mURI, mHandler, mBufferSegmentSize, mBufferMaxSize); if (!mRequest) { return NS_ERROR_OUT_OF_MEMORY; } @@ -887,10 +1015,10 @@ nsHTTPChannel::CheckCache() } // Hook up stream as listener - nsCOMPtr streamAsFile(do_QueryInterface(mCacheEntry)); - if (streamAsFile) + nsCOMPtr streamAsFile( do_QueryInterface( mCacheEntry ) ); + if ( streamAsFile ) { - nsCOMPtr observer; + nsCOMPtr< nsIStreamAsFileObserver> observer; PRUint32 count = 0; mStreamAsFileObserverArray->Count( & count ); for ( PRUint32 i=0; i< count; i++ ) @@ -898,6 +1026,7 @@ nsHTTPChannel::CheckCache() mStreamAsFileObserverArray->GetElementAt( i, getter_AddRefs( observer ) ); streamAsFile->AddObserver( observer ); } + } // Be pessimistic: Assume cache entry has no useful data @@ -949,7 +1078,7 @@ nsHTTPChannel::CheckCache() return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mCachedResponse); nsSubsumeCStr cachedHeadersCStr(NS_CONST_CAST(char*, - NS_STATIC_CAST(const char*, cachedHeaders)), + NS_STATIC_CAST(const char*, cachedHeaders)), PR_FALSE); rv = mCachedResponse->ParseHeaders(cachedHeadersCStr); if (NS_FAILED(rv)) return rv; @@ -1105,18 +1234,15 @@ nsHTTPChannel::ReadFromCache() #endif /* PR_LOGGING */ // Create a cache transport to read the cached response... - rv = mCacheEntry->NewTransport(mLoadGroup, getter_AddRefs(mCacheTransport)); + rv = mCacheEntry->NewChannel(mLoadGroup, getter_AddRefs(mCacheTransport)); if (NS_FAILED(rv)) return rv; -// XXX Transports do not have load attributes -#if 0 // // Propagate the load attributes of this channel into the cache channel. // This will ensure that notifications are suppressed if necessary. // rv = mCacheTransport->SetLoadAttributes(mLoadAttributes); if (NS_FAILED(rv)) return rv; -#endif // Fake it so that HTTP headers come from cached versions SetResponse(mCachedResponse); @@ -1136,8 +1262,7 @@ nsHTTPChannel::ReadFromCache() FinishedResponseHeaders(); // Pump the cache data downstream - nsCOMPtr request; - rv = mCacheTransport->AsyncRead(listener, mResponseContext, 0, -1, 0, getter_AddRefs(request)); + rv = mCacheTransport->AsyncRead(listener, mResponseContext); NS_RELEASE(listener); if (NS_FAILED(rv)) { ResponseCompleted(nsnull, rv, nsnull); @@ -1331,7 +1456,7 @@ nsHTTPChannel::CacheReceivedResponse(nsIStreamListener *aListener, } nsresult -nsHTTPChannel::Begin(PRBool bIgnoreCache) +nsHTTPChannel::Open(PRBool bIgnoreCache) { if (mConnected || (mState > HS_WAITING_FOR_OPEN)) return NS_ERROR_ALREADY_CONNECTED; @@ -1343,7 +1468,7 @@ nsHTTPChannel::Begin(PRBool bIgnoreCache) // If this is the first time, then add the channel to its load group if (mState == HS_IDLE) { if (mLoadGroup) - mLoadGroup->AddRequest(this, nsnull); + mLoadGroup->AddChannel(this, nsnull); // See if there's a cache entry for the given URL if (!bIgnoreCache) @@ -1564,10 +1689,8 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, rv = serv->NewURI(aNewLocation, mURI, getter_AddRefs(newURI)); if (NS_FAILED(rv)) return rv; - -// removing redirect.xul for loop. bugs 44153, 56523, 58658 -// XXX This is broken #if 0 +// removing redirect.xul for loop. bugs 44153, 56523, 58658 nsXPIDLCString spec1; nsXPIDLCString spec2; @@ -1602,6 +1725,7 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, nsXPIDLCString baseref; nsCOMPtr baseurl; + baseurl = do_QueryInterface(mURI, &rv); if (NS_SUCCEEDED(rv)) { @@ -1643,18 +1767,18 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, loadFlags |= nsIChannel::LOAD_REPLACE; rv = NS_OpenURI(getter_AddRefs(channel), newURI, serv, mLoadGroup, - mCallbacks, loadFlags); + mCallbacks, loadFlags, + mBufferSegmentSize, mBufferMaxSize); if (NS_FAILED(rv)) return rv; rv = channel->SetOriginalURI(mOriginalURI); if (NS_FAILED(rv)) return rv; if (mLoadGroup) { - nsCOMPtr tempRequest; - rv = mLoadGroup->GetDefaultLoadRequest(getter_AddRefs(tempRequest)); + nsCOMPtr tempChannel; + rv = mLoadGroup->GetDefaultLoadChannel(getter_AddRefs(tempChannel)); if (NS_SUCCEEDED(rv)) { - nsCOMPtr tempChannel = do_QueryInterface(tempRequest); if (tempChannel == this) { - mLoadGroup->SetDefaultLoadRequest(channel); + mLoadGroup->SetDefaultLoadChannel(channel); } } } @@ -1682,9 +1806,9 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, { // Start the redirect... nsIStreamListener *sl = mResponseDataListener; - nsHTTPFinalListener *fl = NS_STATIC_CAST(nsHTTPFinalListener*, sl); - rv = channel->AsyncOpen(fl->GetListener(), mResponseContext); - fl->Shutdown(); + nsHTTPFinalListener *fl = NS_STATIC_CAST (nsHTTPFinalListener*, sl); + rv = channel->AsyncRead(fl -> GetListener (), mResponseContext); + fl -> Shutdown (); } else rv = NS_ERROR_FAILURE; @@ -1703,7 +1827,9 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, // mResponseDataListener = 0; - NS_ADDREF(*aResult = channel); + *aResult = channel; + NS_ADDREF(*aResult); + return rv; } @@ -1823,7 +1949,7 @@ nsresult nsHTTPChannel::ResponseCompleted(nsIStreamListener *aListener, // if (mLoadGroup) - mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); + mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); // Null out pointers that are no longer needed... @@ -2152,7 +2278,8 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth) // This smells like a clone function... maybe there is a // benefit in doing that, think. TODO. rv = NS_OpenURI(&channel, // delibrately... - mURI, serv, mLoadGroup, mCallbacks, mLoadAttributes); + mURI, serv, mLoadGroup, mCallbacks, + mLoadAttributes, mBufferSegmentSize, mBufferMaxSize); if (NS_FAILED(rv)) return rv; rv = channel->SetOriginalURI(mOriginalURI); if (NS_FAILED(rv)) return rv; @@ -2179,8 +2306,7 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth) // Fire the new request... nsIStreamListener *sl = mResponseDataListener; nsHTTPFinalListener *fl = NS_STATIC_CAST (nsHTTPFinalListener*, sl); - nsCOMPtr request; - rv = channel->AsyncOpen(fl->GetListener (), mResponseContext); + rv = channel->AsyncRead(fl -> GetListener (), mResponseContext); } else rv = NS_ERROR_FAILURE; @@ -2463,23 +2589,24 @@ nsHTTPChannel::ProcessNotModifiedResponse(nsIStreamListener *aListener) SetResponse(mCachedResponse); // Create a cache transport to read the cached response... - rv = mCacheEntry->NewTransport(mLoadGroup, getter_AddRefs(mCacheTransport)); + rv = mCacheEntry->NewChannel(mLoadGroup, getter_AddRefs(mCacheTransport)); if (NS_FAILED (rv)) return rv; - // Set StreamAsFileObserver - nsCOMPtr streamAsFile = do_QueryInterface(mCacheTransport); - if (streamAsFile) - { - nsCOMPtr< nsIStreamAsFileObserver> observer; - PRUint32 count = 0; - mStreamAsFileObserverArray->Count( & count ); - for ( PRUint32 i=0; i< count; i++ ) - { - mStreamAsFileObserverArray->GetElementAt( i, getter_AddRefs( observer ) ); - streamAsFile->AddObserver( observer ); - } - - } + + // Set StreamAsFileObserver + nsCOMPtr streamAsFile( do_QueryInterface( mCacheTransport ) ); + if ( streamAsFile ) + { + nsCOMPtr< nsIStreamAsFileObserver> observer; + PRUint32 count = 0; + mStreamAsFileObserverArray->Count( & count ); + for ( PRUint32 i=0; i< count; i++ ) + { + mStreamAsFileObserverArray->GetElementAt( i, getter_AddRefs( observer ) ); + streamAsFile->AddObserver( observer ); + } + + } // Create a new HTTPCacheListener... nsHTTPResponseListener *cacheListener; @@ -2492,9 +2619,7 @@ nsHTTPChannel::ProcessNotModifiedResponse(nsIStreamListener *aListener) cacheListener->SetListener(aListener); mResponseDataListener = 0/* aListener */; - nsCOMPtr request; - rv = mCacheTransport->AsyncRead(cacheListener, mResponseContext, - 0, -1, 0, getter_AddRefs(request)); + rv = mCacheTransport->AsyncRead(cacheListener, mResponseContext); if (NS_FAILED(rv)) { ResponseCompleted(cacheListener, rv, nsnull); } @@ -2719,7 +2844,7 @@ nsHTTPChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) if (mRequest) { - nsCOMPtr trans; + nsCOMPtr trans; mRequest->GetTransport(getter_AddRefs(trans)); if (trans) @@ -2836,8 +2961,7 @@ nsSyncHelper::Run() // initiate the AsyncRead from this thread so events are // sent here for processing. - - rv = mChannel->AsyncOpen(this, nsnull); + rv = mChannel->AsyncRead(this, nsnull); if (NS_FAILED(rv)) return rv; // process events until we're finished. @@ -2859,29 +2983,29 @@ nsSyncHelper::Run() // nsIStreamListener implementation NS_IMETHODIMP -nsSyncHelper::OnDataAvailable(nsIRequest *request, +nsSyncHelper::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aInStream, PRUint32 aOffset, PRUint32 aCount) { - return mListener->OnDataAvailable(request, aContext, aInStream, + return mListener->OnDataAvailable(aChannel, aContext, aInStream, aOffset, aCount); } // nsIStreamObserver implementation NS_IMETHODIMP -nsSyncHelper::OnStartRequest(nsIRequest *request, nsISupports *aContext) +nsSyncHelper::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { - return mListener->OnStartRequest(request, aContext); + return mListener->OnStartRequest(aChannel, aContext); } NS_IMETHODIMP -nsSyncHelper::OnStopRequest(nsIRequest *request, nsISupports *aContext, +nsSyncHelper::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { mProcessing = PR_FALSE; - return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } @@ -2893,7 +3017,7 @@ nsSyncHelper::nsSyncHelper() } nsresult -nsSyncHelper::Init (nsIChannel* aChannel, +nsSyncHelper::Init (nsIChannel *aChannel, nsIStreamListener* aListener) { if (!aChannel || !aListener) diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h index 92b48133a00..f68b7c5ccec 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h @@ -27,7 +27,6 @@ #include "nsIHTTPChannel.h" #include "nsIChannel.h" -#include "nsITransport.h" #include "nsHTTPEnums.h" #include "nsIURI.h" #include "nsHTTPHandler.h" @@ -46,7 +45,6 @@ #include "nsIPrompt.h" #include "nsIHTTPEventSink.h" #include "nsIStreamAsFile.h" - class nsIFile; class nsHTTPRequest; @@ -90,13 +88,13 @@ public: NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIPROGRESSEVENTSINK NS_DECL_NSIPROXY - NS_DECL_NSISTREAMASFILE + NS_DECL_NSISTREAMASFILE // nsHTTPChannel methods: nsresult Authenticate(const char *iChallenge, PRBool bProxyAuth = PR_FALSE); nsresult Init(); - nsresult Begin(PRBool bIgnoreCache=PR_FALSE); + nsresult Open(PRBool bIgnoreCache=PR_FALSE); nsresult Redirect(const char *aURL, nsIChannel **aResult, PRInt32 aStatusCode); @@ -194,9 +192,11 @@ protected: // (such as socks) we want to reverse conditional proxy behavior PRBool mProxyTransparent; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; nsresult mStatus; - nsCOMPtr mCacheTransport; + nsCOMPtr mCacheTransport; PRBool mPipeliningAllowed; nsHTTPPipelinedRequest* mPipelinedRequest; @@ -204,7 +204,7 @@ protected: // Stream as file nsCOMPtr mStreamAsFileObserverArray; PRBool mApplyConversion; - PRBool mOpenHasEventQueue; + PRBool mOpenInputStreamHasEventQueue; }; #include "nsIRunnable.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp index 65c1d9bd698..e2e3b554361 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp @@ -858,7 +858,9 @@ nsHTTPHandler::~nsHTTPHandler() nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, nsHTTPChannel* i_Channel, - nsITransport** o_pTrans, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans, PRUint32 flags) { nsresult rv; @@ -905,7 +907,7 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, if (port == -1) GetDefaultPort (&port); - nsCOMPtr trans; + nsCOMPtr trans; // Check in the idle transports for a host/port match count = 0; @@ -920,8 +922,8 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, { for (index = count - 1; index >= 0; --index) { - nsCOMPtr cTrans = - dont_AddRef ((nsITransport*) mIdleTransports->ElementAt(index)); + nsCOMPtr cTrans = + dont_AddRef ((nsIChannel*) mIdleTransports->ElementAt(index)); if (cTrans) { @@ -942,20 +944,18 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, for (index = count - 1; index >= 0; --index) { nsCOMPtr uri; - nsCOMPtr cTrans = - dont_AddRef ((nsITransport*) mIdleTransports->ElementAt(index) ); - - nsCOMPtr socketTrans = do_QueryInterface(cTrans); + nsCOMPtr cTrans = dont_AddRef ((nsIChannel*) mIdleTransports->ElementAt(index) ); - if (socketTrans) + if (cTrans && + (NS_SUCCEEDED (cTrans->GetURI(getter_AddRefs(uri))))) { nsXPIDLCString idlehost; - if (NS_SUCCEEDED (socketTrans->GetHost(getter_Copies(idlehost)))) + if (NS_SUCCEEDED (uri->GetHost(getter_Copies(idlehost)))) { if (!PL_strcasecmp (usingProxy ? proxy : host, idlehost)) { PRInt32 idleport; - if (NS_SUCCEEDED (socketTrans->GetPort(&idleport))) + if (NS_SUCCEEDED (uri->GetPort(&idleport))) { if (idleport == -1) GetDefaultPort (&idleport); @@ -1004,12 +1004,16 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, port, proxy, proxyPort, + bufferSegmentSize, + bufferMaxSize, getter_AddRefs(trans) ); } else { rv = CreateTransport( host, port, proxy, proxyPort, + bufferSegmentSize, + bufferMaxSize, getter_AddRefs(trans) ); } @@ -1043,9 +1047,12 @@ nsresult nsHTTPHandler::CreateTransport(const char* host, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - nsITransport** o_pTrans) + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans) { - return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, o_pTrans); + return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, + bufferSegmentSize, bufferMaxSize, o_pTrans); } nsresult nsHTTPHandler::CreateTransportOfType(const char* type, @@ -1053,7 +1060,9 @@ nsresult nsHTTPHandler::CreateTransportOfType(const char* type, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - nsITransport** o_pTrans) + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans) { nsresult rv; @@ -1066,8 +1075,8 @@ nsresult nsHTTPHandler::CreateTransportOfType(const char* type, port, proxyHost, proxyPort, - HTTP_DEFAULT_SEGMENT_SIZE, - HTTP_DEFAULT_BUFFER_SIZE, + bufferSegmentSize, + bufferMaxSize, o_pTrans); return rv; @@ -1076,7 +1085,7 @@ nsresult nsHTTPHandler::CreateTransportOfType(const char* type, static PRUint32 sMaxKeepAlives = 0; nsresult -nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , +nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , PRUint32 aCapabilities, PRBool aDontRestartChannels, PRUint32 aKeepAliveTimeout, @@ -1112,11 +1121,12 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , PRInt32 port = -1; nsXPIDLCString host; - // Get the address of the socket transport + i_pTrans->GetURI (getter_AddRefs (uri)); + + if (uri) { - nsCOMPtr socketTrans = do_QueryInterface(i_pTrans); - socketTrans->GetHost(getter_Copies(host)); - socketTrans->GetPort(&port); + uri->GetHost (getter_Copies (host)); + uri->GetPort (&port); } if (port == -1) GetDefaultPort (&port); @@ -1136,7 +1146,7 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , for (index = count - 1; index >= 0; --index) { - nsCOMPtr cTrans = dont_AddRef ((nsITransport*) mIdleTransports->ElementAt (index) ); + nsCOMPtr cTrans = dont_AddRef ((nsIChannel*) mIdleTransports->ElementAt (index) ); if (cTrans) { @@ -1149,19 +1159,23 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , else if (capabilities & (ALLOW_KEEPALIVE|ALLOW_PROXY_KEEPALIVE)) { - PRInt32 lPort = -1; - nsXPIDLCString lHost; + cTrans->GetURI (getter_AddRefs (uri)); + if (uri) + { + PRInt32 lPort = -1; + nsXPIDLCString lHost; - sTrans->GetHost (getter_Copies (lHost)); - sTrans->GetPort (&lPort); - if (lPort == -1) - GetDefaultPort (&lPort); + uri->GetHost (getter_Copies (lHost)); + uri->GetPort (&lPort); + if (lPort == -1) + GetDefaultPort (&lPort); - if (lHost && !PL_strcasecmp(lHost, host) && lPort == port) - keepAliveMaxCon++; + if (lHost && !PL_strcasecmp (lHost, host) && lPort == port) + keepAliveMaxCon++; - if (keepAliveMaxCon >= aKeepAliveMaxCon) - mIdleTransports->RemoveElement(cTrans); + if (keepAliveMaxCon >= aKeepAliveMaxCon) + mIdleTransports->RemoveElement (cTrans); + } } /* IsAlive */ } /* cTrans */ } /* for */ @@ -1169,12 +1183,12 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , if (capabilities & (ALLOW_KEEPALIVE|ALLOW_PROXY_KEEPALIVE)) { - nsCOMPtr sTrans = do_QueryInterface (i_pTrans, &rv); + nsCOMPtr trans = do_QueryInterface (i_pTrans, &rv); if (NS_SUCCEEDED (rv)) { PRBool alive = PR_FALSE; - rv = sTrans->IsAlive(0, &alive); + rv = trans->IsAlive(0, &alive); if (NS_SUCCEEDED (rv) && alive) { @@ -1188,8 +1202,8 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , NS_ASSERTION(added, "Failed to add a socket to idle transports list!"); - sTrans->SetReuseConnection(PR_TRUE); - sTrans->SetIdleTimeout(aKeepAliveTimeout); + trans->SetReuseConnection(PR_TRUE); + trans->SetIdleTimeout(aKeepAliveTimeout); mIdleTransports->Count(&count); if (count > sMaxKeepAlives) @@ -1204,7 +1218,7 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , // to the transport and the transport which references the HTTPChannel // through the event sink... // - rv = i_pTrans->SetProgressEventSink(nsnull); + rv = i_pTrans->SetNotificationCallbacks(nsnull); rv = mTransportList->RemoveElement(i_pTrans); NS_ASSERTION(NS_SUCCEEDED(rv), "Transport not in table..."); @@ -1239,7 +1253,7 @@ nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , PR_LOG (gHTTPLog, PR_LOG_ALWAYS, ("nsHTTPHandler::ReleaseTransport." "\tRestarting nsHTTPChannel [%x]\n", channel)); - channel->Begin(); + channel->Open(); } return rv; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h index 0de89dca078..f73ad2fea92 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h @@ -52,7 +52,6 @@ //Forward decl. class nsHashtable; class nsHTTPChannel; -class nsITransport; #define TRANSPORT_REUSE_ALIVE 1 #define TRANSPORT_OPEN_ALWAYS 2 @@ -71,10 +70,6 @@ class nsITransport; #define DEFAULT_MAX_ALLOWED_KEEPALIVES_PER_SERVER 8 #define DEFAULT_PIPELINE_MAX_REQUESTS 4 -// xxx fix need to tune -#define HTTP_DEFAULT_SEGMENT_SIZE 4096 -#define HTTP_DEFAULT_BUFFER_SIZE (1024*1024) - typedef struct BrokenServersTable_s { const char *serverHeader; @@ -102,7 +97,9 @@ public: */ virtual nsresult RequestTransport(nsIURI *i_Uri, nsHTTPChannel* i_Channel, - nsITransport** o_pTrans, PRUint32 flags = TRANSPORT_REUSE_ALIVE); + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans, PRUint32 flags = TRANSPORT_REUSE_ALIVE); /** * Called to create a transport from RequestTransport to accually @@ -112,16 +109,20 @@ public: virtual nsresult CreateTransport(const char* host, PRInt32 port, const char* aPrintHost, PRBool usingProxy, - nsITransport** o_pTrans); + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans); virtual nsresult CreateTransportOfType(const char* socketType, const char* host, PRInt32 port, const char* aPrintHost, PRBool usingProxy, - nsITransport** o_pTrans); + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans); /* Remove this transport from the list. */ - virtual nsresult ReleaseTransport(nsITransport* i_pTrans, PRUint32 capabilies = 0, PRBool aDontRestartChannels = PR_FALSE, PRUint32 aKeepAliveTimeout = 0, PRInt32 aKeepAliveMaxCon = -1); + virtual nsresult ReleaseTransport(nsIChannel* i_pTrans, PRUint32 capabilies = 0, PRBool aDontRestartChannels = PR_FALSE, PRUint32 aKeepAliveTimeout = 0, PRInt32 aKeepAliveMaxCon = -1); virtual nsresult CancelPendingChannel(nsHTTPChannel* aChannel); PRTime GetSessionStartTime() { return mSessionStartTime; } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp index aa6fdb645d4..fd2ee5015a7 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp @@ -57,8 +57,12 @@ static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID); extern nsresult DupString(char* *o_Dest, const char* i_Src); nsHTTPRequest::nsHTTPRequest(nsIURI* i_URL, - nsHTTPHandler* i_Handler) + nsHTTPHandler* i_Handler, + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize) : + mBufferSegmentSize(bufferSegmentSize), + mBufferMaxSize(bufferMaxSize), mPipelinedRequest(nsnull), mDoingProxySSLConnect(PR_FALSE), mSSLConnected(PR_FALSE), @@ -182,12 +186,10 @@ nsHTTPRequest::Resume() return rv; } - nsresult nsHTTPRequest::Clone(const nsHTTPRequest* *o_Request) const { return NS_ERROR_FAILURE; } - nsresult nsHTTPRequest::SetMethod(nsIAtom * i_Method) { @@ -202,7 +204,6 @@ nsIAtom * nsHTTPRequest::GetMethod(void) const return mMethod; } - nsresult nsHTTPRequest::SetPriority() { @@ -257,13 +258,12 @@ nsresult nsHTTPRequest::GetConnection(nsHTTPChannel** o_Connection) return rv; } - -nsresult nsHTTPRequest::SetTransport(nsITransport * aTransport) +nsresult nsHTTPRequest::SetTransport(nsIChannel * aTransport) { return NS_OK; } -nsresult nsHTTPRequest::GetTransport(nsITransport **aTransport) +nsresult nsHTTPRequest::GetTransport(nsIChannel **aTransport) { if (mPipelinedRequest) return mPipelinedRequest->GetTransport(aTransport); @@ -273,7 +273,6 @@ nsresult nsHTTPRequest::GetTransport(nsITransport **aTransport) return NS_OK; } - nsresult nsHTTPRequest::GetHeaderEnumerator(nsISimpleEnumerator** aResult) { return mHeaders.GetEnumerator(aResult); @@ -419,7 +418,7 @@ nsHTTPRequest::formBuffer(nsCString * requestBuffer, PRUint32 capabilities) if (mDoingProxySSLConnect) { - nsCOMPtr trans; + nsCOMPtr trans; PRUint32 reuse = 0; GetTransport(getter_AddRefs(trans)); nsCOMPtr sockTrans = @@ -555,6 +554,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsHTTPPipelinedRequest, nsIStreamObserver) nsHTTPPipelinedRequest::nsHTTPPipelinedRequest(nsHTTPHandler* i_Handler, const char *host, PRInt32 port, PRUint32 capabilities) : mCapabilities(capabilities), mAttempts(0), + mBufferSegmentSize(0), + mBufferMaxSize(0), mMustCommit(PR_FALSE), mTotalProcessed(0), mTotalWritten(0), @@ -603,17 +604,21 @@ nsHTTPPipelinedRequest::~nsHTTPPipelinedRequest() } nsresult -nsHTTPPipelinedRequest::SetTransport(nsITransport * aTransport) +nsHTTPPipelinedRequest::SetTransport(nsIChannel * aTransport) { mTransport = aTransport; return NS_OK; } nsresult -nsHTTPPipelinedRequest::GetTransport(nsITransport **aTransport) +nsHTTPPipelinedRequest::GetTransport(nsIChannel **aTransport) { - NS_ENSURE_ARG_POINTER(aTransport); - NS_IF_ADDREF(*aTransport = mTransport); + if (aTransport == NULL) + return NS_ERROR_NULL_POINTER; + + *aTransport = mTransport; + NS_IF_ADDREF(*aTransport); + return NS_OK; } @@ -656,7 +661,7 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) if (mInputStream) tMode &= ~(TRANSPORT_REUSE_ALIVE); - rv = mHandler->RequestTransport(req->mURI, req->mConnection, + rv = mHandler->RequestTransport(req->mURI, req->mConnection, mBufferSegmentSize, mBufferMaxSize, getter_AddRefs(mTransport), tMode); if (NS_FAILED(rv)) @@ -681,6 +686,9 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) { req =(nsHTTPRequest *) mRequests->ElementAt(index); req->formBuffer(&mRequestBuffer, mCapabilities); + if (index == 0) + mTransport->SetNotificationCallbacks(req->mConnection); + NS_RELEASE(req); mTotalWritten++; } @@ -707,9 +715,13 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) stream = do_QueryInterface(result, &rv); if (NS_FAILED(rv)) return rv; + // + // Write the request to the server. + // + rv = mTransport->SetTransferCount(mRequestBuffer.Length()); + + if (NS_FAILED(rv)) return rv; req =(nsHTTPRequest *) mRequests->ElementAt(0); - if (!req) - return NS_ERROR_NULL_POINTER; // // Propagate the load attributes from the HTTPChannel into the @@ -719,26 +731,11 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL; req->mConnection->GetLoadAttributes(&loadAttributes); - if (loadAttributes & nsIChannel::LOAD_BACKGROUND) - mTransport->SetProgressEventSink(nsnull); - else { - // - // configure transport with the progress event sink from the first request. - // - nsCOMPtr sink = - do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor*, req->mConnection)); - if (sink) - mTransport->SetProgressEventSink(sink); - } + mTransport->SetLoadAttributes(loadAttributes); } mOnStopDone = PR_FALSE; - - rv = NS_AsyncWriteFromStream( - getter_AddRefs(mCurrentWriteRequest), - mTransport, stream, 0, mRequestBuffer.Length(), 0, - this, NS_STATIC_CAST(nsIRequest*, req->mConnection)); - + rv = NS_AsyncWriteFromStream(mTransport, stream, this, (nsISupports*)(nsIRequest*)req->mConnection); NS_RELEASE(req); return rv; @@ -748,7 +745,7 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) // nsIStreamObserver methods: NS_IMETHODIMP -nsHTTPPipelinedRequest::OnStartRequest(nsIRequest *request, nsISupports* i_Context) +nsHTTPPipelinedRequest::OnStartRequest(nsIChannel* channel, nsISupports* i_Context) { PR_LOG(gHTTPLog, PR_LOG_ALWAYS, ("nsHTTPRequest [this=%x]. Starting to write data to the server.\n", @@ -758,7 +755,7 @@ nsHTTPPipelinedRequest::OnStartRequest(nsIRequest *request, nsISupports* i_Conte } NS_IMETHODIMP -nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports* i_Context, +nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -788,10 +785,8 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports* i_Contex ("nsHTTPRequest [this=%x]. " "Writing PUT/POST data to the server.\n", this)); - rv = NS_AsyncWriteFromStream( - getter_AddRefs(mCurrentWriteRequest), - mTransport, mInputStream, 0, 0, 0, - this, NS_STATIC_CAST(nsIRequest*, req->mConnection)); + rv = NS_AsyncWriteFromStream(mTransport, mInputStream, this, + (nsISupports*)(nsIRequest*)req->mConnection); /* the mInputStream is released below... */ } @@ -815,8 +810,7 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports* i_Contex if (pListener) { NS_ADDREF(pListener); - rv = mTransport->AsyncRead(pListener, i_Context, 0, -1, 0, - getter_AddRefs(mCurrentReadRequest)); + rv = mTransport->AsyncRead(pListener, i_Context); mListener = pListener; NS_RELEASE(pListener); } @@ -874,9 +868,6 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports* i_Contex mHandler->ReleaseTransport(mTransport, nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES, PR_TRUE); mTransport = null_nsCOMPtr(); - mCurrentWriteRequest = 0; - mCurrentReadRequest = 0; - mOnStopDone = PR_TRUE; rv = WriteRequest(mInputStream); @@ -899,10 +890,8 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports* i_Contex if (mTransport) { - nsITransport *p = mTransport; - mTransport = 0; - mCurrentWriteRequest = 0; - mCurrentReadRequest = 0; + nsIChannel *p = mTransport; + mTransport = null_nsCOMPtr(); mHandler->ReleaseTransport(p, nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES); } @@ -1005,8 +994,6 @@ nsHTTPPipelinedRequest::RestartRequest(PRUint32 aType) mHandler->ReleaseTransport(mTransport, nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES, PR_TRUE); mTransport = null_nsCOMPtr(); - mCurrentWriteRequest = 0; - mCurrentReadRequest = 0; rval = WriteRequest(mInputStream); } @@ -1018,9 +1005,10 @@ nsHTTPPipelinedRequest::RestartRequest(PRUint32 aType) nsresult nsHTTPPipelinedRequest::GetName(PRUnichar* *result) { - if (mCurrentReadRequest) - return mCurrentReadRequest->GetName(result); + if (mTransport) + return mTransport->GetName(result); + NS_NOTREACHED("nsHTTPPipelinedRequest::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } @@ -1029,8 +1017,8 @@ nsHTTPPipelinedRequest::IsPending(PRBool *result) { nsresult rv = NS_OK; - if (mCurrentReadRequest) - rv = mCurrentReadRequest->IsPending(result); + if (mTransport) + rv = mTransport->IsPending(result); else *result = PR_FALSE; @@ -1042,11 +1030,8 @@ nsHTTPPipelinedRequest::Cancel(nsresult status) { nsresult rv = NS_OK; - if (mCurrentReadRequest) - rv = mCurrentReadRequest->Cancel(status); - - if (mCurrentWriteRequest) - (void) mCurrentWriteRequest->Cancel(status); + if (mTransport) + rv = mTransport->Cancel(status); return rv; } @@ -1056,12 +1041,8 @@ nsHTTPPipelinedRequest::Suspend(void) { nsresult rv = NS_ERROR_FAILURE; - if (mCurrentReadRequest) - rv = mCurrentReadRequest->Suspend(); - - if (mCurrentWriteRequest) - (void) mCurrentWriteRequest->Suspend(); - + if (mTransport) + rv = mTransport->Suspend(); return rv; } @@ -1070,12 +1051,8 @@ nsHTTPPipelinedRequest::Resume() { nsresult rv = NS_ERROR_FAILURE; - if (mCurrentReadRequest) - rv = mCurrentReadRequest->Resume(); - - if (mCurrentWriteRequest) - (void) mCurrentWriteRequest->Resume(); - + if (mTransport) + rv = mTransport->Resume(); return rv; } @@ -1120,6 +1097,12 @@ nsHTTPPipelinedRequest::AddToPipeline(nsHTTPRequest *aRequest) aRequest->mPipelinedRequest = this; mRequests->AppendElement(aRequest); + if (mBufferSegmentSize < aRequest->mBufferSegmentSize) + mBufferSegmentSize = aRequest->mBufferSegmentSize; + + if (mBufferMaxSize < aRequest->mBufferMaxSize) + mBufferMaxSize = aRequest->mBufferMaxSize; + if (sLongestPipeline < count + 1) sLongestPipeline = count + 1; @@ -1214,12 +1197,8 @@ nsHTTPPipelinedRequest::AdvanceToNextRequest() // on some machines, but not on others. Check for null to avoid // topcrash, although we really shouldn't need this. NS_ASSERTION(mTransport, "mTransport null in AdvanceToNextRequest"); - if (mTransport) { - nsCOMPtr sink = - do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor*, req->mConnection)); - if (sink) - mTransport->SetProgressEventSink(sink); - } + if (mTransport) + mTransport->SetNotificationCallbacks(req->mConnection); NS_RELEASE(req); } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h index 527c3e66cbe..9540e0c295f 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h @@ -37,7 +37,6 @@ #include "nsHTTPHandler.h" #include "nsISupportsArray.h" #include "nsXPIDLString.h" -#include "nsITransport.h" class nsIInputStream; class nsHTTPChannel; @@ -69,10 +68,11 @@ class nsHTTPPipelinedRequest; class nsHTTPRequest : public nsIRequest { + public: // Constructor - nsHTTPRequest(nsIURI* i_URL, nsHTTPHandler* i_Handler); + nsHTTPRequest(nsIURI* i_URL, nsHTTPHandler* i_Handler, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize); NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -112,8 +112,8 @@ public: nsresult GetConnection(nsHTTPChannel** o_Connection); nsresult SetConnection(nsHTTPChannel* i_Connection); - nsresult SetTransport (nsITransport * aTransport); - nsresult GetTransport (nsITransport **aTransport); + nsresult SetTransport (nsIChannel * aTransport); + nsresult GetTransport (nsIChannel **aTransport); nsresult GetUploadStream(nsIInputStream** o_UploadStream); nsresult SetUploadStream(nsIInputStream* i_UploadStream); @@ -121,6 +121,9 @@ public: nsresult SetOverrideRequestSpec(const char* i_Spec); nsresult GetOverrideRequestSpec(char** o_Spec); + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; + // for POST or PUT data... nsCOMPtr mInputStream; @@ -189,8 +192,8 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSISTREAMOBSERVER - nsresult SetTransport (nsITransport * aTransport); - nsresult GetTransport (nsITransport **aTransport); + nsresult SetTransport (nsIChannel * aTransport); + nsresult GetTransport (nsIChannel **aTransport); // Build the actual request string based on the settings. nsresult WriteRequest(nsIInputStream* iRequestStream); @@ -217,9 +220,7 @@ protected: PRUint32 mCapabilities; PRUint32 mAttempts; - nsCOMPtr mTransport; - nsCOMPtr mCurrentWriteRequest; - nsCOMPtr mCurrentReadRequest; + nsCOMPtr mTransport; PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index b350466d5ad..0a478c2af4d 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -138,27 +138,21 @@ nsHTTPCacheListener::~nsHTTPCacheListener() // nsIStreamObserver methods: NS_IMETHODIMP -nsHTTPCacheListener::OnStartRequest(nsIRequest *aRequest, +nsHTTPCacheListener::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, ("nsHTTPCacheListener::OnStartRequest [this=%x]\n", this)) ; mBodyBytesReceived = 0; -// XXX Need a way to get the content-length from the cache transport -#if 0 // get and store the content length which will be used in ODA for computing // progress information. - nsCOMPtr cr = do_QueryInterface(aRequest); - if (!cr) return NS_ERROR_FAILURE; - - cr->GetContentLength(&mContentLength) ; -#endif + aChannel->GetContentLength(&mContentLength) ; return mResponseDataListener->OnStartRequest(mChannel, aContext) ; } NS_IMETHODIMP -nsHTTPCacheListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, +nsHTTPCacheListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, @@ -178,7 +172,7 @@ nsHTTPCacheListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, // nsIStreamListener methods: NS_IMETHODIMP -nsHTTPCacheListener::OnDataAvailable(nsIRequest *aRequest, +nsHTTPCacheListener::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aStream, PRUint32 aSourceOffset, @@ -282,7 +276,7 @@ nsHTTPServerListener::~nsHTTPServerListener() // nsIStreamListener methods: NS_IMETHODIMP -nsHTTPServerListener::OnDataAvailable(nsIRequest* request, +nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *i_pStream, PRUint32 i_SourceOffset, @@ -367,35 +361,29 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, if (mResponse) { PRUint32 statusCode = 0; - mResponse->GetStatus(&statusCode); + mResponse->GetStatus(&statusCode) ; if (statusCode == 304) // no content { - rv = FinishedResponseHeaders(); + rv = FinishedResponseHeaders() ; if (NS_FAILED(rv)) return rv; - rv = mPipelinedRequest->AdvanceToNextRequest(); + rv = mPipelinedRequest->AdvanceToNextRequest() ; if (NS_FAILED(rv)) { - mHandler->ReleasePipelinedRequest(mPipelinedRequest); + mHandler->ReleasePipelinedRequest(mPipelinedRequest) ; mPipelinedRequest = nsnull; - nsCOMPtr req = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - nsCOMPtr trans; - rv = req->GetTransport(getter_AddRefs(trans)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr sTrans = do_QueryInterface(trans, &rv); + nsCOMPtr trans = do_QueryInterface(channel, &rv) ; // XXX/ruslan: will be replaced with the new Cancel(code) if (NS_SUCCEEDED(rv)) - sTrans->SetBytesExpected(0); + trans->SetBytesExpected(0) ; } else { - OnStartRequest(nsnull, nsnull); + OnStartRequest(nsnull, nsnull) ; } } else @@ -405,7 +393,7 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, mFirstLineParsed = PR_FALSE; mHeaderBuffer.Truncate() ; - mChannel->SetResponse(nsnull); + mChannel->SetResponse(nsnull) ; NS_RELEASE(mResponse) ; mResponse = nsnull; @@ -423,22 +411,22 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, mFirstLineParsed = PR_FALSE; mHeaderBuffer.Truncate() ; - mChannel->SetResponse(nsnull); - NS_RELEASE(mResponse); + mChannel->SetResponse(nsnull) ; + NS_RELEASE(mResponse) ; mResponse = nsnull; mBytesReceived = 0; - mPipelinedRequest->RestartRequest(REQUEST_RESTART_SSL); + mPipelinedRequest->RestartRequest(REQUEST_RESTART_SSL) ; return NS_OK; PR_LOG(gHTTPLog, PR_LOG_DEBUG, ("\tOnDataAvailable [this=%x].(200) SSL CONNECT\n", - this)); + this)) ; } else { - rv = FinishedResponseHeaders(); + rv = FinishedResponseHeaders() ; if (NS_FAILED(rv)) return rv; } @@ -503,7 +491,7 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, fromStr.GetUnicode() , toStr.GetUnicode() , mResponseDataListener, - request, + channel, getter_AddRefs(converterListener)) ; if (NS_FAILED(rv)) return rv; mResponseDataListener = converterListener; @@ -605,18 +593,11 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, mHandler->ReleasePipelinedRequest(mPipelinedRequest) ; mPipelinedRequest = nsnull; - nsCOMPtr req = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr trans; - rv = req->GetTransport(getter_AddRefs(trans)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr sTrans = do_QueryInterface(trans, &rv1) ; + nsCOMPtr trans = do_QueryInterface(channel, &rv1) ; // XXX/ruslan: will be replaced with the new Cancel(code) if (NS_SUCCEEDED(rv1)) - sTrans->SetBytesExpected(0); + trans->SetBytesExpected(0) ; } else @@ -637,7 +618,7 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, i_pStream->Available(&streamLen) ; if (streamLen > 0) - OnDataAvailable(request, context, i_pStream, 0, streamLen) ; + OnDataAvailable(channel, context, i_pStream, 0, streamLen) ; } } } @@ -646,7 +627,7 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest* request, NS_IMETHODIMP -nsHTTPServerListener::OnStartRequest(nsIRequest* request, nsISupports* i_pContext) +nsHTTPServerListener::OnStartRequest(nsIChannel* channel, nsISupports* i_pContext) { PR_LOG(gHTTPLog, PR_LOG_ALWAYS, ("nsHTTPServerListener::OnStartRequest [this=%x].\n", this)) ; @@ -689,7 +670,7 @@ nsHTTPServerListener::OnStartRequest(nsIRequest* request, nsISupports* i_pContex } NS_IMETHODIMP -nsHTTPServerListener::OnStopRequest(nsIRequest* request, nsISupports* i_pContext, +nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext, nsresult i_Status, const PRUnichar* aStatusArg) { nsresult rv = i_Status, channelStatus = NS_OK; @@ -759,7 +740,7 @@ nsHTTPServerListener::OnStopRequest(nsIRequest* request, nsISupports* i_pContext PRUint32 keepAliveTimeout = 0; PRInt32 keepAliveMaxCon = -1; - if (mResponse && request) // this is the actual response from the transport + if (mResponse && channel) // this is the actual response from the transport { HTTPVersion ver; rv = mResponse->GetServerVersion(&ver) ; @@ -806,40 +787,33 @@ nsHTTPServerListener::OnStopRequest(nsIRequest* request, nsISupports* i_pContext cp = PL_strstr(keepAliveHeader, "max=") ; if (cp) - keepAliveMaxCon = atoi(cp + 4); + keepAliveMaxCon = atoi(cp + 4) ; - cp = PL_strstr(keepAliveHeader, "timeout="); + cp = PL_strstr(keepAliveHeader, "timeout=") ; if (cp) - keepAliveTimeout =(PRUint32) atoi(cp + 8); + keepAliveTimeout =(PRUint32) atoi(cp + 8) ; } } if (mPipelinedRequest) { - while (NS_SUCCEEDED(mPipelinedRequest->AdvanceToNextRequest())) + while (NS_SUCCEEDED(mPipelinedRequest->AdvanceToNextRequest()) ) { - OnStartRequest(nsnull, nsnull); + OnStartRequest(nsnull, nsnull) ; mChannel->ResponseCompleted(mResponseDataListener, i_Status, aStatusArg); mChannel->mHTTPServerListener = 0; } - mHandler->ReleasePipelinedRequest(mPipelinedRequest); + mHandler->ReleasePipelinedRequest(mPipelinedRequest) ; mPipelinedRequest = nsnull; } - nsCOMPtr req = do_QueryInterface(request); - if (req) { - nsCOMPtr transport; - req->GetTransport(getter_AddRefs(transport)); - - if (transport) - mHandler->ReleaseTransport(transport, capabilities, PR_FALSE, - keepAliveTimeout, keepAliveMaxCon); - } + if (channel) + mHandler->ReleaseTransport(channel, capabilities, PR_FALSE, keepAliveTimeout, keepAliveMaxCon) ; } - NS_IF_RELEASE(mChannel); - NS_IF_RELEASE(mResponse); + NS_IF_RELEASE(mChannel) ; + NS_IF_RELEASE(mResponse) ; return NS_OK; } @@ -1157,7 +1131,7 @@ nsHTTPFinalListener::~nsHTTPFinalListener() // nsIStreamObserver methods: NS_IMETHODIMP -nsHTTPFinalListener::OnStartRequest(nsIRequest *aRequest, +nsHTTPFinalListener::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, @@ -1168,11 +1142,11 @@ nsHTTPFinalListener::OnStartRequest(nsIRequest *aRequest, return NS_OK; mOnStartFired = PR_TRUE; - return mListener->OnStartRequest(aRequest, aContext) ; + return mListener->OnStartRequest(aChannel, aContext) ; } NS_IMETHODIMP -nsHTTPFinalListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, +nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, @@ -1205,7 +1179,7 @@ nsHTTPFinalListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, } mOnStopFired = PR_TRUE; - nsresult rv = mListener->OnStopRequest(aRequest, aContext, aStatus, aStatusArg) ; + nsresult rv = mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg) ; return rv; } @@ -1214,7 +1188,7 @@ nsHTTPFinalListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, // nsIStreamListener methods: NS_IMETHODIMP -nsHTTPFinalListener::OnDataAvailable(nsIRequest *aRequest, +nsHTTPFinalListener::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aStream, PRUint32 aSourceOffset, @@ -1237,7 +1211,7 @@ nsHTTPFinalListener::OnDataAvailable(nsIRequest *aRequest, return NS_OK; mBusy = PR_TRUE; - nsresult rv = mListener->OnDataAvailable(aRequest, aContext, + nsresult rv = mListener->OnDataAvailable(aChannel, aContext, aStream, aSourceOffset, aCount) ; mBusy = PR_FALSE; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp index 02a891bc25e..7d769398501 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp @@ -73,9 +73,12 @@ nsresult nsHTTPSHandler::CreateTransport(const char* host, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - nsITransport** o_pTrans) + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans) { - return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, o_pTrans); + return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, + bufferSegmentSize, bufferMaxSize, o_pTrans); } nsresult nsHTTPSHandler::CreateTransportOfType(const char * type, @@ -83,7 +86,9 @@ nsresult nsHTTPSHandler::CreateTransportOfType(const char * type, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - nsITransport** o_pTrans) + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans) { nsresult rv; @@ -98,7 +103,7 @@ nsresult nsHTTPSHandler::CreateTransportOfType(const char * type, port, proxyHost, proxyPort, - 0, - 0, + bufferSegmentSize, + bufferMaxSize, o_pTrans); } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h index 925ae459827..9b4ec14c3d3 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h @@ -74,14 +74,18 @@ public: PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - nsITransport** o_pTrans); + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans); virtual nsresult CreateTransportOfType(const char* socketType, const char* host, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - nsITransport** o_pTrans); + PRUint32 bufferSegmentSize, + PRUint32 bufferMaxSize, + nsIChannel** o_pTrans); }; #endif /* _nsHTTPSHandler_h_ */ diff --git a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp index 2249ba9d601..5ef89b162d8 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp @@ -31,7 +31,6 @@ #include "nsMimeTypes.h" #include "nsScriptSecurityManager.h" #include "nsIAggregatePrincipal.h" -#include "nsIProgressEventSink.h" #include "nsXPIDLString.h" static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); @@ -61,9 +60,13 @@ PRLogModuleInfo* gJarProtocolLog = nsnull; nsJARChannel::nsJARChannel() : mLoadAttributes(LOAD_NORMAL), + mStartPosition(0), + mReadCount(-1), mContentType(nsnull), mContentLength(-1), mJAREntry(nsnull), + mBufferSegmentSize(NS_DEFAULT_JAR_BUFFER_SEGMENT_SIZE), + mBufferMaxSize(NS_DEFAULT_JAR_BUFFER_MAX_SIZE), mStatus(NS_OK), mMonitor(nsnull) { @@ -252,12 +255,12 @@ nsJARChannel::OpenJARElement() rv = Open(nsnull, nsnull); if (NS_SUCCEEDED(rv)) rv = GetInputStream(getter_AddRefs(mSynchronousInputStream)); - mon.Notify(); // wake up nsIChannel::Open + mon.Notify(); // wake up OpenInputStream return rv; } NS_IMETHODIMP -nsJARChannel::Open(nsIInputStream* *result) +nsJARChannel::OpenInputStream(nsIInputStream* *result) { nsAutoCMonitor mon(this); nsresult rv; @@ -270,7 +273,7 @@ nsJARChannel::Open(nsIInputStream* *result) { *result = mSynchronousInputStream; // Result of GetInputStream called on transport thread NS_ADDREF(*result); - mSynchronousInputStream = 0; + mSynchronousInputStream = null_nsCOMPtr(); return NS_OK; } else @@ -278,7 +281,14 @@ nsJARChannel::Open(nsIInputStream* *result) } NS_IMETHODIMP -nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt) +nsJARChannel::OpenOutputStream(nsIOutputStream* *result) +{ + NS_NOTREACHED("nsJARChannel::OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsJARChannel::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) { nsresult rv; mUserContext = ctxt; @@ -300,7 +310,7 @@ nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt) } } } - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -332,7 +342,7 @@ nsJARChannel::EnsureJARFileAvailable() rv = NS_NewDownloader(getter_AddRefs(mDownloader), mJARBaseURI, this, nsnull, mSynchronousRead, mLoadGroup, mCallbacks, - mLoadAttributes); + mLoadAttributes, mBufferSegmentSize, mBufferMaxSize); // if DownloadComplete() was called early, need to release the reference. if (mSynchronousRead && mSynchronousInputStream) @@ -340,7 +350,7 @@ nsJARChannel::EnsureJARFileAvailable() error: if (NS_FAILED(rv) && mLoadGroup) { - nsresult rv2 = mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); + nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } return rv; @@ -356,16 +366,20 @@ nsJARChannel::AsyncReadJARElement() NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr jarTransport; - rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport)); + rv = fts->CreateTransportFromStreamIO(this, + getter_AddRefs(mJarExtractionTransport)); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetBufferSegmentSize(mBufferSegmentSize); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetBufferMaxSize(mBufferMaxSize); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetNotificationCallbacks(mCallbacks); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetTransferOffset(mStartPosition); + if (NS_FAILED(rv)) return rv; + rv = mJarExtractionTransport->SetTransferCount(mReadCount); if (NS_FAILED(rv)) return rv; - if (mCallbacks) { - nsCOMPtr sink = do_GetInterface(mCallbacks); - if (sink) - jarTransport->SetProgressEventSink(sink); - } - #ifdef PR_LOGGING nsXPIDLCString jarURLStr; mURI->GetSpec(getter_Copies(jarURLStr)); @@ -373,10 +387,18 @@ nsJARChannel::AsyncReadJARElement() ("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr)); #endif - rv = jarTransport->AsyncRead(this, nsnull, 0, -1, 0, getter_AddRefs(mJarExtractionTransport)); + rv = mJarExtractionTransport->AsyncRead(this, nsnull); return rv; } +NS_IMETHODIMP +nsJARChannel::AsyncWrite(nsIStreamProvider* provider, + nsISupports* ctxt) +{ + NS_NOTREACHED("nsJARChannel::AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJARChannel::GetLoadAttributes(PRUint32* aLoadFlags) { @@ -469,6 +491,83 @@ nsJARChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsJARChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mStartPosition; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + mStartPosition = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mReadCount; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetTransferCount(PRInt32 aTransferCount) +{ + mReadCount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsJARChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -568,7 +667,7 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu else rv = AsyncReadJARElement(); } - mDownloader = 0; + mDownloader = null_nsCOMPtr(); return rv; } @@ -576,14 +675,14 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu // nsIStreamObserver methods: NS_IMETHODIMP -nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport, +nsJARChannel::OnStartRequest(nsIChannel* jarExtractionTransport, nsISupports* context) { return mUserListener->OnStartRequest(this, mUserContext); } NS_IMETHODIMP -nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context, +nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -602,7 +701,7 @@ nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* con if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); + mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); } } @@ -616,7 +715,7 @@ nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* con // nsIStreamListener methods: NS_IMETHODIMP -nsJARChannel::OnDataAvailable(nsIRequest* jarCacheTransport, +nsJARChannel::OnDataAvailable(nsIChannel* jarCacheTransport, nsISupports* context, nsIInputStream *inStr, PRUint32 sourceOffset, diff --git a/mozilla/netwerk/protocol/jar/src/nsJARChannel.h b/mozilla/netwerk/protocol/jar/src/nsJARChannel.h index e8d08e93c06..9bfdf71c3c4 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARChannel.h +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.h @@ -89,6 +89,8 @@ protected: nsLoadFlags mLoadAttributes; nsCOMPtr mOwner; + PRUint32 mStartPosition; + PRInt32 mReadCount; nsCOMPtr mUserContext; nsCOMPtr mUserListener; @@ -98,13 +100,15 @@ protected: char* mJAREntry; nsCOMPtr mJAR; nsCOMPtr mDownloadedJARFile; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; nsresult mStatus; PRBool mSynchronousRead; nsCOMPtr mSynchronousInputStream; PRMonitor* mMonitor; nsCOMPtr mDownloader; - nsCOMPtr mJarExtractionTransport; + nsCOMPtr mJarExtractionTransport; }; diff --git a/mozilla/netwerk/protocol/res/src/Makefile.in b/mozilla/netwerk/protocol/res/src/Makefile.in index 976e2901ffb..f96a1773a2d 100644 --- a/mozilla/netwerk/protocol/res/src/Makefile.in +++ b/mozilla/netwerk/protocol/res/src/Makefile.in @@ -28,7 +28,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = necko LIBRARY_NAME = nkres_s -REQUIRES = xpcom exthandler mime +REQUIRES = xpcom CPPSRCS = \ nsResChannel.cpp \ diff --git a/mozilla/netwerk/protocol/res/src/nsResChannel.cpp b/mozilla/netwerk/protocol/res/src/nsResChannel.cpp index ad114e946e8..558fde17734 100644 --- a/mozilla/netwerk/protocol/res/src/nsResChannel.cpp +++ b/mozilla/netwerk/protocol/res/src/nsResChannel.cpp @@ -29,11 +29,6 @@ #include "nsIURL.h" #include "nsIIOService.h" #include "nsXPIDLString.h" -#include "nsCExternalHandlerService.h" -#include "nsIMIMEService.h" -#include "nsNetUtil.h" -#include "nsMimeTypes.h" - static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); @@ -57,8 +52,12 @@ PRLogModuleInfo* gResChannelLog = nsnull; //////////////////////////////////////////////////////////////////////////////// nsResChannel::nsResChannel() -: mLoadAttributes(nsIResChannel::LOAD_NORMAL), + : mLoadAttributes(LOAD_NORMAL), mState(QUIESCENT), + mStartPosition(0), + mCount(-1), + mBufferSegmentSize(0), + mBufferMaxSize(0), mStatus(NS_OK) #ifdef DEBUG ,mInitiator(nsnull) @@ -88,19 +87,12 @@ nsResChannel::~nsResChannel() { } - -NS_IMPL_THREADSAFE_ADDREF(nsResChannel) -NS_IMPL_THREADSAFE_RELEASE(nsResChannel) - -NS_INTERFACE_MAP_BEGIN(nsResChannel) - NS_INTERFACE_MAP_ENTRY(nsIResChannel) - NS_INTERFACE_MAP_ENTRY(nsIFileChannel) - NS_INTERFACE_MAP_ENTRY(nsIStreamListener) - NS_INTERFACE_MAP_ENTRY(nsIStreamObserver) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIResChannel) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIRequest, nsIResChannel) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIChannel, nsIResChannel) -NS_INTERFACE_MAP_END_THREADSAFE +NS_IMPL_ISUPPORTS5(nsResChannel, + nsIResChannel, + nsIChannel, + nsIRequest, + nsIStreamListener, + nsIStreamProvider) NS_METHOD nsResChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) @@ -124,8 +116,7 @@ nsResChannel::Substitutions::Init() nsresult rv; nsResChannel* channel = GET_SUBSTITUTIONS_CHANNEL(this); - if (mSubstitutions) - return NS_ERROR_FAILURE; + NS_ASSERTION(mSubstitutions == nsnull, "failed to call destructor"); char* root; rv = channel->mResourceURI->GetHost(&root); @@ -303,15 +294,31 @@ nsResChannel::EnsureNextResolvedChannel() rv = mResolvedChannel->SetLoadGroup(mLoadGroup); if (NS_FAILED(rv)) goto done; } - if (mLoadAttributes != nsIResChannel::LOAD_NORMAL) { + if (mLoadAttributes != LOAD_NORMAL) { rv = mResolvedChannel->SetLoadAttributes(mLoadAttributes); if (NS_FAILED(rv)) goto done; } + if (mBufferSegmentSize) { + rv = mResolvedChannel->SetBufferSegmentSize(mBufferSegmentSize); + if (NS_FAILED(rv)) goto done; + } + if (mBufferMaxSize) { + rv = mResolvedChannel->SetBufferMaxSize(mBufferMaxSize); + if (NS_FAILED(rv)) goto done; + } if (mCallbacks) { rv = mResolvedChannel->SetNotificationCallbacks(mCallbacks); if (NS_FAILED(rv)) goto done; } - + if (mStartPosition) { + rv = mResolvedChannel->SetTransferOffset(mStartPosition); + if (NS_FAILED(rv)) goto done; + } + if (mCount >= 0) { + rv = mResolvedChannel->SetTransferCount(mCount); + if (NS_FAILED(rv)) goto done; + } + done: #if defined(PR_LOGGING) nsXPIDLCString resURI; @@ -327,7 +334,7 @@ nsResChannel::EnsureNextResolvedChannel() } NS_IMETHODIMP -nsResChannel::Open(nsIInputStream **result) +nsResChannel::OpenInputStream(nsIInputStream **result) { nsresult rv; @@ -342,16 +349,14 @@ nsResChannel::Open(nsIInputStream **result) if (NS_FAILED(rv)) break; if (mResolvedChannel) - rv = mResolvedChannel->Open(result); + rv = mResolvedChannel->OpenInputStream(result); } while (NS_FAILED(rv)); return rv; } -// XXX What does OpenOutputStream mean for a res "channel" -#if 0 NS_IMETHODIMP -nsResChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **result) +nsResChannel::OpenOutputStream(nsIOutputStream **result) { nsresult rv; @@ -366,15 +371,14 @@ nsResChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, if (NS_FAILED(rv)) break; if (mResolvedChannel) - rv = mResolvedChannel->OpenOutputStream(transferOffset, transferCount, result); + rv = mResolvedChannel->OpenOutputStream(result); } while (NS_FAILED(rv)); return rv; } -#endif NS_IMETHODIMP -nsResChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +nsResChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; @@ -411,13 +415,65 @@ nsResChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) if (NS_FAILED(rv)) break; if (mResolvedChannel) - rv = mResolvedChannel->AsyncOpen(this, nsnull); + rv = mResolvedChannel->AsyncRead(this, nsnull); // Later, this AsyncRead will call back our OnStopRequest // method. The action resumes there... } while (NS_FAILED(rv)); - if (NS_FAILED(rv)) + if (NS_FAILED(rv)) { (void)EndRequest(rv, nsnull); + } + + return rv; +} + +NS_IMETHODIMP +nsResChannel::AsyncWrite(nsIStreamProvider *provider, + nsISupports *ctxt) +{ + nsresult rv; + +#ifdef DEBUG + NS_ASSERTION(mInitiator == nsnull || mInitiator == PR_CurrentThread(), + "wrong thread calling this routine"); + mInitiator = PR_CurrentThread(); +#endif + + switch (mState) { + case QUIESCENT: + if (mResolvedChannel) + return NS_ERROR_IN_PROGRESS; + + // first time through + rv = mSubstitutions.Init(); + if (NS_FAILED(rv)) return rv; + // fall through + mState = ASYNC_READ; + + case ASYNC_READ: + break; + + default: + return NS_ERROR_IN_PROGRESS; + } + NS_ASSERTION(mState == ASYNC_READ, "wrong state"); + + mUserContext = ctxt; + mUserObserver = provider; + + do { + rv = EnsureNextResolvedChannel(); + if (NS_FAILED(rv)) break; + + if (mResolvedChannel) + rv = mResolvedChannel->AsyncWrite(this, nsnull); + // Later, this AsyncWrite will call back our OnStopRequest + // method. The action resumes there... + } while (NS_FAILED(rv)); + + if (NS_FAILED(rv)) { + (void)EndRequest(rv, nsnull); + } return rv; } @@ -441,11 +497,7 @@ nsResChannel::GetContentType(char * *aContentType) { if (mResolvedChannel) return mResolvedChannel->GetContentType(aContentType); - - // if we have not created a mResolvedChannel, use the mime service - nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID)); - if (!MIMEService) return NS_ERROR_FAILURE; - return MIMEService->GetTypeFromURI(mResourceURI, aContentType); + return NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -453,7 +505,6 @@ nsResChannel::SetContentType(const char *aContentType) { if (mResolvedChannel) return mResolvedChannel->SetContentType(aContentType); - return NS_ERROR_FAILURE; } @@ -462,7 +513,6 @@ nsResChannel::GetContentLength(PRInt32 *aContentLength) { if (mResolvedChannel) return mResolvedChannel->GetContentLength(aContentLength); - return NS_ERROR_FAILURE; } @@ -473,6 +523,104 @@ nsResChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsResChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + *aTransferOffset = mStartPosition; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + mStartPosition = aTransferOffset; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + *aTransferCount = mCount; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::SetTransferCount(PRInt32 aTransferCount) +{ + mCount = aTransferCount; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + *aBufferSegmentSize = mBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + mBufferSegmentSize = aBufferSegmentSize; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + *aBufferMaxSize = mBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + mBufferMaxSize = aBufferMaxSize; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::GetLocalFile(nsIFile* *result) +{ + nsresult rv; + rv = mSubstitutions.Init(); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr file; + do { + rv = EnsureNextResolvedChannel(); + if (NS_FAILED(rv)) break; + + if (mResolvedChannel) { + rv = mResolvedChannel->GetLocalFile(getter_AddRefs(file)); + PRBool exists; + rv = file->Exists(&exists); + if (NS_SUCCEEDED(rv) && exists) { + *result = file; + NS_ADDREF(*result); + return NS_OK; + } + } + } while (NS_FAILED(rv)); + + *result = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsResChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsResChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { @@ -530,18 +678,18 @@ nsResChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsResChannel::OnStartRequest(nsIRequest* request, nsISupports* context) +nsResChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) { #ifdef DEBUG NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif NS_ASSERTION(mUserObserver, "No observer..."); - return mUserObserver->OnStartRequest(NS_STATIC_CAST(nsIResChannel*, this), mUserContext); + return mUserObserver->OnStartRequest(this, mUserContext); } NS_IMETHODIMP -nsResChannel::OnStopRequest(nsIRequest* request, nsISupports* context, +nsResChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { #ifdef DEBUG @@ -549,12 +697,12 @@ nsResChannel::OnStopRequest(nsIRequest* request, nsISupports* context, "wrong thread calling this routine"); #endif if (NS_FAILED(aStatus) && aStatus != NS_BINDING_ABORTED) { - nsCOMPtr dummyRequest; - // if we failed to process this channel, then try the next one: switch (mState) { case ASYNC_READ: - return AsyncOpen(GetUserListener(), mUserContext); + return AsyncRead(GetUserListener(), mUserContext); + case ASYNC_WRITE: + return AsyncWrite(GetUserProvider(), mUserContext); default: break; } @@ -566,8 +714,7 @@ nsresult nsResChannel::EndRequest(nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - rv = mUserObserver->OnStopRequest(NS_STATIC_CAST(nsIResChannel*, this), - mUserContext, aStatus, aStatusArg); + rv = mUserObserver->OnStopRequest(this, mUserContext, aStatus, aStatusArg); #if 0 // we don't add the resource channel to the group (although maybe we should) if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { @@ -583,7 +730,7 @@ nsResChannel::EndRequest(nsresult aStatus, const PRUnichar* aStatusArg) } NS_IMETHODIMP -nsResChannel::OnDataAvailable(nsIRequest* request, nsISupports* context, +nsResChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -591,69 +738,20 @@ nsResChannel::OnDataAvailable(nsIRequest* request, nsISupports* context, NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif - return GetUserListener()->OnDataAvailable(NS_STATIC_CAST(nsIResChannel*, this), - mUserContext, aIStream, + return GetUserListener()->OnDataAvailable(this, mUserContext, aIStream, aSourceOffset, aLength); } +NS_IMETHODIMP +nsResChannel::OnDataWritable(nsIChannel* transportChannel, nsISupports* context, + nsIOutputStream *aOStream, PRUint32 aOffset, PRUint32 aLength) +{ +#ifdef DEBUG + NS_ASSERTION(mInitiator == PR_CurrentThread(), + "wrong thread calling this routine"); +#endif + return GetUserProvider()->OnDataWritable(this, mUserContext, aOStream, + aOffset, aLength); +} + //////////////////////////////////////////////////////////////////////////////// - - -/* void init (in nsIFile file, in long ioFlags, in long perm); */ -NS_IMETHODIMP nsResChannel::Init(nsIFile *file, PRInt32 ioFlags, PRInt32 perm) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute nsIFile file; */ -NS_IMETHODIMP nsResChannel::GetFile(nsIFile * *result) -{ - nsresult rv; - rv = mSubstitutions.Init(); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr file; - do { - rv = EnsureNextResolvedChannel(); - if (NS_FAILED(rv)) break; - - if (mResolvedChannel) { - nsCOMPtr fc(do_QueryInterface(mResolvedChannel)); - if (fc) { - rv = fc->GetFile(getter_AddRefs(file)); - if (file) { - PRBool exists; - rv = file->Exists(&exists); - if (NS_SUCCEEDED(rv) && exists) { - *result = file; - NS_ADDREF(*result); - return NS_OK; - } - } - } - } - } while (NS_FAILED(rv)); - - *result = nsnull; - return NS_ERROR_FAILURE; -} - -/* attribute long ioFlags; */ -NS_IMETHODIMP nsResChannel::GetIoFlags(PRInt32 *aIoFlags) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsResChannel::SetIoFlags(PRInt32 aIoFlags) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* attribute long permissions; */ -NS_IMETHODIMP nsResChannel::GetPermissions(PRInt32 *aPermissions) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsResChannel::SetPermissions(PRInt32 aPermissions) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} diff --git a/mozilla/netwerk/protocol/res/src/nsResChannel.h b/mozilla/netwerk/protocol/res/src/nsResChannel.h index 312c52ed038..20736d8b06c 100644 --- a/mozilla/netwerk/protocol/res/src/nsResChannel.h +++ b/mozilla/netwerk/protocol/res/src/nsResChannel.h @@ -39,17 +39,17 @@ #endif class nsResChannel : public nsIResChannel, - public nsIFileChannel, - public nsIStreamListener + public nsIStreamListener, + public nsIStreamProvider { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST NS_DECL_NSICHANNEL - NS_DECL_NSIFILECHANNEL NS_DECL_NSIRESCHANNEL NS_DECL_NSISTREAMOBSERVER NS_DECL_NSISTREAMLISTENER + NS_DECL_NSISTREAMPROVIDER nsResChannel(); virtual ~nsResChannel(); @@ -119,6 +119,10 @@ protected: Substitutions mSubstitutions; nsCOMPtr mUserObserver; nsCOMPtr mUserContext; + PRUint32 mStartPosition; + PRInt32 mCount; + PRUint32 mBufferSegmentSize; + PRUint32 mBufferMaxSize; nsresult mStatus; #ifdef DEBUG PRThread* mInitiator; diff --git a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp index 73cc77952ae..734f3bed6d8 100644 --- a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp +++ b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp @@ -228,7 +228,7 @@ nsResProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result) return rv; } - *result = (nsIChannel*)(nsIResChannel*)channel; + *result = channel; return NS_OK; } diff --git a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index a1180570b30..c884c550bf5 100644 --- a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -1088,7 +1088,7 @@ mozTXTToHTMLConv::AsyncConvertData(const PRUnichar *aFromType, } NS_IMETHODIMP -mozTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, +mozTXTToHTMLConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { @@ -1096,13 +1096,13 @@ mozTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, } NS_IMETHODIMP -mozTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *ctxt) +mozTXTToHTMLConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -mozTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *ctxt, +mozTXTToHTMLConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { return NS_ERROR_NOT_IMPLEMENTED; @@ -1159,6 +1159,10 @@ mozTXTToHTMLConv::ScanHTML(const PRUnichar *text, PRUint32 whattodo, return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } + +/************************************************************************** + Global functions +***************************************************************************/ nsresult MOZ_NewTXTToHTMLConv(mozTXTToHTMLConv** aConv) { diff --git a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index 5604aab5211..52f995d6779 100644 --- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -60,10 +60,7 @@ PRLogModuleInfo* gFTPDirListConvLog = nsnull; #endif /* PR_LOGGING */ // nsISupports implementation -NS_IMPL_THREADSAFE_ISUPPORTS3(nsFTPDirListingConv, - nsIStreamConverter, - nsIStreamListener, - nsIStreamObserver); +NS_IMPL_THREADSAFE_ISUPPORTS3(nsFTPDirListingConv, nsIStreamConverter, nsIStreamListener, nsIStreamObserver); // nsIStreamConverter implementation @@ -248,15 +245,10 @@ nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnicha // nsIStreamListener implementation NS_IMETHODIMP -nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, +nsFTPDirListingConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { - NS_ASSERTION(request, "FTP dir listing stream converter needs a request"); - + NS_ASSERTION(channel, "FTP dir listing stream converter needs a channel"); nsresult rv; - - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - PRUint32 read, streamLen; nsCAutoString indexFormat; indexFormat.SetCapacity(72); // quick guess @@ -271,7 +263,7 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, // the dir listings are ascii text, null terminate this sucker. buffer[streamLen] = '\0'; - PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::OnData(request = %x, ctxt = %x, inStr = %x, sourceOffset = %d, count = %d)\n", request, ctxt, inStr, sourceOffset, count)); + PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::OnData(channel = %x, ctxt = %x, inStr = %x, sourceOffset = %d, count = %d)\n", channel, ctxt, inStr, sourceOffset, count)); if (!mBuffer.IsEmpty()) { // we have data left over from a previous OnDataAvailable() call. @@ -354,29 +346,22 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, // nsIStreamObserver implementation NS_IMETHODIMP -nsFTPDirListingConv::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { +nsFTPDirListingConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { // we don't care about start. move along... but start masqeurading // as the http-index channel now. return mFinalListener->OnStartRequest(mPartChannel, ctxt); } NS_IMETHODIMP -nsFTPDirListingConv::OnStopRequest(nsIRequest* request, nsISupports *ctxt, +nsFTPDirListingConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { // we don't care about stop. move along... - - nsresult rv; - - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr loadgroup; - rv = channel->GetLoadGroup(getter_AddRefs(loadgroup)); + nsresult rv = mPartChannel->GetLoadGroup(getter_AddRefs(loadgroup)); if (NS_FAILED(rv)) return rv; if (loadgroup) - (void)loadgroup->RemoveRequest(mPartChannel, nsnull, aStatus, aStatusArg); + (void)loadgroup->RemoveChannel(mPartChannel, nsnull, aStatus, aStatusArg); return mFinalListener->OnStopRequest(mPartChannel, ctxt, aStatus, aStatusArg); } @@ -749,9 +734,6 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCAutoString &aString) { if (NT == mServerType && !nsCRT::IsAsciiSpace(line[8])) mServerType = UNIX; - // check for an eplf response - if (line[0] == '+') - mServerType = EPLF; char *escName = nsnull; switch (mServerType) { @@ -863,64 +845,6 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCAutoString &aString) { nsMemory::Free(escName); break; // END NT } - case EPLF: - { - - int flagcwd = 0; - int when = 0; - int flagsize = 0; - unsigned long size; - PRBool processing = PR_TRUE; - while (*line && processing) - switch (*line) { - case '\t': - { - if (flagcwd) { - thisEntry->mType = Dir; - thisEntry->mContentLen = 0; - } else { - thisEntry->mType = File; - thisEntry->mContentLen = size; - } - - escName = nsEscape(line+1, url_Path); - thisEntry->mName = escName; - - if (flagsize) { - thisEntry->mSupressSize = PR_FALSE; - // Mutiply what the last modification date to get usecs. - PRInt64 usecs = LL_Zero(); - PRInt64 seconds = LL_Zero(); - PRInt64 multiplier = LL_Zero(); - LL_I2L(seconds, when); - LL_I2L(multiplier, PR_USEC_PER_SEC); - LL_MUL(usecs, seconds, multiplier); - PR_ExplodeTime(usecs, PR_LocalTimeParameters, &thisEntry->mMDTM); - } else { - thisEntry->mSupressSize = PR_TRUE; - } - - processing = PR_FALSE; - } - break; - case 's': - flagsize = 1; - size = 0; - while (*++line && (*line != ',')) - size = size * 10 + (*line - '0'); - break; - case 'm': - while (*++line && (*line != ',')) - when = when * 10 + (*line - '0'); - break; - case '/': - flagcwd = 1; - default: - while (*line) if (*line++ == ',') break; - } - break; //END EPLF - } - default: { escName = nsEscape(line, url_Path); @@ -997,4 +921,3 @@ NS_NewFTPDirListingConv(nsFTPDirListingConv** aFTPDirListingConv) NS_ADDREF(*aFTPDirListingConv); return (*aFTPDirListingConv)->Init(); } - diff --git a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.h b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.h index 41b1ca48ab8..80ff10b0125 100644 --- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.h +++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.h @@ -54,8 +54,7 @@ static NS_DEFINE_CID(kFTPDirListingConverterCID, NS_FTPDIRLISTINGCONVERTER_CID); // tcpc // vms // nt -// eplf -// +// // nsFTPDirListingConv converts the raw ascii text directory generated via a FTP // LIST or NLST command, to the application/http-index-format MIME-type. // For more info see: http://www.area.com/~roeber/file_format.html @@ -70,8 +69,7 @@ typedef enum _FTP_Server_Type { CMS, TCPC, VMS, - NT, - EPLF + NT } FTP_Server_Type; typedef enum _FTPentryType { diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp b/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp index 7a25acb1743..7d0f1dfb6b2 100644 --- a/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp @@ -96,21 +96,21 @@ nsHTTPChunkConv::AsyncConvertData ( } NS_IMETHODIMP -nsHTTPChunkConv::OnStartRequest (nsIRequest* request, nsISupports *aContext) +nsHTTPChunkConv::OnStartRequest (nsIChannel *aChannel, nsISupports *aContext) { - return mListener->OnStartRequest (request, aContext); + return mListener -> OnStartRequest (aChannel, aContext); } NS_IMETHODIMP -nsHTTPChunkConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, +nsHTTPChunkConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } NS_IMETHODIMP nsHTTPChunkConv::OnDataAvailable ( - nsIRequest* request, + nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *iStr, PRUint32 aSourceOffset, @@ -160,7 +160,7 @@ nsHTTPChunkConv::OnDataAvailable ( if (NS_FAILED (rv)) return rv; - rv = mListener -> OnDataAvailable (request, aContext, convertedStream, aSourceOffset, mChunkBufferLength); + rv = mListener -> OnDataAvailable (aChannel, aContext, convertedStream, aSourceOffset, mChunkBufferLength); if (NS_FAILED (rv)) return rv; @@ -208,7 +208,7 @@ nsHTTPChunkConv::OnDataAvailable ( if (NS_FAILED (rv)) return rv; - rv = mListener -> OnDataAvailable (request, aContext, convertedStream, aSourceOffset, mChunkBufferLength); + rv = mListener -> OnDataAvailable (aChannel, aContext, convertedStream, aSourceOffset, mChunkBufferLength); if (NS_FAILED (rv)) return rv; @@ -440,3 +440,4 @@ NS_NewHTTPChunkConv (nsHTTPChunkConv ** aHTTPChunkConv) return NS_OK; } + diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index c5ea3c46f6f..e8923e274ff 100644 --- a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -95,21 +95,21 @@ nsHTTPCompressConv::AsyncConvertData ( } NS_IMETHODIMP -nsHTTPCompressConv::OnStartRequest (nsIRequest* request, nsISupports *aContext) +nsHTTPCompressConv::OnStartRequest (nsIChannel *aChannel, nsISupports *aContext) { - return mListener->OnStartRequest (request, aContext); + return mListener -> OnStartRequest (aChannel, aContext); } NS_IMETHODIMP -nsHTTPCompressConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, +nsHTTPCompressConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } NS_IMETHODIMP nsHTTPCompressConv::OnDataAvailable ( - nsIRequest* request, + nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *iStr, PRUint32 aSourceOffset, @@ -118,7 +118,7 @@ nsHTTPCompressConv::OnDataAvailable ( nsresult rv = NS_ERROR_FAILURE; PRUint32 streamLen; - rv = iStr->Available (&streamLen); + rv = iStr -> Available (&streamLen); if (NS_FAILED (rv)) return rv; @@ -159,7 +159,7 @@ nsHTTPCompressConv::OnDataAvailable ( if (mInpBuffer == NULL || mOutBuffer == NULL) return NS_ERROR_OUT_OF_MEMORY; - iStr->Read ((char *)mInpBuffer, streamLen, &rv); + iStr -> Read ((char *)mInpBuffer, streamLen, &rv); if (NS_FAILED (rv)) return rv; @@ -179,7 +179,7 @@ nsHTTPCompressConv::OnDataAvailable ( if (code != Z_OK) return NS_ERROR_FAILURE; - rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, (PRUint32) uLen); + rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, (PRUint32) uLen); if (NS_FAILED (rv)) return rv; @@ -211,7 +211,7 @@ nsHTTPCompressConv::OnDataAvailable ( { if (bytesWritten) { - rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); if (NS_FAILED (rv)) return rv; } @@ -225,7 +225,7 @@ nsHTTPCompressConv::OnDataAvailable ( { if (bytesWritten) { - rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); if (NS_FAILED (rv)) return rv; } @@ -235,7 +235,7 @@ nsHTTPCompressConv::OnDataAvailable ( { if (bytesWritten) { - rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); if (NS_FAILED (rv)) return rv; } @@ -248,7 +248,7 @@ nsHTTPCompressConv::OnDataAvailable ( break; default: - rv = mListener->OnDataAvailable (request, aContext, iStr, aSourceOffset, aCount); + rv = mListener -> OnDataAvailable (aChannel, aContext, iStr, aSourceOffset, aCount); if (NS_FAILED (rv)) return rv; } /* switch */ @@ -271,7 +271,24 @@ nsHTTPCompressConv::Convert ( } nsresult -nsHTTPCompressConv::do_OnDataAvailable (nsIRequest* request, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount) +NS_NewHTTPCompressConv (nsHTTPCompressConv ** aHTTPCompressConv) +{ + NS_PRECONDITION(aHTTPCompressConv != nsnull, "null ptr"); + + if (! aHTTPCompressConv) + return NS_ERROR_NULL_POINTER; + + *aHTTPCompressConv = new nsHTTPCompressConv (); + + if (! *aHTTPCompressConv) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(*aHTTPCompressConv); + return NS_OK; +} + +nsresult +nsHTTPCompressConv::do_OnDataAvailable (nsIChannel *aChannel, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount) { nsresult rv; @@ -291,7 +308,7 @@ nsHTTPCompressConv::do_OnDataAvailable (nsIRequest* request, nsISupports *aConte if (NS_FAILED (rv)) return rv; - rv = mListener->OnDataAvailable (request, aContext, convertedStream, aSourceOffset, aCount); + rv = mListener -> OnDataAvailable (aChannel, aContext, convertedStream, aSourceOffset, aCount); return rv; } @@ -322,7 +339,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre switch (hMode) { case GZIP_INIT: - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; if (mSkipCount == 0 && ((unsigned)c & 0377) != gz_magic[0]) @@ -358,7 +375,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre break; case GZIP_OS : - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; mSkipCount++; @@ -369,7 +386,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre case GZIP_EXTRA0: if (mFlags & EXTRA_FIELD) { - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; mLen = (uInt) c & 0377; hMode = GZIP_EXTRA1; @@ -379,7 +396,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre break; case GZIP_EXTRA1: - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; mLen = ((uInt) c & 0377) << 8; mSkipCount = 0; @@ -391,7 +408,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre hMode = GZIP_ORIG; else { - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; mSkipCount++; } @@ -400,7 +417,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre case GZIP_ORIG: if (mFlags & ORIG_NAME) { - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; if (c == 0) hMode = GZIP_COMMENT; @@ -412,7 +429,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre case GZIP_COMMENT: if (mFlags & GZIP_COMMENT) { - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; if (c == 0) { @@ -430,7 +447,7 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre case GZIP_CRC: if (mFlags & HEAD_CRC) { - iStr->Read (&c, 1, &rv); + iStr -> Read (&c, 1, &rv); streamLen--; mSkipCount++; if (mSkipCount == 2) @@ -449,23 +466,3 @@ nsHTTPCompressConv::check_header (nsIInputStream *iStr, PRUint32 streamLen, nsre } return streamLen; } - - -nsresult -NS_NewHTTPCompressConv (nsHTTPCompressConv ** aHTTPCompressConv) -{ - NS_PRECONDITION(aHTTPCompressConv != nsnull, "null ptr"); - - if (! aHTTPCompressConv) - return NS_ERROR_NULL_POINTER; - - *aHTTPCompressConv = new nsHTTPCompressConv (); - - if (! *aHTTPCompressConv) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(*aHTTPCompressConv); - return NS_OK; -} - - diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.h b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.h index 201bcddf2f2..d49c95fcf52 100644 --- a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.h +++ b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.h @@ -83,7 +83,7 @@ private: nsCOMPtr mAsyncConvContext; - nsresult do_OnDataAvailable (nsIRequest *request, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount); + nsresult do_OnDataAvailable (nsIChannel *aChannel, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount); PRBool mCheckHeaderDone; PRBool mGzipStreamEnded; diff --git a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp index ec0a40d27af..356713feae9 100644 --- a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -34,10 +34,8 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); // nsISupports implementation -NS_IMPL_THREADSAFE_ISUPPORTS3(nsMultiMixedConv, - nsIStreamConverter, - nsIStreamListener, - nsIStreamObserver); +NS_IMPL_THREADSAFE_ISUPPORTS3(nsMultiMixedConv, nsIStreamConverter, + nsIStreamListener, nsIStreamObserver); // nsIStreamConverter implementation @@ -71,17 +69,14 @@ nsMultiMixedConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnichar * // nsIStreamListener implementation NS_IMETHODIMP -nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context, +nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *context, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv = NS_OK; char *buffer = nsnull; PRUint32 bufLen = count, read; - NS_ASSERTION(request, "multimixed converter needs a request"); + NS_ASSERTION(channel, "multimixed converter needs a channel"); - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - buffer = (char*)nsMemory::Alloc(bufLen); if (!buffer) ERR_OUT @@ -209,7 +204,7 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context, // nsIStreamObserver implementation NS_IMETHODIMP -nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { +nsMultiMixedConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { // we're assuming the content-type is available at this stage NS_ASSERTION(!mToken, "a second on start???"); char *bndry = nsnull; @@ -217,11 +212,9 @@ nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsresult rv = NS_OK; mContext = ctxt; - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - // ask the HTTP channel for the content-type and extract the boundary from it. - nsCOMPtr httpChannel = do_QueryInterface(channel, &rv); + nsCOMPtr httpChannel; + rv = channel->QueryInterface(NS_GET_IID(nsIHTTPChannel), getter_AddRefs(httpChannel)); if (NS_SUCCEEDED(rv)) { nsCOMPtr header = NS_NewAtom("content-type"); if (!header) return NS_ERROR_OUT_OF_MEMORY; @@ -230,7 +223,7 @@ nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { } else { // try asking the channel directly rv = channel->GetContentType(getter_Copies(delimiter)); - if (!delimiter || NS_FAILED(rv)) return NS_ERROR_FAILURE; + if (NS_FAILED(rv)) return rv; } if (!delimiter) return NS_ERROR_FAILURE; @@ -257,7 +250,7 @@ nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { } NS_IMETHODIMP -nsMultiMixedConv::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +nsMultiMixedConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -275,10 +268,10 @@ nsMultiMixedConv::OnStopRequest(nsIRequest *request, nsISupports *ctxt, } rv = mFinalListener->OnStopRequest(mPartChannel, mContext, aStatus, aStatusArg); } else { - rv = mFinalListener->OnStartRequest(request, ctxt); + rv = mFinalListener->OnStartRequest(channel, ctxt); if (NS_FAILED(rv)) return rv; - rv = mFinalListener->OnStopRequest(request, ctxt, aStatus, aStatusArg); + rv = mFinalListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); } } else { @@ -339,7 +332,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) { // First build up a dummy uri. nsCOMPtr partURI; - rv = aChannel->GetURI(getter_AddRefs(partURI)); + rv = aChannel->GetURI(getter_AddRefs (partURI)); if (NS_FAILED(rv)) return rv; if (mContentType.IsEmpty()) @@ -353,9 +346,9 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) { if (NS_FAILED(rv)) return rv; nsLoadFlags loadFlags = 0; - mPartChannel->GetLoadAttributes(&loadFlags); + mPartChannel -> GetLoadAttributes (&loadFlags); loadFlags |= nsIChannel::LOAD_REPLACE; - mPartChannel->SetLoadAttributes(loadFlags); + mPartChannel -> SetLoadAttributes ( loadFlags); nsCOMPtr loadGroup; (void)aChannel->GetLoadGroup(getter_AddRefs(loadGroup)); @@ -363,7 +356,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) { if (loadGroup) { rv = mPartChannel->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; - rv = loadGroup->AddRequest(mPartChannel, nsnull); + rv = loadGroup->AddChannel(mPartChannel, nsnull); if (NS_FAILED(rv)) return rv; } @@ -383,7 +376,7 @@ nsMultiMixedConv::SendStop() { (void) mPartChannel->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) { - loadGroup->RemoveRequest(mPartChannel, mContext, NS_OK, nsnull); + loadGroup->RemoveChannel(mPartChannel, mContext, NS_OK, nsnull); } mPartChannel = 0; @@ -555,4 +548,3 @@ NS_NewMultiMixedConv(nsMultiMixedConv** aMultiMixedConv) NS_ADDREF(*aMultiMixedConv); return (*aMultiMixedConv)->Init(); } - diff --git a/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp b/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp index 44a86833b14..7c039c7f5f0 100644 --- a/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp @@ -55,7 +55,7 @@ nsTXTToHTMLConv::AsyncConvertData(const PRUnichar *aFromType, // nsIStreamObserver methods NS_IMETHODIMP -nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { +nsTXTToHTMLConv::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { mBuffer.AssignWithConversion("\n"); mBuffer.Append(mPageTitle); mBuffer.AppendWithConversion("\n\n"); @@ -66,7 +66,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { // Push mBuffer to the listener now, so the initial HTML will not // be parsed in OnDataAvailable(). - nsresult rv = mListener->OnStartRequest(request, aContext); + nsresult rv = mListener->OnStartRequest(aChannel, aContext); if (NS_FAILED(rv)) return rv; nsCOMPtr inputData; @@ -75,7 +75,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { if (NS_FAILED(rv)) return rv; inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, + rv = mListener->OnDataAvailable(aChannel, aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; mBuffer.AssignWithConversion(""); @@ -83,7 +83,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { } NS_IMETHODIMP -nsTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, +nsTXTToHTMLConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mToken) { @@ -105,11 +105,11 @@ nsTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, + rv = mListener->OnDataAvailable(aChannel, aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; - return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); } // nsITXTToHTMLConv methods @@ -127,7 +127,7 @@ nsTXTToHTMLConv::PreFormatHTML(PRBool value) { // nsIStreamListener method NS_IMETHODIMP -nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext, +nsTXTToHTMLConv::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aInStream, PRUint32 aOffset, PRUint32 aCount) { nsresult rv = NS_OK; @@ -180,7 +180,7 @@ nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext, inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(request, aContext, + rv = mListener->OnDataAvailable(aChannel, aContext, inputData, 0, pushBuffer.Length()); if (NS_FAILED(rv)) { nsMemory::Free(buffer); @@ -277,3 +277,17 @@ nsTXTToHTMLConv::CatHTML(PRInt32 front, PRInt32 back) { return cursor; } +nsresult +NS_NewNSTXTToHTMLConv(nsTXTToHTMLConv** aTXTToHTMLConv) +{ + NS_PRECONDITION(aTXTToHTMLConv != nsnull, "null ptr"); + if (!aTXTToHTMLConv) + return NS_ERROR_NULL_POINTER; + + *aTXTToHTMLConv = new nsTXTToHTMLConv(); + if (!*aTXTToHTMLConv) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(*aTXTToHTMLConv); + return (*aTXTToHTMLConv)->Init(); +} diff --git a/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.h b/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.h index 124d69641b5..bc5f7e2066e 100644 --- a/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.h +++ b/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.h @@ -36,6 +36,7 @@ 0x11b2, \ {0x9d, 0x65, 0xd7, 0x2d, 0x6d, 0x1f, 0x02, 0x5e} \ } +static NS_DEFINE_CID(kNSTXTTOHTMLCONVCID, NS_NSTXTTOHTMLCONVERTER_CID); // Internal representation of a "token" typedef struct convToken { diff --git a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp index 7b6204b5e6e..a9b1f39b4d2 100644 --- a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -21,6 +21,7 @@ */ #include "nsUnknownDecoder.h" + #include "nsIServiceManager.h" #include "nsIStreamConverterService.h" @@ -119,7 +120,7 @@ nsUnknownDecoder::AsyncConvertData(const PRUnichar *aFromType, // ---- NS_IMETHODIMP -nsUnknownDecoder::OnDataAvailable(nsIRequest* request, +nsUnknownDecoder::OnDataAvailable(nsIChannel *aChannel, nsISupports *aCtxt, nsIInputStream *aStream, PRUint32 aSourceOffset, @@ -160,11 +161,11 @@ nsUnknownDecoder::OnDataAvailable(nsIRequest* request, // aSourceOffset += mBufferLen; - DetermineContentType(request); + DetermineContentType(aChannel); NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); - rv = FireListenerNotifications(request, aCtxt); + rv = FireListenerNotifications(aChannel, aCtxt); } } @@ -172,7 +173,7 @@ nsUnknownDecoder::OnDataAvailable(nsIRequest* request, NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); - rv = mNextListener->OnDataAvailable(request, aCtxt, aStream, + rv = mNextListener->OnDataAvailable(aChannel, aCtxt, aStream, aSourceOffset, aCount); } @@ -186,7 +187,7 @@ nsUnknownDecoder::OnDataAvailable(nsIRequest* request, // ---- NS_IMETHODIMP -nsUnknownDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt) +nsUnknownDecoder::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) { nsresult rv = NS_OK; @@ -206,7 +207,7 @@ nsUnknownDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt) } NS_IMETHODIMP -nsUnknownDecoder::OnStopRequest(nsIRequest* request, nsISupports *aCtxt, +nsUnknownDecoder::OnStopRequest(nsIChannel *aChannel, nsISupports *aCtxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -218,25 +219,25 @@ nsUnknownDecoder::OnStopRequest(nsIRequest* request, nsISupports *aCtxt, // Analyze the buffer now... // if (mContentType.IsEmpty()) { - DetermineContentType(request); + DetermineContentType(aChannel); NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); - rv = FireListenerNotifications(request, aCtxt); + rv = FireListenerNotifications(aChannel, aCtxt); if (NS_FAILED(rv)) { aStatus = rv; } } - rv = mNextListener->OnStopRequest(request, aCtxt, aStatus, aStatusArg); + rv = mNextListener->OnStopRequest(aChannel, aCtxt, aStatus, aStatusArg); mNextListener = 0; return rv; } -void nsUnknownDecoder::DetermineContentType(nsIRequest* request) +void nsUnknownDecoder::DetermineContentType(nsIChannel *aChannel) { PRUint32 i; @@ -275,10 +276,7 @@ void nsUnknownDecoder::DetermineContentType(nsIRequest* request) */ PRBool isLocalFile = PR_FALSE; - if (request) { - nsCOMPtr aChannel = do_QueryInterface(request); - if (!request) { NS_WARNING("QI failed"); return; } - + if (aChannel) { nsCOMPtr pURL; if (NS_SUCCEEDED(aChannel->GetURI(getter_AddRefs(pURL)))) pURL->SchemeIs(nsIURI::FILE, &isLocalFile); @@ -326,7 +324,7 @@ void nsUnknownDecoder::DetermineContentType(nsIRequest* request) } } -nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request, +nsresult nsUnknownDecoder::FireListenerNotifications(nsIChannel *aChannel, nsISupports *aCtxt) { nsresult rv = NS_OK; @@ -335,14 +333,11 @@ nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request, if (!mBuffer) return NS_ERROR_OUT_OF_MEMORY; - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - // Set the new content type on the channel... - channel->SetContentType(mContentType); + aChannel->SetContentType(mContentType); // Fire the OnStartRequest(...) - rv = mNextListener->OnStartRequest(request, aCtxt); + rv = mNextListener->OnStartRequest(aChannel, aCtxt); // Fire the first OnDataAvailable for the data that was read from the // stream into the sniffer buffer... @@ -359,7 +354,7 @@ nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request, rv = out->Write(mBuffer, mBufferLen, &len); if (NS_SUCCEEDED(rv)) { if (len == mBufferLen) { - rv = mNextListener->OnDataAvailable(request, aCtxt, in, 0, len); + rv = mNextListener->OnDataAvailable(aChannel, aCtxt, in, 0, len); } else { NS_ASSERTION(0, "Unable to write all the data into the pipe."); rv = NS_ERROR_FAILURE; diff --git a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.h b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.h index 78d037aab7d..4cc2be95291 100644 --- a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.h +++ b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.h @@ -53,13 +53,14 @@ public: // nsIStreamObserver methods NS_DECL_NSISTREAMOBSERVER + nsUnknownDecoder(); protected: virtual ~nsUnknownDecoder(); - void DetermineContentType(nsIRequest* request); - nsresult FireListenerNotifications(nsIRequest* request, nsISupports *aCtxt); + void DetermineContentType(nsIChannel *aChannel); + nsresult FireListenerNotifications(nsIChannel *aChannel, nsISupports *aCtxt); protected: nsCOMPtr mNextListener; diff --git a/mozilla/netwerk/streamconv/test/Converters.cpp b/mozilla/netwerk/streamconv/test/Converters.cpp index 91ba0e12e61..a310aebea97 100644 --- a/mozilla/netwerk/streamconv/test/Converters.cpp +++ b/mozilla/netwerk/streamconv/test/Converters.cpp @@ -72,7 +72,7 @@ TestConverter::AsyncConvertData(const PRUnichar *aFromType, // nsIStreamListener method /* This method handles asyncronous conversion of data. */ NS_IMETHODIMP -TestConverter::OnDataAvailable(nsIRequest* request, +TestConverter::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, @@ -87,20 +87,20 @@ TestConverter::OnDataAvailable(nsIRequest* request, PRUint32 len; convertedStream->Available(&len); - return mListener->OnDataAvailable(request, ctxt, convertedStream, sourceOffset, len); + return mListener->OnDataAvailable(channel, ctxt, convertedStream, sourceOffset, len); }; // nsIStreamObserver methods /* These methods just pass through directly to the mListener */ NS_IMETHODIMP -TestConverter::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { - return mListener->OnStartRequest(request, ctxt); +TestConverter::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { + return mListener->OnStartRequest(channel, ctxt); }; NS_IMETHODIMP -TestConverter::OnStopRequest(nsIRequest* request, nsISupports *ctxt, +TestConverter::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener->OnStopRequest(request, ctxt, aStatus, aStatusArg); + return mListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); }; diff --git a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp index c27bc708918..379d2034911 100644 --- a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp +++ b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp @@ -80,7 +80,7 @@ public: EndListener() {NS_INIT_ISUPPORTS();}; // nsIStreamListener method - NS_IMETHOD OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, + NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv; @@ -102,12 +102,12 @@ public: } // nsIStreamObserver methods - NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt) + NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest* request, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { return NS_OK; @@ -120,7 +120,7 @@ NS_IMPL_ISUPPORTS1(EndListener, nsIStreamListener); //////////////////////////////////////////////////////////////////////// -nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) { +nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIChannel* aChannel) { nsString data; data.AssignWithConversion(aData); nsCOMPtr dataStream; @@ -129,9 +129,9 @@ nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* if (NS_FAILED(rv)) return rv; dataStream = do_QueryInterface(sup, &rv); if (NS_FAILED(rv)) return rv; - return aListener->OnDataAvailable(request, nsnull, dataStream, 0, -1); + return aListener->OnDataAvailable(aChannel, nsnull, dataStream, 0, -1); } -#define SEND_DATA(x) SendData(x, converterListener, nsnull) +#define SEND_DATA(x) SendData(x, converterListener, dummyChannel) int main(int argc, char* argv[]) @@ -272,11 +272,11 @@ main(int argc, char* argv[]) if (NS_FAILED(rv)) return rv; // we need a dummy channel for the async calls. - nsCOMPtr channel; + nsCOMPtr dummyChannel; nsCOMPtr dummyURI; rv = serv->NewURI("http://neverneverland.com", nsnull, getter_AddRefs(dummyURI)); if (NS_FAILED(rv)) return rv; - rv = NS_NewInputStreamChannel(getter_AddRefs(channel), + rv = NS_NewInputStreamChannel(getter_AddRefs(dummyChannel), dummyURI, nsnull, // inStr "multipart/x-mixed-replacE;boundary=thisrandomstring", @@ -300,10 +300,9 @@ main(int argc, char* argv[]) // that will receive the converted data. Let's mimic On*() calls and get the conversion // going. Typically these On*() calls would be made inside their respective wrappers On*() // methods. - rv = converterListener->OnStartRequest(nsnull, nsnull); + rv = converterListener->OnStartRequest(dummyChannel, nsnull); if (NS_FAILED(rv)) return rv; - rv = SEND_DATA("--thisrandomstring\r\nContent-type: text/html\r\n\r\n

Please stand by...

\r\n"); if (NS_FAILED(rv)) return rv; @@ -326,7 +325,7 @@ main(int argc, char* argv[]) if (NS_FAILED(rv)) return rv; // Finish the request. - rv = converterListener->OnStopRequest(nsnull, nsnull, rv, nsnull); + rv = converterListener->OnStopRequest(dummyChannel, nsnull, rv, nsnull); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/netwerk/test/Makefile.in b/mozilla/netwerk/test/Makefile.in index 9b922bc2047..2959cc0908d 100644 --- a/mozilla/netwerk/test/Makefile.in +++ b/mozilla/netwerk/test/Makefile.in @@ -35,12 +35,11 @@ CPPSRCS = \ TestSocketIO.cpp \ TestSocketInput.cpp \ TestSocketTransport.cpp \ - TestOverlappedIO.cpp \ TestFileInput.cpp \ - TestFileTransport.cpp \ TestProtocols.cpp \ urltest.cpp \ TestFileInput2.cpp \ + TestFileTransport.cpp \ TestRes.cpp \ TestCallbacks.cpp \ TestSyncHTTP.cpp \ diff --git a/mozilla/netwerk/test/TestCacheMgr.cpp b/mozilla/netwerk/test/TestCacheMgr.cpp index 2173cb96589..70306b04b18 100644 --- a/mozilla/netwerk/test/TestCacheMgr.cpp +++ b/mozilla/netwerk/test/TestCacheMgr.cpp @@ -23,7 +23,7 @@ #include "nsIOutputStream.h" #include "nsIEventQueue.h" #include "nsIEventQueueService.h" -#include "nsITransport.h" +#include "nsIChannel.h" #include "nsCOMPtr.h" #include "nsINetDataCache.h" @@ -192,13 +192,13 @@ public: return NS_OK; } - NS_IMETHOD OnStartRequest(nsIRequest *request, + NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context) { mStartTime = PR_IntervalNow(); return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIRequest *request, + NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -217,7 +217,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { PRIntervalTime endTime; PRIntervalTime duration; @@ -280,11 +280,11 @@ nsresult TestReadStream(nsICachedNetData *cacheEntry, nsITestDataStream *testDataStream, PRUint32 expectedStreamLength) { - nsCOMPtr transport; + nsCOMPtr channel; nsresult rv; PRUint32 actualContentLength; - rv = cacheEntry->NewTransport(0, getter_AddRefs(transport)); + rv = cacheEntry->NewChannel(0, getter_AddRefs(channel)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); rv = cacheEntry->GetStoredContentLength(&actualContentLength); @@ -297,8 +297,7 @@ TestReadStream(nsICachedNetData *cacheEntry, nsITestDataStream *testDataStream, rv = reader->Init(testDataStream, expectedStreamLength); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - nsCOMPtr request; - rv = transport->AsyncRead(0, reader, 0, -1, 0, getter_AddRefs(request)); + rv = channel->AsyncRead(0, reader); NS_ASSERTION(NS_SUCCEEDED(rv), " "); reader->Release(); @@ -424,7 +423,7 @@ FillCache(nsINetDataCacheManager *aCache, PRUint32 aFlags, PRUint32 aCacheCapaci nsresult rv; PRBool inCache; nsCOMPtr cacheEntry; - nsCOMPtr transport; + nsCOMPtr channel; nsCOMPtr outStream; nsCOMPtr containingCache; char buf[1000]; @@ -488,13 +487,13 @@ FillCache(nsINetDataCacheManager *aCache, PRUint32 aFlags, PRUint32 aCacheCapaci // Cache manager complains if expiration set without setting last-modified time rv = cacheEntry->SetLastModifiedTime(expirationTime); - rv = cacheEntry->NewTransport(0, getter_AddRefs(transport)); + rv = cacheEntry->NewChannel(0, getter_AddRefs(channel)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); rv = cacheEntry->GetCache(getter_AddRefs(containingCache)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - rv = transport->OpenOutputStream(0, -1, 0,getter_AddRefs(outStream)); + rv = channel->OpenOutputStream(getter_AddRefs(outStream)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); int streamLength = randomStream->Next() % MAX_CONTENT_LENGTH; diff --git a/mozilla/netwerk/test/TestCallbacks.cpp b/mozilla/netwerk/test/TestCallbacks.cpp index b61f5ca92bc..264d6100f7a 100644 --- a/mozilla/netwerk/test/TestCallbacks.cpp +++ b/mozilla/netwerk/test/TestCallbacks.cpp @@ -83,7 +83,7 @@ public: Consumer(); virtual ~Consumer(); nsresult Init(nsIURI *aURI, nsIChannel *aChannel, nsISupports *aContext); - nsresult Validate(nsIRequest *request, nsISupports *aContext); + nsresult Validate(nsIChannel *aChannel, nsISupports *aContext); // member data PRBool mOnStart; // have we received an OnStart? @@ -100,7 +100,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(Consumer, nsIStreamListener, nsIStreamObserver); // nsIStreamObserver implementation NS_IMETHODIMP -Consumer::OnStartRequest(nsIRequest *request, nsISupports* aContext) { +Consumer::OnStartRequest(nsIChannel *aChannel, nsISupports* aContext) { fprintf(stderr, "Consumer::OnStart() -> in\n\n"); if (mOnStart) { @@ -108,7 +108,7 @@ Consumer::OnStartRequest(nsIRequest *request, nsISupports* aContext) { } mOnStart = PR_TRUE; - nsresult rv = Validate(request, aContext); + nsresult rv = Validate(aChannel, aContext); if (NS_FAILED(rv)) return rv; fprintf(stderr, "Consumer::OnStart() -> out\n\n"); @@ -116,7 +116,7 @@ Consumer::OnStartRequest(nsIRequest *request, nsISupports* aContext) { } NS_IMETHODIMP -Consumer::OnStopRequest(nsIRequest *request, nsISupports *aContext, +Consumer::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { fprintf(stderr, "Consumer::OnStop() -> in\n\n"); @@ -133,7 +133,7 @@ Consumer::OnStopRequest(nsIRequest *request, nsISupports *aContext, mOnStop = PR_TRUE; - nsresult rv = Validate(request, aContext); + nsresult rv = Validate(aChannel, aContext); if (NS_FAILED(rv)) return rv; fprintf(stderr, "Consumer::OnStop() -> out\n\n"); @@ -143,7 +143,7 @@ Consumer::OnStopRequest(nsIRequest *request, nsISupports *aContext, // nsIStreamListener implementation NS_IMETHODIMP -Consumer::OnDataAvailable(nsIRequest *request, nsISupports *aContext, +Consumer::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 aOffset, PRUint32 aLength) { fprintf(stderr, "Consumer::OnData() -> in\n\n"); @@ -155,7 +155,7 @@ Consumer::OnDataAvailable(nsIRequest *request, nsISupports *aContext, mOnDataCount += 1; - nsresult rv = Validate(request, aContext); + nsresult rv = Validate(aChannel, aContext); if (NS_FAILED(rv)) return rv; fprintf(stderr, "Consumer::OnData() -> out\n\n"); @@ -188,7 +188,7 @@ Consumer::~Consumer() { } nsresult -Consumer::Init(nsIURI *aURI, nsIChannel* aChannel, nsISupports *aContext) { +Consumer::Init(nsIURI *aURI, nsIChannel *aChannel, nsISupports *aContext) { mURI = aURI; mChannel = aChannel; mContext = do_QueryInterface(aContext); @@ -196,11 +196,9 @@ Consumer::Init(nsIURI *aURI, nsIChannel* aChannel, nsISupports *aContext) { } nsresult -Consumer::Validate(nsIRequest* request, nsISupports *aContext) { +Consumer::Validate(nsIChannel *aChannel, nsISupports *aContext) { nsresult rv = NS_OK; nsCOMPtr uri; - nsCOMPtr aChannel = do_QueryInterface(request); - rv = aChannel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; @@ -312,6 +310,6 @@ nsresult StartLoad(char *aURISpec) { if (NS_FAILED(rv)) return rv; // kick off the load - nsCOMPtr request; - return channel->AsyncOpen(NS_STATIC_CAST(nsIStreamListener*, consumer), contextSup); + return channel->AsyncRead(NS_STATIC_CAST(nsIStreamListener*, consumer), + contextSup); } diff --git a/mozilla/netwerk/test/TestFileInput.cpp b/mozilla/netwerk/test/TestFileInput.cpp index 1221ce872bd..85a22fcbc47 100644 --- a/mozilla/netwerk/test/TestFileInput.cpp +++ b/mozilla/netwerk/test/TestFileInput.cpp @@ -110,7 +110,7 @@ public: return NS_OK; } - NS_IMETHOD OnStartRequest(nsIRequest *request, + NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context) { PR_EnterMonitor(mMonitor); printf("start binding\n"); @@ -119,7 +119,7 @@ public: return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIRequest *request, + NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -140,7 +140,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; PR_EnterMonitor(mMonitor); @@ -347,11 +347,11 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts) reader->QueryInterface(NS_GET_IID(nsIStreamListener), (void**)&listener); NS_ASSERTION(listener, "QI failed"); - nsITransport* trans; + nsIChannel* trans; rv = fts->CreateTransport(file, PR_RDONLY, 0, &trans); NS_ASSERTION(NS_SUCCEEDED(rv), "create failed"); - nsCOMPtr request; - rv = trans->AsyncRead(nsnull, listener, 0, -1, 0, getter_AddRefs(request)); + + rv = trans->AsyncRead(nsnull, listener); NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed"); // the reader thread will hang on to these objects until it quits diff --git a/mozilla/netwerk/test/TestFileInput2.cpp b/mozilla/netwerk/test/TestFileInput2.cpp index 0dba1849eeb..cad66aa679d 100644 --- a/mozilla/netwerk/test/TestFileInput2.cpp +++ b/mozilla/netwerk/test/TestFileInput2.cpp @@ -257,14 +257,14 @@ public: rv = NS_NewLocalFileChannel(getter_AddRefs(inCh), mInPath); if (NS_FAILED(rv)) return rv; - rv = inCh->Open(getter_AddRefs(inStr)); + rv = inCh->OpenInputStream(getter_AddRefs(inStr)); if (NS_FAILED(rv)) return rv; - //rv = NS_NewLocalFileChannel(getter_AddRefs(outCh), mOutPath); - //if (NS_FAILED(rv)) return rv; + rv = NS_NewLocalFileChannel(getter_AddRefs(outCh), mOutPath); + if (NS_FAILED(rv)) return rv; - //rv = outCh->OpenOutputStream(0, -1, 0, getter_AddRefs(outStr)); - //if (NS_FAILED(rv)) return rv; + rv = outCh->OpenOutputStream(getter_AddRefs(outStr)); + if (NS_FAILED(rv)) return rv; // Copy from one to the other rv = Copy(inStr, outStr, mBuffer, mBufferSize, ©Count); diff --git a/mozilla/netwerk/test/TestFileTransport.cpp b/mozilla/netwerk/test/TestFileTransport.cpp index 1f2c5b23ded..015e3b175cc 100644 --- a/mozilla/netwerk/test/TestFileTransport.cpp +++ b/mozilla/netwerk/test/TestFileTransport.cpp @@ -21,8 +21,7 @@ */ #include "nsIFileTransportService.h" -#include "nsITransport.h" -#include "nsIRequest.h" +#include "nsIChannel.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsCOMPtr.h" @@ -59,12 +58,12 @@ class MyListener : public nsIStreamListener { public: NS_DECL_ISUPPORTS - NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { + NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { PRINTF(("starting\n")); return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { PRINTF(("ending status=%0x total=%d\n", aStatus, mTotal)); if (--mStopCount == 0) @@ -72,7 +71,7 @@ public: return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { PRINTF(("receiving %d bytes\n", count)); @@ -146,7 +145,7 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length) NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsITransport* fileTrans; + nsIChannel* fileTrans; nsCOMPtr file; rv = NS_NewLocalFile(fileName, PR_FALSE, getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; @@ -161,8 +160,11 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length) if (NS_FAILED(rv)) return rv; gDone = PR_FALSE; - nsCOMPtr request; - rv = fileTrans->AsyncRead(listener, nsnull, offset, length, 0, getter_AddRefs(request)); + rv = fileTrans->SetTransferOffset(offset); + if (NS_FAILED(rv)) return rv; + rv = fileTrans->SetTransferCount(length); + if (NS_FAILED(rv)) return rv; + rv = fileTrans->AsyncRead(listener, nsnull); if (NS_FAILED(rv)) return rv; while (!gDone) { @@ -192,7 +194,7 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length) nsCAutoString outFile(fileName); outFile.Append(".out"); - nsITransport* fileTrans; + nsIChannel* fileTrans; nsCOMPtr file; rv = NS_NewLocalFile(outFile, PR_FALSE, getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; @@ -216,8 +218,11 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length) if (NS_FAILED(rv)) return rv; gDone = PR_FALSE; - nsCOMPtr request; - rv = NS_AsyncWriteFromStream(getter_AddRefs(request), fileTrans, inStr, offset, length, 0, listener); + rv = fileTrans->SetTransferOffset(offset); + if (NS_FAILED(rv)) return rv; + rv = fileTrans->SetTransferCount(length); + if (NS_FAILED(rv)) return rv; + rv = NS_AsyncWriteFromStream(fileTrans, inStr, listener, nsnull); if (NS_FAILED(rv)) return rv; while (!gDone) { @@ -235,20 +240,18 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length) //////////////////////////////////////////////////////////////////////////////// -#if 0 class MyOpenObserver : public nsIStreamObserver { public: NS_DECL_ISUPPORTS - NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { + NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { nsresult rv; char* contentType; - nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetContentType(&contentType); if (NS_FAILED(rv)) return rv; PRInt32 length; - rv = cr->GetContentLength(&length); + rv = channel->GetContentLength(&length); if (NS_FAILED(rv)) return rv; PRINTF(("stream opened: content type = %s, length = %d\n", contentType, length)); @@ -256,7 +259,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { PRINTF(("stream closed: status %x\n", aStatus)); return NS_OK; @@ -267,7 +270,6 @@ public: }; NS_IMPL_ISUPPORTS1(MyOpenObserver, nsIStreamObserver); -#endif //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/test/TestProtocols.cpp b/mozilla/netwerk/test/TestProtocols.cpp index d30101f47e8..2fa12cd6bc3 100644 --- a/mozilla/netwerk/test/TestProtocols.cpp +++ b/mozilla/netwerk/test/TestProtocols.cpp @@ -65,8 +65,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static int gKeepRunning = 0; static PRBool gVerbose = PR_FALSE; static nsIEventQueue* gEventQ = nsnull; -static PRBool gAskUserForInput = PR_FALSE; - class URLLoadInfo : public nsISupports { @@ -166,7 +164,7 @@ TestHTTPEventSink::OnHeadersAvailable(nsISupports* context) header->GetField(getter_AddRefs(key)); key->ToString(field); nsCAutoString theField; - theField.AssignWithConversion(field); + theField.AssignWithConversion(field); printf("\t%s: ", theField.GetBuffer()); header->GetValue(getter_Copies(value)); @@ -194,7 +192,7 @@ TestHTTPEventSink::OnHeadersAvailable(nsISupports* context) header->GetField(getter_AddRefs(key)); key->ToString(field); nsCAutoString theField; - theField.AssignWithConversion(field); + theField.AssignWithConversion(field); printf("\t%s: ", theField.GetBuffer()); header->GetValue(getter_Copies(value)); @@ -264,17 +262,16 @@ protected: NS_IMPL_ISUPPORTS1(OpenObserver, nsIStreamObserver); NS_IMETHODIMP -OpenObserver::OnStartRequest(nsIRequest *request, nsISupports* context) +OpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) { - printf("\n+++ OpenObserver::OnStartRequest +++. Context = %p\n", (void*)context); + printf("\n+++ OpenObserver::OnStartRequest +++. Context = %p\n", context); char* type; PRInt32 length = -1; nsresult rv; - nsCOMPtr pChan(do_QueryInterface(context)); - rv = pChan->GetContentType(&type); + rv = channel->GetContentType(&type); NS_ASSERTION(NS_SUCCEEDED(rv), "GetContentType failed"); - rv = pChan->GetContentLength(&length); + rv = channel->GetContentLength(&length); NS_ASSERTION(NS_SUCCEEDED(rv), "GetContentLength failed"); printf(" contentType = %s length = %d\n", type, length); nsCRT::free(type); @@ -283,12 +280,12 @@ OpenObserver::OnStartRequest(nsIRequest *request, nsISupports* context) } NS_IMETHODIMP -OpenObserver::OnStopRequest(nsIRequest *request, nsISupports* context, +OpenObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { printf("\n+++ OpenObserver::OnStopRequest (status = %x) +++." "\tContext = %p\n", - aStatus, (void*)context); + aStatus, context); return NS_OK; } @@ -308,7 +305,7 @@ NS_IMPL_ISUPPORTS(InputTestConsumer,NS_GET_IID(nsIStreamListener)); NS_IMETHODIMP -InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context) +InputTestConsumer::OnStartRequest(nsIChannel* channel, nsISupports* context) { URLLoadInfo* info = (URLLoadInfo*)context; if (info) { @@ -336,7 +333,7 @@ InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context) NS_IMETHODIMP -InputTestConsumer::OnDataAvailable(nsIRequest *request, +InputTestConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -370,31 +367,9 @@ InputTestConsumer::OnDataAvailable(nsIRequest *request, return NS_OK; } -PR_STATIC_CALLBACK(void) DecrementDestroyHandler(PLEvent *self) -{ - PR_DELETE(self); -} - - -PR_STATIC_CALLBACK(void*) DecrementEventHandler(PLEvent *self) -{ - gKeepRunning--; - return nsnull; -} - -void FireDecrement() -{ - PLEvent *event = PR_NEW(PLEvent); - PL_InitEvent(event, - nsnull, - DecrementEventHandler, - DecrementDestroyHandler); - - gEventQ->PostEvent(event); -} NS_IMETHODIMP -InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, +InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { URLLoadInfo* info = (URLLoadInfo*)context; @@ -410,7 +385,7 @@ InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, connectTime = (info->mConnectTime/1000.0)/1000.0; readTime = ((info->mTotalTime-info->mConnectTime)/1000.0)/1000.0; - nsCOMPtr pHTTPCon(do_QueryInterface(request)); + nsCOMPtr pHTTPCon(do_QueryInterface(channel)); if (pHTTPCon) { pHTTPCon->GetResponseStatus(&httpStatus); bHTTPURL = PR_TRUE; @@ -447,8 +422,7 @@ InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, nsCRT::free(location); } */ - FireDecrement(); - + gKeepRunning -= 1; return NS_OK; } @@ -547,8 +521,9 @@ nsresult StartLoadingURL(const char* aUrlString) return NS_ERROR_OUT_OF_MEMORY; } - rv = pChannel->AsyncOpen(listener, // IStreamListener consumer - info); + + rv = pChannel->AsyncRead(listener, // IStreamListener consumer + info); // ISupports context if (NS_SUCCEEDED(rv)) { gKeepRunning += 1; @@ -605,19 +580,6 @@ nsresult LoadURLsFromFile(char *aFileName) return NS_OK; } - -nsresult LoadURLFromConsole() -{ - char buffer[1024]; - printf("Enter URL (\"q\" to start): "); - scanf("%s", buffer); - if (buffer[0]=='q') - gAskUserForInput = PR_FALSE; - else - StartLoadingURL(buffer); - return NS_OK; -} - int main(int argc, char* argv[]) { @@ -654,7 +616,6 @@ main(int argc, char* argv[]) if (NS_FAILED(rv)) return rv; #endif // NECKO - int i; printf("\nTrying to load:\n"); for (i=1; i @@ -204,13 +203,13 @@ public: return NS_OK; } - NS_IMETHOD OnStartRequest(nsIRequest *request, + NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context) { mStartTime = PR_IntervalNow(); return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIRequest *request, + NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -229,7 +228,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { PRIntervalTime endTime; PRIntervalTime duration; @@ -290,11 +289,11 @@ nsresult TestReadStream(nsINetDataCacheRecord *record, nsITestDataStream *testDataStream, PRUint32 expectedStreamLength) { - nsCOMPtr transport; + nsCOMPtr channel; nsresult rv; PRUint32 actualContentLength; - rv = record->NewTransport(0, getter_AddRefs(transport)); + rv = record->NewChannel(0, getter_AddRefs(channel)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); rv = record->GetStoredContentLength(&actualContentLength); @@ -306,8 +305,7 @@ TestReadStream(nsINetDataCacheRecord *record, nsITestDataStream *testDataStream, rv = reader->Init(testDataStream, expectedStreamLength); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - nsCOMPtr request; - rv = transport->AsyncRead(0, reader, 0, -1, 0, getter_AddRefs(request)); + rv = channel->AsyncRead(0, reader); NS_ASSERTION(NS_SUCCEEDED(rv), " "); reader->Release(); @@ -525,7 +523,7 @@ TestOffsetWrites(nsINetDataCache *cache) { nsresult rv; nsCOMPtr record; - nsCOMPtr transport; + nsCOMPtr channel; nsCOMPtr outStream; char buf[512]; char cacheKey[CACHE_KEY_LENGTH]; @@ -545,12 +543,13 @@ TestOffsetWrites(nsINetDataCache *cache) CounterStream *counterStream; int i; for (i = 0; i < 100; i++) { - rv = record->NewTransport(0, getter_AddRefs(transport)); + rv = record->NewChannel(0, getter_AddRefs(channel)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); startingOffset = streamLength ? streamLength - (randomStream->Next() % sizeof buf): 0; - - rv = transport->OpenOutputStream(startingOffset, -1, 0, getter_AddRefs(outStream)); + rv = channel->SetTransferOffset(startingOffset); + NS_ASSERTION(NS_SUCCEEDED(rv), "SetTransferOffset failed"); + rv = channel->OpenOutputStream(getter_AddRefs(outStream)); NS_ASSERTION(NS_SUCCEEDED(rv), "OpenOutputStream failed"); counterStream = new CounterStream(startingOffset); @@ -584,7 +583,7 @@ FillCache(nsINetDataCache *cache) nsresult rv; PRBool inCache; nsCOMPtr record; - nsCOMPtr transport; + nsCOMPtr channel; nsCOMPtr outStream; char buf[1000]; PRUint32 metaDataLength; @@ -629,10 +628,10 @@ FillCache(nsINetDataCache *cache) randomStream->Read(metaData, sizeof metaData); record->SetMetaData(sizeof metaData, metaData); - rv = record->NewTransport(0, getter_AddRefs(transport)); + rv = record->NewChannel(0, getter_AddRefs(channel)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - rv = transport->OpenOutputStream(0, -1, 0, getter_AddRefs(outStream)); + rv = channel->OpenOutputStream(getter_AddRefs(outStream)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); PRUint32 beforeOccupancy; diff --git a/mozilla/netwerk/test/TestRes.cpp b/mozilla/netwerk/test/TestRes.cpp index 32690c6f22e..dd9ab94afa8 100644 --- a/mozilla/netwerk/test/TestRes.cpp +++ b/mozilla/netwerk/test/TestRes.cpp @@ -76,7 +76,7 @@ TestOpenInputStream(const char* url) if (NS_FAILED(rv)) return rv; nsCOMPtr in; - rv = channel->Open(getter_AddRefs(in)); + rv = channel->OpenInputStream(getter_AddRefs(in)); if (NS_FAILED(rv)) { fprintf(stdout, "failed to OpenInputStream for %s\n", url); return NS_OK; @@ -127,11 +127,9 @@ public: Listener() { NS_INIT_REFCNT(); } virtual ~Listener() {} - NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { + NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { nsresult rv; nsCOMPtr uri; - nsCOMPtr channel = do_QueryInterface(request); - rv = channel->GetURI(getter_AddRefs(uri)); if (NS_SUCCEEDED(rv)) { char* str; @@ -144,12 +142,10 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; nsCOMPtr uri; - nsCOMPtr channel = do_QueryInterface(request); - rv = channel->GetURI(getter_AddRefs(uri)); if (NS_SUCCEEDED(rv)) { char* str; @@ -163,7 +159,7 @@ public: return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv; @@ -209,7 +205,8 @@ TestAsyncRead(const char* url) nsCOMPtr listener = new Listener(); if (listener == nsnull) return NS_ERROR_OUT_OF_MEMORY; - rv = channel->AsyncOpen(nsnull, listener); + + rv = channel->AsyncRead(nsnull, listener); if (NS_FAILED(rv)) return rv; while (!gDone) { diff --git a/mozilla/netwerk/test/TestSocketIO.cpp b/mozilla/netwerk/test/TestSocketIO.cpp index 772bd351936..c3d39e784c7 100644 --- a/mozilla/netwerk/test/TestSocketIO.cpp +++ b/mozilla/netwerk/test/TestSocketIO.cpp @@ -34,8 +34,7 @@ #include "nsISocketTransportService.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" -#include "nsITransport.h" -#include "nsIRequest.h" +#include "nsIChannel.h" #include "nsIStreamProvider.h" #include "nsIStreamListener.h" #include "nsIPipe.h" @@ -69,53 +68,54 @@ static nsIEventQueue* gEventQ = nsnull; class TestListener : public nsIStreamListener { public: - TestListener() { NS_INIT_ISUPPORTS(); } - virtual ~TestListener() {} - NS_DECL_ISUPPORTS - NS_DECL_NSISTREAMOBSERVER - NS_DECL_NSISTREAMLISTENER + TestListener() { NS_INIT_ISUPPORTS(); } + virtual ~TestListener() {} + + NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER }; NS_IMPL_ISUPPORTS2(TestListener, - nsIStreamObserver, - nsIStreamListener); + nsIStreamObserver, + nsIStreamListener); NS_IMETHODIMP -TestListener::OnStartRequest(nsIRequest* request, nsISupports* context) +TestListener::OnStartRequest(nsIChannel* channel, nsISupports* context) { - LOG(("TestListener::OnStartRequest\n")); - return NS_OK; + LOG(("TestListener::OnStartRequest\n")); + return NS_OK; } NS_IMETHODIMP -TestListener::OnDataAvailable(nsIRequest* request, - nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength) +TestListener::OnDataAvailable(nsIChannel* channel, + nsISupports* context, + nsIInputStream *aIStream, + PRUint32 aSourceOffset, + PRUint32 aLength) { LOG(("TestListener::OnDataAvailable [offset=%u length=%u]\n", aSourceOffset, aLength)); - char buf[1025]; - PRUint32 amt; + char buf[1025]; + PRUint32 amt; while (1) { - aIStream->Read(buf, 1024, &amt); + aIStream->Read(buf, 1024, &amt); if (amt == 0) break; - buf[amt] = '\0'; - puts(buf); + buf[amt] = '\0'; + puts(buf); } - return NS_OK; + return NS_OK; } NS_IMETHODIMP -TestListener::OnStopRequest(nsIRequest* request, nsISupports* context, - nsresult aStatus, const PRUnichar* aStatusArg) +TestListener::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { LOG(("TestListener::OnStopRequest [aStatus=%x]\n", aStatus)); - gKeepRunning = 0; - return NS_OK; + gKeepRunning = 0; + return NS_OK; } // @@ -127,15 +127,16 @@ TestListener::OnStopRequest(nsIRequest* request, nsISupports* context, class TestProvider : public nsIStreamProvider { public: - TestProvider(char *data); - virtual ~TestProvider(); - NS_DECL_ISUPPORTS - NS_DECL_NSISTREAMOBSERVER - NS_DECL_NSISTREAMPROVIDER + TestProvider(char *data); + virtual ~TestProvider(); + + NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMPROVIDER protected: - nsCOMPtr mData; + nsCOMPtr mData; }; NS_IMPL_ISUPPORTS2(TestProvider, @@ -144,48 +145,42 @@ NS_IMPL_ISUPPORTS2(TestProvider, TestProvider::TestProvider(char *data) { - NS_INIT_ISUPPORTS(); - NS_NewByteArrayInputStream(getter_AddRefs(mData), data, strlen(data)); - LOG(("Constructing TestProvider [this=%x]\n", this)); + NS_INIT_ISUPPORTS(); + NS_NewByteArrayInputStream(getter_AddRefs(mData), data, strlen(data)); + LOG(("Constructing TestProvider [this=%x]\n", this)); } TestProvider::~TestProvider() { - LOG(("Destroying TestProvider [this=%x]\n", this)); + LOG(("Destroying TestProvider [this=%x]\n", this)); } NS_IMETHODIMP -TestProvider::OnStartRequest(nsIRequest* request, nsISupports* context) +TestProvider::OnStartRequest(nsIChannel* channel, nsISupports* context) { - LOG(("TestProvider::OnStartRequest [this=%x]\n", this)); - return NS_OK; + LOG(("TestProvider::OnStartRequest [this=%x]\n", this)); + return NS_OK; } NS_IMETHODIMP -TestProvider::OnStopRequest(nsIRequest* request, nsISupports* context, - nsresult aStatus, const PRUnichar* aStatusArg) +TestProvider::OnStopRequest(nsIChannel* channel, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { LOG(("TestProvider::OnStopRequest [status=%x]\n", aStatus)); nsCOMPtr listener = do_QueryInterface(new TestListener()); - if (NS_SUCCEEDED(aStatus)) { - nsCOMPtr treq = do_QueryInterface(request); - nsCOMPtr transport; - treq->GetTransport(getter_AddRefs(transport)); - if (transport) { - nsCOMPtr readRequest; - transport->AsyncRead(listener, nsnull, 0, 0, 0, getter_AddRefs(readRequest)); - } - } else - gKeepRunning = 0; + if (NS_SUCCEEDED(aStatus)) + channel->AsyncRead(listener, nsnull); + else + gKeepRunning = 0; - return NS_OK; + return NS_OK; } NS_IMETHODIMP -TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context, - nsIOutputStream *output, PRUint32 offset, PRUint32 count) +TestProvider::OnDataWritable(nsIChannel *channel, nsISupports *context, + nsIOutputStream *output, PRUint32 offset, PRUint32 count) { LOG(("TestProvider::OnDataWritable [offset=%u, count=%u]\n", offset, count)); PRUint32 writeCount; @@ -193,7 +188,7 @@ TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context, // Zero bytes written on success indicates EOF if (NS_SUCCEEDED(rv) && (writeCount == 0)) return NS_BASE_STREAM_CLOSED; - return rv; + return rv; } // @@ -204,7 +199,6 @@ TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context, nsresult WriteRequest(nsIOutputStream *os, const char *request) { - LOG(("WriteRequest [request=%s]\n", request)); PRUint32 n; return os->Write(request, strlen(request), &n); } @@ -245,7 +239,7 @@ usage(char **argv) int main(int argc, char* argv[]) { - nsresult rv; + nsresult rv; #ifdef XP_OS2_VACPP signal(SIGSEGV, (_SigFunc)sighandler); @@ -273,8 +267,8 @@ main(int argc, char* argv[]) char *fileName = argv[2+i]; int port = 80; - // Create the Event Queue for this thread... - NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv); + // Create the Event Queue for this thread... + NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv); if (NS_FAILED(rv)) { NS_WARNING("failed to create: event queue service!"); return rv; @@ -286,10 +280,10 @@ main(int argc, char* argv[]) return rv; } - eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ); + eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ); - // Create the Socket transport service... - NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv); + // Create the Socket transport service... + NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) { NS_WARNING("failed to create: socket transport service!"); return rv; @@ -307,85 +301,74 @@ main(int argc, char* argv[]) fileName, hostName); LOG(("Request [\n%s]\n", buffer)); - // Create the socket transport... - nsCOMPtr transport; + // Create the socket transport... + nsCOMPtr transport; rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, getter_AddRefs(transport)); if (NS_FAILED(rv)) { NS_WARNING("failed to create: socket transport!"); return rv; - } + } gElapsedTime = PR_Now(); if (!sync) { - nsCOMPtr request; - rv = transport->AsyncWrite(new TestProvider(buffer), nsnull, 0, 0, 0, getter_AddRefs(request)); + rv = transport->AsyncWrite(new TestProvider(buffer), nsnull); if (NS_FAILED(rv)) { NS_WARNING("failed calling: AsyncWrite!"); return rv; - } + } - // Enter the message pump to allow the URL load to proceed. - while ( gKeepRunning ) { + // Enter the message pump to allow the URL load to proceed. + while ( gKeepRunning ) { #ifdef WIN32 - MSG msg; - if (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - else - gKeepRunning = FALSE; -#elif XP_MAC - /* Mac stuff is missing here! */ -#elif XP_OS2 - QMSG qmsg; - if (WinGetMsg(0, &qmsg, 0, 0, 0)) - WinDispatchMsg(0, &qmsg); - else - gKeepRunning = FALSE; + MSG msg; + if (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else + gKeepRunning = FALSE; #else - PLEvent *gEvent; +#ifdef XP_MAC + /* Mac stuff is missing here! */ +#else +#ifdef XP_OS2 + QMSG qmsg; + if (WinGetMsg(0, &qmsg, 0, 0, 0)) + WinDispatchMsg(0, &qmsg); + else + gKeepRunning = FALSE; +#else + PLEvent *gEvent; rv = gEventQ->WaitForEvent(&gEvent); - rv = gEventQ->HandleEvent(gEvent); + rv = gEventQ->HandleEvent(gEvent); #endif - } +#endif +#endif + } } else { // synchronous write { nsCOMPtr os; - rv = transport->OpenOutputStream(0, 0, 0, getter_AddRefs(os)); - if (NS_FAILED(rv)) { - LOG(("OpenOutputStream failed [rv=%x]\n", rv)); - return rv; - } + rv = transport->OpenOutputStream(getter_AddRefs(os)); + if (NS_FAILED(rv)) return rv; rv = WriteRequest(os, buffer); - if (NS_FAILED(rv)) { - LOG(("WriteRequest failed [rv=%x]\n", rv)); - return rv; - } + if (NS_FAILED(rv)) return rv; } // synchronous read { nsCOMPtr is; - rv = transport->OpenInputStream(0, 0, 0, getter_AddRefs(is)); - if (NS_FAILED(rv)) { - LOG(("OpenInputStream failed [rv=%x]\n", rv)); - return rv; - } + rv = transport->OpenInputStream(getter_AddRefs(is)); + if (NS_FAILED(rv)) return rv; rv = ReadResponse(is); - if (NS_FAILED(rv)) { - LOG(("ReadResponse failed [rv=%x]\n", rv)); - return rv; - } + if (NS_FAILED(rv)) return rv; } } - PRTime endTime; - endTime = PR_Now(); + PRTime endTime; + endTime = PR_Now(); LOG(("Elapsed time: %d\n", (PRInt32)(endTime/1000UL - gElapsedTime/1000UL))); - sts->Shutdown(); - return 0; + sts->Shutdown(); + return 0; } - diff --git a/mozilla/netwerk/test/TestSocketInput.cpp b/mozilla/netwerk/test/TestSocketInput.cpp index a08e1117975..e79e28f9946 100644 --- a/mozilla/netwerk/test/TestSocketInput.cpp +++ b/mozilla/netwerk/test/TestSocketInput.cpp @@ -33,8 +33,7 @@ #include "nsISocketTransportService.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" -#include "nsITransport.h" -#include "nsIRequest.h" +#include "nsIChannel.h" #include "nsIStreamListener.h" #include "nsIInputStream.h" @@ -54,14 +53,14 @@ public: NS_DECL_ISUPPORTS // IStreamListener interface... - NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports* context); + NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); - NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports* context, + NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength); - NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg); }; @@ -82,7 +81,7 @@ NS_IMPL_ISUPPORTS(InputTestConsumer,kIStreamListenerIID); NS_IMETHODIMP -InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context) +InputTestConsumer::OnStartRequest(nsIChannel* channel, nsISupports* context) { printf("+++ OnStartRequest +++\n"); return NS_OK; @@ -90,7 +89,7 @@ InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context) NS_IMETHODIMP -InputTestConsumer::OnDataAvailable(nsIRequest *request, +InputTestConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -111,7 +110,7 @@ InputTestConsumer::OnDataAvailable(nsIRequest *request, NS_IMETHODIMP -InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, +InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { gKeepRunning = 0; @@ -160,12 +159,11 @@ main(int argc, char* argv[]) NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsITransport* transport; + nsIChannel* transport; rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, &transport); if (NS_SUCCEEDED(rv)) { - nsCOMPtr request; - transport->AsyncRead(nsnull, new InputTestConsumer, 0, -1, 0, getter_AddRefs(request)); + transport->AsyncRead(nsnull, new InputTestConsumer); NS_RELEASE(transport); } diff --git a/mozilla/netwerk/test/TestSocketTransport.cpp b/mozilla/netwerk/test/TestSocketTransport.cpp index f49293fd66e..8b0ed4d7e98 100644 --- a/mozilla/netwerk/test/TestSocketTransport.cpp +++ b/mozilla/netwerk/test/TestSocketTransport.cpp @@ -34,11 +34,10 @@ #include "pprio.h" // PR_Init_Log #endif -#include "nsITransport.h" -#include "nsIRequest.h" #include "nsISocketTransportService.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" +#include "nsIChannel.h" #include "nsIStreamObserver.h" #include "nsIStreamListener.h" #include "nsIPipe.h" @@ -149,13 +148,13 @@ public: return NS_NOINTERFACE; } - NS_IMETHOD OnProgress(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { putc('+', stderr); return NS_OK; } - NS_IMETHOD OnStatus(nsIRequest *request, nsISupports *ctxt, + NS_IMETHOD OnStatus(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { putc('?', stderr); return NS_OK; @@ -168,9 +167,7 @@ protected: nsIInputStream* mInStream; nsIOutputStream* mOutStream; - nsITransport* mTransport; - nsCOMPtr mReadRequest; - nsCOMPtr mWriteRequest; + nsIChannel* mTransport; PRBool mIsAsync; PRInt32 mBufferLength; @@ -202,38 +199,38 @@ protected: NS_IMPL_ISUPPORTS1(TestConnectionOpenObserver, nsIStreamObserver); NS_IMETHODIMP -TestConnectionOpenObserver::OnStartRequest(nsIRequest *request, nsISupports* context) +TestConnectionOpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) { if (gVerbose) - printf("\n+++ TestConnectionOpenObserver::OnStartRequest +++. Context = %p\n", (void*)context); + printf("\n+++ TestConnectionOpenObserver::OnStartRequest +++. Context = %p\n", context); return NS_OK; } NS_IMETHODIMP -TestConnectionOpenObserver::OnStopRequest(nsIRequest *request, nsISupports* context, +TestConnectionOpenObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { if (gVerbose || NS_FAILED(aStatus)) printf("\n+++ TestConnectionOpenObserver::OnStopRequest (status = %x) +++." "\tContext = %p\n", - aStatus, (void*)context); + aStatus, context); return NS_OK; } //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -TestConnection::OnStartRequest(nsIRequest *request, nsISupports* context) +TestConnection::OnStartRequest(nsIChannel* channel, nsISupports* context) { if (gVerbose) - printf("\n+++ TestConnection::OnStartRequest +++. Context = %p\n", (void*)context); + printf("\n+++ TestConnection::OnStartRequest +++. Context = %p\n", context); return NS_OK; } NS_IMETHODIMP -TestConnection::OnDataAvailable(nsIRequest *request, nsISupports* context, +TestConnection::OnDataAvailable(nsIChannel* channel, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) @@ -246,7 +243,7 @@ TestConnection::OnDataAvailable(nsIRequest *request, nsISupports* context, if (gVerbose) printf("\n+++ TestConnection::OnDavaAvailable +++." "\tContext = %p length = %d\n", - (void*)context, aLength); + context, aLength); while (aLength > 0) { PRInt32 cnt = PR_MIN(TRANSFER_AMOUNT, aLength); @@ -269,13 +266,13 @@ TestConnection::OnDataAvailable(nsIRequest *request, nsISupports* context, NS_IMETHODIMP -TestConnection::OnStopRequest(nsIRequest *request, nsISupports* context, +TestConnection::OnStopRequest(nsIChannel* channel, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { if (gVerbose || NS_FAILED(aStatus)) printf("\n+++ TestConnection::OnStopRequest (status = %x) +++." "\tContext = %p\n", - aStatus, (void*)context); + aStatus, context); return NS_OK; } @@ -307,8 +304,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort, if (NS_SUCCEEDED(rv)) { // Set up the notification callbacks to provide a progress event sink. // That way we exercise the progress notification proxy code. - nsCOMPtr sink = do_GetInterface((nsIInterfaceRequestor*)this); - rv = mTransport->SetProgressEventSink(sink); + rv = mTransport->SetNotificationCallbacks(this); } } @@ -322,8 +318,8 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort, } // Synchronous transport... else { - rv = mTransport->OpenInputStream(0, -1, 0, &mInStream); - rv = mTransport->OpenOutputStream(0, -1, 0, &mOutStream); + rv = mTransport->OpenInputStream(&mInStream); + rv = mTransport->OpenOutputStream(&mOutStream); } } } @@ -373,7 +369,7 @@ TestConnection::Run(void) // // Initiate an async read... // - rv = mTransport->AsyncRead(this, mTransport, 0, -1, 0, getter_AddRefs(mReadRequest)); + rv = mTransport->AsyncRead(this, mTransport); if (NS_FAILED(rv)) { printf("Error: AsyncRead failed..."); @@ -413,7 +409,7 @@ nsresult TestConnection::WriteBuffer(void) } if (gVerbose) - printf("\n+++ Request is: %c. Context = %p\n", mBufferChar, (void*)mTransport); + printf("\n+++ Request is: %c. Context = %p\n", mBufferChar, mTransport); // Create and fill a test buffer of data... buffer = (char*)PR_Malloc(mBufferLength + 4); @@ -434,10 +430,10 @@ nsresult TestConnection::WriteBuffer(void) // Write the buffer to the server... if (NS_SUCCEEDED(rv)) { - rv = NS_AsyncWriteFromStream( - getter_AddRefs(mWriteRequest), - mTransport, mStream, 0, bytesWritten, 0, - nsnull, mTransport); + rv = mTransport->SetTransferCount(bytesWritten); + if (NS_SUCCEEDED(rv)) { + rv = NS_AsyncWriteFromStream(mTransport, mStream, nsnull, mTransport); + } } // Wait for the write to complete... if (NS_FAILED(rv)) { @@ -499,8 +495,8 @@ nsresult TestConnection::Suspend(void) { nsresult rv; - if (mReadRequest) { - rv = mReadRequest->Suspend(); + if (mTransport) { + rv = mTransport->Suspend(); } else { rv = NS_ERROR_FAILURE; } @@ -512,8 +508,8 @@ nsresult TestConnection::Resume(void) { nsresult rv; - if (mReadRequest) { - rv = mReadRequest->Resume(); + if (mTransport) { + rv = mTransport->Resume(); } else { rv = NS_ERROR_FAILURE; } diff --git a/mozilla/netwerk/test/TestSyncHTTP.cpp b/mozilla/netwerk/test/TestSyncHTTP.cpp index 74479e02526..f2b39ad50bd 100644 --- a/mozilla/netwerk/test/TestSyncHTTP.cpp +++ b/mozilla/netwerk/test/TestSyncHTTP.cpp @@ -49,9 +49,9 @@ struct TestContext { TestContext() : t1(0), t2(0), bytesRead(0), totalRead(0) - { printf("TestContext [this=%p]\n", (void*)this); } + { printf("TestContext [this=%p]\n", this); } ~TestContext() - { printf("~TestContext [this=%p]\n", (void*)this); } + { printf("~TestContext [this=%p]\n", this); } }; int @@ -78,7 +78,7 @@ main(int argc, char **argv) nsCOMPtr httpChannel = do_QueryInterface(c[i].channel); if (httpChannel) - httpChannel->SetOpenHasEventQueue(PR_FALSE); + httpChannel->SetOpenInputStreamHasEventQueue(PR_FALSE); // initialize these fields for reading c[i].bytesRead = 1; @@ -88,7 +88,7 @@ main(int argc, char **argv) for (i=0; iOpen(getter_AddRefs(c[i].inputStream)); + rv = c[i].channel->OpenInputStream(getter_AddRefs(c[i].inputStream)); RETURN_IF_FAILED(rv, "nsIChannel::OpenInputStream"); } diff --git a/mozilla/netwerk/test/TestWriteStream.cpp b/mozilla/netwerk/test/TestWriteStream.cpp index 50234197a3e..4b57b0b0a70 100644 --- a/mozilla/netwerk/test/TestWriteStream.cpp +++ b/mozilla/netwerk/test/TestWriteStream.cpp @@ -22,7 +22,6 @@ #include "nsIFileTransportService.h" #include "nsIChannel.h" -#include "nsITransport.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsCOMPtr.h" @@ -116,12 +115,14 @@ TestSyncWrite(char* filename, PRUint32 startPosition, PRInt32 length) rv = NS_NewLocalFile(filename, PR_FALSE, getter_AddRefs(fs)); if (NS_FAILED(rv)) return rv ; - nsCOMPtr transport; + nsCOMPtr transport; rv = fts->CreateTransport(fs, PR_RDWR | PR_CREATE_FILE, 0664, getter_AddRefs(transport)) ; if (NS_FAILED(rv)) return rv ; - rv = transport->OpenOutputStream(startPosition, -1, 0, getter_AddRefs(outStream)) ; + rv = transport->SetTransferOffset(startPosition); + if (NS_FAILED(rv)) return rv; + rv = transport->OpenOutputStream(getter_AddRefs(outStream)) ; if (NS_FAILED(rv)) return rv; PRIntervalTime startTime = PR_IntervalNow(); diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index b425214c371..41be60fa94d 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -152,7 +152,7 @@ CStreamListener::OnStartDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsresult aStatus) { fputs("done.\n",stdout); @@ -162,14 +162,14 @@ CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest *request) + nsIChannel* channel) { return NS_OK; } NS_IMETHODIMP CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -178,7 +178,7 @@ CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsString& aMsg) { return NS_OK; @@ -186,7 +186,7 @@ CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, + nsIChannel* channel, nsresult aStatus) { return NS_OK; diff --git a/mozilla/parser/htmlparser/src/CParserContext.cpp b/mozilla/parser/htmlparser/src/CParserContext.cpp index 4bafaaf0a63..c3bbaaacf78 100644 --- a/mozilla/parser/htmlparser/src/CParserContext.cpp +++ b/mozilla/parser/htmlparser/src/CParserContext.cpp @@ -61,7 +61,7 @@ CParserContext::CParserContext(nsScanner* aScanner, mContextType=eCTNone; mCopyUnused=aCopyUnused; mParserCommand=aCommand; - mRequest=0; + mChannel=0; mValidator=0; } @@ -92,7 +92,7 @@ CParserContext::CParserContext(const CParserContext &aContext) : mMimeType() { mStreamListenerState=aContext.mStreamListenerState; mMultipart=aContext.mMultipart; mContextType=aContext.mContextType; - mRequest=aContext.mRequest; + mChannel=aContext.mChannel; mParserCommand=aContext.mParserCommand; SetMimeType(aContext.mMimeType); } diff --git a/mozilla/parser/htmlparser/src/CParserContext.h b/mozilla/parser/htmlparser/src/CParserContext.h index e9ac2471984..9e282589875 100644 --- a/mozilla/parser/htmlparser/src/CParserContext.h +++ b/mozilla/parser/htmlparser/src/CParserContext.h @@ -72,7 +72,7 @@ public: eContextType mContextType; eAutoDetectResult mAutoDetectStatus; eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors... - nsIRequest* mRequest; // provided by necko to differnciate different input streams + nsIChannel* mChannel; // provided by necko to differnciate different input streams nsScanner* mScanner; nsIDTD* mDTD; diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index e2d35b6f1a0..7f9e83a5e70 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -2062,11 +2062,11 @@ nsITokenizer* nsParser::GetTokenizer(void) { * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) +nsParser::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult result=0; if (nsnull != mProgressEventSink) { - mProgressEventSink->OnProgress(request, aContext, aProgress, aProgressMax); + mProgressEventSink->OnProgress(channel, aContext, aProgress, aProgressMax); } return result; } @@ -2079,12 +2079,12 @@ nsParser::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgr * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIRequest *request, nsISupports* aContext, +nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; if (nsnull != mProgressEventSink) { - rv = mProgressEventSink->OnStatus(request, aContext, aStatus, aStatusArg); + rv = mProgressEventSink->OnStatus(channel, aContext, aStatus, aStatusArg); NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } return NS_OK; @@ -2102,22 +2102,19 @@ nsParser::OnStatus(nsIRequest *request, nsISupports* aContext, * @param * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { +nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { NS_PRECONDITION((eNone==mParserContext->mStreamListenerState),kBadListenerInit); if (nsnull != mObserver) { - mObserver->OnStartRequest(request, aContext); + mObserver->OnStartRequest(channel, aContext); } mParserContext->mStreamListenerState=eOnStart; mParserContext->mAutoDetectStatus=eUnknownDetect; - mParserContext->mRequest=request; + mParserContext->mChannel=channel; mParserContext->mDTD=0; nsresult rv; char* contentType = nsnull; - nsCOMPtr channel = do_QueryInterface(request); - NS_ASSERTION(channel, "parser needs a channel to find a dtd"); - rv = channel->GetContentType(&contentType); if (NS_SUCCEEDED(rv)) { @@ -2313,7 +2310,7 @@ ParserWriteFunc(nsIInputStream* in, * @return error code (usually 0) */ -nsresult nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext, +nsresult nsParser::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIInputStream *pIStream, PRUint32 sourceOffset, PRUint32 aLength) { @@ -2325,12 +2322,12 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail CParserContext *theContext=mParserContext; while(theContext) { - if(theContext->mRequest!=request && theContext->mPrevContext) + if(theContext->mChannel!=channel && theContext->mPrevContext) theContext=theContext->mPrevContext; else break; } - if(theContext && theContext->mRequest==request) { + if(theContext && theContext->mChannel==channel) { theContext->mStreamListenerState=eOnDataAvail; @@ -2369,7 +2366,7 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail * @param * @return */ -nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, +nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) { @@ -2401,7 +2398,7 @@ nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, // XXX Should we wait to notify our observers as well if the // parser isn't yet enabled? if (nsnull != mObserver) { - mObserver->OnStopRequest(request, aContext, status, aMsg); + mObserver->OnStopRequest(channel, aContext, status, aMsg); } #ifdef rickgdebug diff --git a/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp b/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp index 07a224ece41..4b42cfac0d7 100644 --- a/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp +++ b/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp @@ -237,7 +237,7 @@ PageGrabber::Grab(const nsString& aURL) if(copier) { NS_ADDREF(copier); - rv = channel->AsyncOpen(copier, nsnull); + rv = channel->AsyncRead(copier, nsnull); if (NS_OK != rv) { NS_RELEASE(copier); diff --git a/mozilla/profile/Acct/nsAccount.cpp b/mozilla/profile/Acct/nsAccount.cpp index 8fa2e895586..0973d86f23a 100644 --- a/mozilla/profile/Acct/nsAccount.cpp +++ b/mozilla/profile/Acct/nsAccount.cpp @@ -348,7 +348,7 @@ int nsAccount::GetNCIValues(nsString MiddleValue) ret = NS_OpenURI(&channel, uri, service); if (NS_FAILED(ret)) return ret; - ret = channel->Open(&in); + ret = channel->OpenInputStream(&in); if (NS_FAILED(ret)) return ret; nsIPersistentProperties* props = nsnull; @@ -430,7 +430,7 @@ int nsAccount::GetConfigValues(nsString fileName) ret = NS_OpenURI(&channel, uri, service); if (NS_FAILED(ret)) return ret; - ret = channel->Open(&in); + ret = channel->OpenInputStream(&in); if (NS_FAILED(ret)) return ret; nsIPersistentProperties* props = nsnull; diff --git a/mozilla/rdf/base/src/nsRDFContentSink.cpp b/mozilla/rdf/base/src/nsRDFContentSink.cpp index 6ceb165c92c..ce5e96a9c81 100644 --- a/mozilla/rdf/base/src/nsRDFContentSink.cpp +++ b/mozilla/rdf/base/src/nsRDFContentSink.cpp @@ -927,8 +927,7 @@ RDFContentSinkImpl::GetNameSpaceURI(nsIAtom* aPrefix, const char** aNameSpaceURI #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) { nsAutoString prefixStr; - if (aPrefix) - aPrefix->ToString(prefixStr); + aPrefix->ToString(prefixStr); char* prefixCStr = prefixStr.ToNewCString(); diff --git a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp index 45f1b427ef3..6a58baa9aba 100644 --- a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp +++ b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp @@ -597,16 +597,15 @@ rdf_BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer) // XXX I really hate the way that we're spoon-feeding this stuff // to the parser: it seems like this is something that netlib // should be able to do by itself. - - nsCOMPtr channel; - nsCOMPtr request; + nsCOMPtr channel; // Null LoadGroup ? rv = NS_OpenURI(getter_AddRefs(channel), aURL, nsnull); if (NS_FAILED(rv)) return rv; + nsIInputStream* in; PRUint32 sourceOffset = 0; - rv = channel->Open(&in); + rv = channel->OpenInputStream(&in); // If we couldn't open the channel, then just return. if (NS_FAILED(rv)) return NS_OK; @@ -619,9 +618,7 @@ rdf_BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer) if (! proxy) goto done; - request = do_QueryInterface(channel); - - aConsumer->OnStartRequest(request, nsnull); + aConsumer->OnStartRequest(channel, nsnull); while (PR_TRUE) { char buf[1024]; PRUint32 readCount; @@ -634,13 +631,13 @@ rdf_BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer) proxy->SetBuffer(buf, readCount); - rv = aConsumer->OnDataAvailable(request, nsnull, proxy, sourceOffset, readCount); + rv = aConsumer->OnDataAvailable(channel, nsnull, proxy, sourceOffset, readCount); sourceOffset += readCount; if (NS_FAILED(rv)) break; } - aConsumer->OnStopRequest(request, nsnull, rv, nsnull); + aConsumer->OnStopRequest(channel, nsnull, rv, nsnull); // don't leak proxy! proxy->Close(); @@ -1085,13 +1082,13 @@ RDFXMLDataSourceImpl::RemoveXMLSinkObserver(nsIRDFXMLSinkObserver* aObserver) // NS_IMETHODIMP -RDFXMLDataSourceImpl::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +RDFXMLDataSourceImpl::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { - return mParser->OnStartRequest(request, ctxt); + return mParser->OnStartRequest(channel, ctxt); } NS_IMETHODIMP -RDFXMLDataSourceImpl::OnStopRequest(nsIRequest *request, +RDFXMLDataSourceImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) @@ -1104,7 +1101,7 @@ RDFXMLDataSourceImpl::OnStopRequest(nsIRequest *request, } nsresult rv; - rv = mParser->OnStopRequest(request, ctxt, status, errorMsg); + rv = mParser->OnStopRequest(channel, ctxt, status, errorMsg); mParser = nsnull; // release the parser @@ -1117,13 +1114,13 @@ RDFXMLDataSourceImpl::OnStopRequest(nsIRequest *request, // NS_IMETHODIMP -RDFXMLDataSourceImpl::OnDataAvailable(nsIRequest *request, +RDFXMLDataSourceImpl::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { - return mParser->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); + return mParser->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp b/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp index 9d3566b0c6d..392fb916814 100644 --- a/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp +++ b/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp @@ -116,25 +116,27 @@ public: NS_DECL_ISUPPORTS // nsIRequest - NS_IMETHOD GetName(PRUnichar* *result) { return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetName(PRUnichar* *result) { + NS_NOTREACHED("nsCachedChromeChannel::GetName"); + return NS_ERROR_NOT_IMPLEMENTED; + } NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; } NS_IMETHOD GetStatus(nsresult *status) { *status = mStatus; return NS_OK; } NS_IMETHOD Cancel(nsresult status) { mStatus = status; return NS_OK; } NS_IMETHOD Suspend(void) { return NS_OK; } NS_IMETHOD Resume(void) { return NS_OK; } - -// nsIChannel - NS_DECL_NSICHANNEL + // nsIChannel + NS_DECL_NSICHANNEL }; #ifdef PR_LOGGING PRLogModuleInfo* nsCachedChromeChannel::gLog; #endif -NS_IMPL_ISUPPORTS2(nsCachedChromeChannel, - nsIChannel, - nsIRequest); +NS_IMPL_ADDREF(nsCachedChromeChannel); +NS_IMPL_RELEASE(nsCachedChromeChannel); +NS_IMPL_QUERY_INTERFACE2(nsCachedChromeChannel, nsIRequest, nsIChannel); nsresult nsCachedChromeChannel::Create(nsIURI* aURI, nsIChannel** aResult) @@ -209,7 +211,7 @@ nsCachedChromeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsCachedChromeChannel::Open(nsIInputStream **_retval) +nsCachedChromeChannel::OpenInputStream(nsIInputStream **_retval) { // NS_NOTREACHED("don't do that"); *_retval = nsnull; @@ -217,7 +219,15 @@ nsCachedChromeChannel::Open(nsIInputStream **_retval) } NS_IMETHODIMP -nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +nsCachedChromeChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("don't do that"); + *_retval = nsnull; + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { if (listener) { nsresult rv; @@ -227,7 +237,7 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: adding self to load group %p", this, mLoadGroup.get())); - rv = mLoadGroup->AddRequest(this, nsnull); + rv = mLoadGroup->AddChannel(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -247,7 +257,7 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: removing self from load group %p", this, mLoadGroup.get())); - (void) mLoadGroup->RemoveRequest(this, nsnull, nsnull, nsnull); + (void) mLoadGroup->RemoveChannel(this, nsnull, nsnull, nsnull); } return rv; @@ -261,9 +271,10 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) } NS_IMETHODIMP -nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +nsCachedChromeChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { - return NS_ERROR_NOT_IMPLEMENTED; + NS_NOTREACHED("don't do that"); + return NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -280,6 +291,113 @@ nsCachedChromeChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) return NS_OK; } +NS_IMETHODIMP +nsCachedChromeChannel::GetContentType(char * *aContentType) +{ + *aContentType = nsXPIDLCString::Copy("text/cached-xul"); + return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetContentType(const char *aContentType) +{ + // Do not allow the content-type to be changed. + NS_NOTREACHED("don't do that"); + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetContentLength(PRInt32 *aContentLength) +{ + NS_NOTREACHED("don't do that"); + *aContentLength = 0; + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetContentLength(PRInt32 aContentLength) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetContentLength"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("nsCachedChromeChannel::SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetLocalFile(nsIFile* *file) +{ + *file = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +nsCachedChromeChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsCachedChromeChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsCachedChromeChannel::GetOwner(nsISupports * *aOwner) { @@ -323,34 +441,12 @@ nsCachedChromeChannel::SetNotificationCallbacks(nsIInterfaceRequestor * aNotific return NS_OK; // ignored } + NS_IMETHODIMP -nsCachedChromeChannel::GetContentType(char * *aContentType) +nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - *aContentType = nsXPIDLCString::Copy("text/cached-xul"); - return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP -nsCachedChromeChannel::SetContentType(const char *aContentType) -{ - // Do not allow the content-type to be changed. - NS_NOTREACHED("don't do that"); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsCachedChromeChannel::GetContentLength(PRInt32 *aContentLength) -{ - NS_NOTREACHED("don't do that"); - *aContentLength = 0; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsCachedChromeChannel::SetContentLength(PRInt32 aContentLength) -{ - NS_NOTREACHED("nsCachedChromeChannel::SetContentLength"); - return NS_ERROR_NOT_IMPLEMENTED; + *aSecurityInfo = nsnull; + return NS_OK; } nsresult @@ -427,14 +523,12 @@ nsCachedChromeChannel::HandleStopLoadEvent(PLEvent* aEvent) // remove it from the load group. LoadEvent* event = NS_REINTERPRET_CAST(LoadEvent*, aEvent); nsCachedChromeChannel* channel = event->mChannel; - nsIRequest* request = NS_REINTERPRET_CAST(nsIRequest*, channel); - PR_LOG(gLog, PR_LOG_DEBUG, ("nsCachedChromeChannel[%p]: firing OnStopRequest for %p", channel, channel->mListener.get())); - (void) channel->mListener->OnStopRequest(request, channel->mContext, + (void) channel->mListener->OnStopRequest(channel, channel->mContext, channel->mStatus, nsnull); if (channel->mLoadGroup) { @@ -442,7 +536,7 @@ nsCachedChromeChannel::HandleStopLoadEvent(PLEvent* aEvent) ("nsCachedChromeChannel[%p]: removing self from load group %p", channel, channel->mLoadGroup.get())); - (void) channel->mLoadGroup->RemoveRequest(request, nsnull, nsnull, nsnull); + (void) channel->mLoadGroup->RemoveChannel(channel, nsnull, nsnull, nsnull); } channel->mListener = nsnull; diff --git a/mozilla/rdf/content/src/Makefile.in b/mozilla/rdf/content/src/Makefile.in index 8ca70f52335..cc53f852828 100644 --- a/mozilla/rdf/content/src/Makefile.in +++ b/mozilla/rdf/content/src/Makefile.in @@ -28,7 +28,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = rdf LIBRARY_NAME = rdfcontent_s -REQUIRES = xpcom layout widget dom js caps locale necko timer lwbrk htmlparser xpconnect uriloader view pref docshell chrome exthandler mime +REQUIRES = xpcom layout widget dom js caps locale necko timer lwbrk htmlparser xpconnect uriloader view pref docshell chrome CPPSRCS = \ nsElementMap.cpp \ diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 6268e060d47..17c60632f23 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -127,10 +127,6 @@ #include "nsIDOMDocumentType.h" #include "nsIXBLService.h" #include "nsReadableUtils.h" -#include "nsCExternalHandlerService.h" -#include "nsIMIMEService.h" -#include "nsNetUtil.h" -#include "nsMimeTypes.h" //---------------------------------------------------------------------- @@ -317,19 +313,19 @@ NS_IMPL_ISUPPORTS1(nsProxyLoadStream, nsIInputStream); //---------------------------------------------------------------------- // -// PlaceholderRequest +// PlaceholderChannel // -// This is a dummy request implementation that we add to the load +// This is a dummy channel implementation that we add to the load // group. It ensures that EndDocumentLoad() in the docshell doesn't // fire before we've finished building the complete document content // model. // -class PlaceHolderRequest : public nsIChannel +class PlaceholderChannel : public nsIChannel { protected: - PlaceHolderRequest(); - virtual ~PlaceHolderRequest(); + PlaceholderChannel(); + virtual ~PlaceholderChannel(); static PRInt32 gRefCnt; static nsIURI* gURI; @@ -338,12 +334,13 @@ protected: public: static nsresult - Create(nsIRequest** aResult); + Create(nsIChannel** aResult); NS_DECL_ISUPPORTS // nsIRequest NS_IMETHOD GetName(PRUnichar* *result) { + NS_NOTREACHED("PlaceholderChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; } @@ -352,50 +349,63 @@ public: NS_IMETHOD Suspend(void) { return NS_OK; } NS_IMETHOD Resume(void) { return NS_OK; } - // nsIChannel + // nsIChannel NS_IMETHOD GetOriginalURI(nsIURI* *aOriginalURI) { *aOriginalURI = gURI; NS_ADDREF(*aOriginalURI); return NS_OK; } NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI) { gURI = aOriginalURI; NS_ADDREF(gURI); return NS_OK; } NS_IMETHOD GetURI(nsIURI* *aURI) { *aURI = gURI; NS_ADDREF(*aURI); return NS_OK; } NS_IMETHOD SetURI(nsIURI* aURI) { gURI = aURI; NS_ADDREF(gURI); return NS_OK; } - NS_IMETHOD Open(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } - NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } - NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes) { return NS_OK; } - NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } - NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } - NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } - NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } - NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } - NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } - NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { *aSecurityInfo = nsnull; return NS_OK; } - NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } - NS_IMETHOD SetContentType(const char * aContentType) { return NS_OK; } - NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return NS_OK; } - NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return NS_OK; } - + NS_IMETHOD OpenInputStream(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD OpenOutputStream(nsIOutputStream **_retval) { *_retval = nsnull; return NS_OK; } + NS_IMETHOD AsyncOpen(nsIStreamObserver *observer, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) { return NS_OK; } + NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = nsIChannel::LOAD_NORMAL; return NS_OK; } + NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes) { return NS_OK; } + NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; } + NS_IMETHOD SetContentType(const char *aContentType) { return NS_OK; } + NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { *aContentLength = 0; return NS_OK; } + NS_IMETHOD SetContentLength(PRInt32 aContentLength) { NS_NOTREACHED("SetContentLength"); NS_NOTREACHED("NOTREACHED"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferOffset(PRUint32 *aTransferOffset) { NS_NOTREACHED("GetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferOffset(PRUint32 aTransferOffset) { NS_NOTREACHED("SetTransferOffset"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetTransferCount(PRInt32 *aTransferCount) { NS_NOTREACHED("GetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetTransferCount(PRInt32 aTransferCount) { NS_NOTREACHED("SetTransferCount"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) { NS_NOTREACHED("GetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferSegmentSize(PRUint32 aBufferSegmentSize) { NS_NOTREACHED("SetBufferSegmentSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetBufferMaxSize(PRUint32 *aBufferMaxSize) { NS_NOTREACHED("GetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD SetBufferMaxSize(PRUint32 aBufferMaxSize) { NS_NOTREACHED("SetBufferMaxSize"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetLocalFile(nsIFile* *result) { NS_NOTREACHED("GetLocalFile"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetPipeliningAllowed(PRBool *aPipeliningAllowed) { *aPipeliningAllowed = PR_FALSE; return NS_OK; } + NS_IMETHOD SetPipeliningAllowed(PRBool aPipeliningAllowed) { NS_NOTREACHED("SetPipeliningAllowed"); return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; } + NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; } + NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; } + NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; } + NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; } + NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; } + NS_IMETHOD GetSecurityInfo(nsISupports **info) {*info = nsnull; return NS_OK;} }; -PRInt32 PlaceHolderRequest::gRefCnt; -nsIURI* PlaceHolderRequest::gURI; +PRInt32 PlaceholderChannel::gRefCnt; +nsIURI* PlaceholderChannel::gURI; -NS_IMPL_ADDREF(PlaceHolderRequest); -NS_IMPL_RELEASE(PlaceHolderRequest); -NS_IMPL_QUERY_INTERFACE2(PlaceHolderRequest, nsIRequest, nsIChannel); +NS_IMPL_ADDREF(PlaceholderChannel); +NS_IMPL_RELEASE(PlaceholderChannel); +NS_IMPL_QUERY_INTERFACE2(PlaceholderChannel, nsIRequest, nsIChannel); nsresult -PlaceHolderRequest::Create(nsIRequest** aResult) +PlaceholderChannel::Create(nsIChannel** aResult) { - PlaceHolderRequest* request = new PlaceHolderRequest(); - if (! request) + PlaceholderChannel* channel = new PlaceholderChannel(); + if (! channel) return NS_ERROR_OUT_OF_MEMORY; - *aResult = request; + *aResult = channel; NS_ADDREF(*aResult); return NS_OK; } -PlaceHolderRequest::PlaceHolderRequest() +PlaceholderChannel::PlaceholderChannel() { NS_INIT_REFCNT(); @@ -407,7 +417,7 @@ PlaceHolderRequest::PlaceHolderRequest() } -PlaceHolderRequest::~PlaceHolderRequest() +PlaceholderChannel::~PlaceholderChannel() { if (--gRefCnt == 0) { NS_IF_RELEASE(gURI); @@ -763,9 +773,8 @@ nsXULDocument::StartDocumentLoad(const char* aCommand, // certain hacks (cough, the directory viewer) need to be able to // StartDocumentLoad() before the channel's content type has been // detected. - nsXPIDLCString contentType; - aChannel->GetContentType(getter_Copies(contentType)); + (void) aChannel->GetContentType(getter_Copies(contentType)); if (contentType && PL_strcmp(contentType, "text/cached-xul") == 0) { // Look in the chrome cache: we've got this puppy loaded @@ -4934,16 +4943,16 @@ nsXULDocument::PrepareToWalk() // Add a dummy channel to the load group as a placeholder for the document // load - rv = PlaceHolderRequest::Create(getter_AddRefs(mPlaceHolderRequest)); + rv = PlaceholderChannel::Create(getter_AddRefs(mPlaceholderChannel)); if (NS_FAILED(rv)) return rv; nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); if (group) { - nsCOMPtr channel = do_QueryInterface(mPlaceHolderRequest); - rv = channel->SetLoadGroup(group); + rv = mPlaceholderChannel->SetLoadGroup(group); if (NS_FAILED(rv)) return rv; - rv = group->AddRequest(mPlaceHolderRequest, nsnull); + + rv = group->AddChannel(mPlaceholderChannel, nsnull); if (NS_FAILED(rv)) return rv; } } @@ -5287,10 +5296,10 @@ nsXULDocument::ResumeWalk() // docshell, and run the onload handlers, etc. nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); if (group) { - rv = group->RemoveRequest(mPlaceHolderRequest, nsnull, NS_OK, nsnull); + rv = group->RemoveChannel(mPlaceholderChannel, nsnull, NS_OK, nsnull); if (NS_FAILED(rv)) return rv; - mPlaceHolderRequest = nsnull; + mPlaceholderChannel = nsnull; } return rv; } @@ -5352,11 +5361,8 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader, { if (aLoader) { - nsCOMPtr request; nsCOMPtr channel; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) - channel = do_QueryInterface(request); + aLoader->GetChannel(getter_AddRefs(channel)); if (channel) { nsCOMPtr uri; @@ -6521,14 +6527,14 @@ nsXULDocument::CachedChromeStreamListener::~CachedChromeStreamListener() NS_IMPL_ISUPPORTS2(nsXULDocument::CachedChromeStreamListener, nsIStreamObserver, nsIStreamListener); NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIRequest *request, nsISupports* acontext) +nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIChannel* aChannel, nsISupports* acontext) { return NS_OK; } NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request, +nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -6543,7 +6549,7 @@ nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request, NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIRequest *request, +nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream* aInStr, PRUint32 aSourceOffset, @@ -6573,14 +6579,14 @@ nsXULDocument::ParserObserver::~ParserObserver() NS_IMPL_ISUPPORTS1(nsXULDocument::ParserObserver, nsIStreamObserver); NS_IMETHODIMP -nsXULDocument::ParserObserver::OnStartRequest(nsIRequest *request, +nsXULDocument::ParserObserver::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) { return NS_OK; } NS_IMETHODIMP -nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request, +nsXULDocument::ParserObserver::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -6592,10 +6598,6 @@ nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request, // walk along. #define YELL_IF_MISSING_OVERLAY 1 #if defined(DEBUG) || defined(YELL_IF_MISSING_OVERLAY) - - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; - nsCOMPtr uri; aChannel->GetOriginalURI(getter_AddRefs(uri)); diff --git a/mozilla/rdf/content/src/nsXULDocument.h b/mozilla/rdf/content/src/nsXULDocument.h index 26642d103f4..be5d165392a 100644 --- a/mozilla/rdf/content/src/nsXULDocument.h +++ b/mozilla/rdf/content/src/nsXULDocument.h @@ -119,7 +119,7 @@ public: NS_IMETHOD GetContentType(nsAWritableString& aContentType) const; NS_IMETHOD StartDocumentLoad(const char* aCommand, - nsIChannel *channel, + nsIChannel* aChannel, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, @@ -642,7 +642,7 @@ protected: * A "dummy" channel that is used as a placeholder to signal document load * completion. */ - nsCOMPtr mPlaceHolderRequest; + nsCOMPtr mPlaceholderChannel; /** * Create a XUL template builder on the specified node if a 'datasources' diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 671bf44a50a..223b4062983 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -64,17 +64,15 @@ PRLogModuleInfo* gDocLoaderLog = nsnull; #if defined(DEBUG) -void GetURIStringFromRequest(nsIRequest* request, nsXPIDLCString &aStr) +void GetURIStringFromChannel(nsIRequest *aRequest, nsXPIDLCString &aStr) { - nsCOMPtr channel = do_QueryInterface(request); - - if (!channel) { - aStr = "???"; - return; - } - + nsCOMPtr channel; nsCOMPtr uri; - nsresult rv = channel->GetURI(getter_AddRefs(uri)); + nsresult rv = NS_OK; + + channel = do_QueryInterface(aRequest, &rv); + if (NS_SUCCEEDED(rv)) + rv = channel->GetURI(getter_AddRefs(uri)); if (NS_SUCCEEDED(rv) && uri) rv = uri->GetSpec(getter_Copies(aStr)); @@ -441,7 +439,7 @@ nsDocLoaderImpl::Destroy() ClearChannelInfoList(); - mDocumentRequest = 0; + mDocumentChannel = null_nsCOMPtr(); mLoadGroup->SetGroupObserver(nsnull); @@ -449,15 +447,14 @@ nsDocLoaderImpl::Destroy() } NS_IMETHODIMP -nsDocLoaderImpl::OnStartRequest(nsIRequest *request, nsISupports *aCtxt) +nsDocLoaderImpl::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) { // called each time a channel is added to the group. nsresult rv; - - nsCOMPtr aChannel = do_QueryInterface(request); if (!mIsLoadingDocument) { PRUint32 loadAttribs = 0; + aChannel->GetLoadAttributes(&loadAttribs); if (loadAttribs & nsIChannel::LOAD_DOCUMENT_URI) { mIsLoadingDocument = PR_TRUE; @@ -483,39 +480,37 @@ nsDocLoaderImpl::OnStartRequest(nsIRequest *request, nsISupports *aCtxt) if (1 == count) { // This channel is associated with the entire document... - mDocumentRequest = do_QueryInterface(request); - mLoadGroup->SetDefaultLoadRequest(mDocumentRequest); + mDocumentChannel = aChannel; + mLoadGroup->SetDefaultLoadChannel(mDocumentChannel); // Update the progress status state mProgressStateFlags = nsIWebProgressListener::STATE_START; doStartDocumentLoad(); - FireOnStartDocumentLoad(this, request); + FireOnStartDocumentLoad(this, aChannel); } else { - doStartURLLoad(request); - FireOnStartURLLoad(this, request); + doStartURLLoad(aChannel); + FireOnStartURLLoad(this, aChannel); } } else { ClearChannelInfoList(); - doStartURLLoad(request); - FireOnStartURLLoad(this, request); + doStartURLLoad(aChannel); + FireOnStartURLLoad(this, aChannel); } return NS_OK; } NS_IMETHODIMP -nsDocLoaderImpl::OnStopRequest(nsIRequest *request, +nsDocLoaderImpl::OnStopRequest(nsIChannel *aChannel, nsISupports *aCtxt, nsresult aStatus, const PRUnichar *aMsg) { nsresult rv = NS_OK; - nsCOMPtr aChannel = do_QueryInterface(request); - // // Only fire the OnEndDocumentLoad(...) if the document loader // has initiated a load... @@ -548,8 +543,8 @@ nsDocLoaderImpl::OnStopRequest(nsIRequest *request, // // Fire the OnStateChange(...) notification for stop request // - doStopURLLoad(request, aStatus); - FireOnEndURLLoad(this, request, aStatus); + doStopURLLoad(aChannel, aStatus); + FireOnEndURLLoad(this, aChannel, aStatus); rv = mLoadGroup->GetActiveCount(&count); if (NS_FAILED(rv)) return rv; @@ -562,8 +557,8 @@ nsDocLoaderImpl::OnStopRequest(nsIRequest *request, } } else { - doStopURLLoad(request, aStatus); - FireOnEndURLLoad(this, request, aStatus); + doStopURLLoad(aChannel, aStatus); + FireOnEndURLLoad(this, aChannel, aStatus); } return NS_OK; @@ -582,9 +577,7 @@ nsresult nsDocLoaderImpl::RemoveChildGroup(nsDocLoaderImpl* aLoader) NS_IMETHODIMP nsDocLoaderImpl::GetDocumentChannel(nsIChannel ** aChannel) { - nsCOMPtr ourChannel = do_QueryInterface(mDocumentRequest); - - *aChannel = ourChannel.get(); + *aChannel = mDocumentChannel; NS_IF_ADDREF(*aChannel); return NS_OK; } @@ -605,9 +598,9 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus) PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: Is now idle...\n", this)); - nsCOMPtr docRequest = mDocumentRequest; + nsCOMPtr docChannel(mDocumentChannel); - mDocumentRequest = null_nsCOMPtr(); + mDocumentChannel = null_nsCOMPtr(); mIsLoadingDocument = PR_FALSE; // Update the progress status state - the document is done @@ -621,15 +614,15 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus) // New code to break the circular reference between // the load group and the docloader... // - mLoadGroup->SetDefaultLoadRequest(nsnull); + mLoadGroup->SetDefaultLoadChannel(nsnull); // // Do nothing after firing the OnEndDocumentLoad(...). The document // loader may be loading a *new* document - if LoadDocument() // was called from a handler! // - doStopDocumentLoad(docRequest, loadGroupStatus); - FireOnEndDocumentLoad(this, docRequest, loadGroupStatus); + doStopDocumentLoad(docChannel, loadGroupStatus); + FireOnEndDocumentLoad(this, docChannel, loadGroupStatus); if (mParent) { mParent->DocLoaderIsEmpty(loadGroupStatus); @@ -644,7 +637,7 @@ void nsDocLoaderImpl::doStartDocumentLoad(void) #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(mDocumentRequest, buffer); + GetURIStringFromChannel(mDocumentChannel, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange for start document load (...)." "\tURI: %s \n", @@ -652,10 +645,10 @@ void nsDocLoaderImpl::doStartDocumentLoad(void) #endif /* DEBUG */ // Fire an OnStatus(...) notification STATE_START. This indicates - // that the document represented by mDocumentRequest has started to + // that the document represented by mDocumentChannel has started to // load... FireOnStateChange(this, - mDocumentRequest, + mDocumentChannel, nsIWebProgressListener::STATE_START | nsIWebProgressListener::STATE_IS_DOCUMENT | nsIWebProgressListener::STATE_IS_REQUEST | @@ -663,12 +656,12 @@ void nsDocLoaderImpl::doStartDocumentLoad(void) NS_OK); } -void nsDocLoaderImpl::doStartURLLoad(nsIRequest *request) +void nsDocLoaderImpl::doStartURLLoad(nsIChannel *aChannel) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(request, buffer); + GetURIStringFromChannel(aChannel, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange start url load (...)." "\tURI: %s\n", @@ -676,18 +669,18 @@ void nsDocLoaderImpl::doStartURLLoad(nsIRequest *request) #endif /* DEBUG */ FireOnStateChange(this, - request, + aChannel, nsIWebProgressListener::STATE_START | nsIWebProgressListener::STATE_IS_REQUEST, NS_OK); } -void nsDocLoaderImpl::doStopURLLoad(nsIRequest *request, nsresult aStatus) +void nsDocLoaderImpl::doStopURLLoad(nsIChannel *aChannel, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(request, buffer); + GetURIStringFromChannel(aChannel, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange for end url load (...)." "\tURI: %s status=%x\n", @@ -695,19 +688,19 @@ void nsDocLoaderImpl::doStopURLLoad(nsIRequest *request, nsresult aStatus) #endif /* DEBUG */ FireOnStateChange(this, - request, + aChannel, nsIWebProgressListener::STATE_STOP | nsIWebProgressListener::STATE_IS_REQUEST, aStatus); } -void nsDocLoaderImpl::doStopDocumentLoad(nsIRequest *request, +void nsDocLoaderImpl::doStopDocumentLoad(nsIChannel* aChannel, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(request, buffer); + GetURIStringFromChannel(aChannel, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange for end document load (...)." "\tURI: %s Status=%x\n", @@ -719,7 +712,7 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIRequest *request, // current document has finished loading... // FireOnStateChange(this, - request, + aChannel, nsIWebProgressListener::STATE_STOP | nsIWebProgressListener::STATE_IS_DOCUMENT, aStatus); @@ -729,7 +722,7 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIRequest *request, // current document has finished loading... // FireOnStateChange(this, - request, + aChannel, nsIWebProgressListener::STATE_STOP | nsIWebProgressListener::STATE_IS_WINDOW | nsIWebProgressListener::STATE_IS_NETWORK, @@ -740,19 +733,18 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIRequest *request, void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *aDocRequest) + nsIChannel *aDocChannel) { PRInt32 count; nsCOMPtr uri; - nsCOMPtr aChannel = do_QueryInterface(aDocRequest); - aChannel->GetURI(getter_AddRefs(uri)); + aDocChannel->GetURI(getter_AddRefs(uri)); #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(aDocRequest, buffer); + GetURIStringFromChannel(aDocChannel, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStartDocumentLoad(...).\tURI: %s\n", @@ -789,19 +781,19 @@ void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, * Finally notify the parent... */ if (mParent) { - mParent->FireOnStartDocumentLoad(aLoadInitiator, aDocRequest); + mParent->FireOnStartDocumentLoad(aLoadInitiator, aDocChannel); } } void nsDocLoaderImpl::FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *aDocRequest, + nsIChannel *aDocChannel, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(aDocRequest, buffer); + GetURIStringFromChannel(aDocChannel, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnEndDocumentLoad(...)" @@ -834,25 +826,25 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, continue; } - observer->OnEndDocumentLoad(aLoadInitiator, aDocRequest, aStatus); + observer->OnEndDocumentLoad(aLoadInitiator, aDocChannel, aStatus); } /* * Next notify the parent... */ if (mParent) { - mParent->FireOnEndDocumentLoad(aLoadInitiator, aDocRequest, aStatus); + mParent->FireOnEndDocumentLoad(aLoadInitiator, aDocChannel, aStatus); } } void nsDocLoaderImpl::FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest* aRequest) + nsIChannel* aChannel) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(aRequest, buffer); + GetURIStringFromChannel(aChannel, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStartURLLoad(...)" @@ -886,25 +878,25 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, continue; } - observer->OnStartURLLoad(aLoadInitiator, aRequest); + observer->OnStartURLLoad(aLoadInitiator, aChannel); } /* * Finally notify the parent... */ if (mParent) { - mParent->FireOnStartURLLoad(aLoadInitiator, aRequest); + mParent->FireOnStartURLLoad(aLoadInitiator, aChannel); } } void nsDocLoaderImpl::FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request, nsresult aStatus) + nsIChannel* aChannel, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(request, buffer); + GetURIStringFromChannel(aChannel, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnEndURLLoad(...)" @@ -937,14 +929,14 @@ void nsDocLoaderImpl::FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, continue; } - observer->OnEndURLLoad(aLoadInitiator, request, aStatus); + observer->OnEndURLLoad(aLoadInitiator, aChannel, aStatus); } /* * Finally notify the parent... */ if (mParent) { - mParent->FireOnEndURLLoad(aLoadInitiator, request, aStatus); + mParent->FireOnEndURLLoad(aLoadInitiator, aChannel, aStatus); } } @@ -1080,7 +1072,7 @@ nsresult nsDocLoaderImpl::GetMaxTotalProgress(PRInt32 *aMaxTotalProgress) // then turns around and makes the right web progress calls based on this information. //////////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIRequest *request, nsISupports* ctxt, +NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { nsChannelInfo *info; @@ -1089,9 +1081,6 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIRequest *request, nsISupports* ctxt // // Update the ChannelInfo entry with the new progress data // - nsCOMPtr aChannel = do_QueryInterface(request); - - info = GetChannelInfo(aChannel); if (info) { if ((0 == info->mCurrentProgress) && (0 == info->mMaxProgress)) { @@ -1124,7 +1113,7 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIRequest *request, nsISupports* ctxt flags |= nsIWebProgressListener::STATE_IS_DOCUMENT; } - FireOnStateChange(this, request, flags, NS_OK); + FireOnStateChange(this, aChannel, flags, NS_OK); } // Update the current progress count... @@ -1141,7 +1130,7 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIRequest *request, nsISupports* ctxt #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(request, buffer); + GetURIStringFromChannel(aChannel, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p OOPS - No Channel Info for: %s\n", this, (const char *)buffer)); @@ -1153,13 +1142,13 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIRequest *request, nsISupports* ctxt // // Fire progress notifications out to any registered nsIWebProgressListeners // - FireOnProgressChange(this, request, aProgress, aProgressMax, progressDelta, + FireOnProgressChange(this, aChannel, aProgress, aProgressMax, progressDelta, mCurrentTotalProgress, mMaxTotalProgress); return NS_OK; } -NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIRequest* aRequest, nsISupports* ctxt, +NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIChannel* aChannel, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { // @@ -1172,7 +1161,7 @@ NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIRequest* aRequest, nsISupports* ctxt, nsXPIDLString msg; rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg)); if (NS_FAILED(rv)) return rv; - FireOnStatusChange(this, aRequest, aStatus, msg); + FireOnStatusChange(this, aChannel, aStatus, msg); } return NS_OK; } @@ -1189,7 +1178,7 @@ void nsDocLoaderImpl::ClearInternalProgress() void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, - nsIRequest *request, + nsIChannel *aChannel, PRInt32 aProgress, PRInt32 aProgressMax, PRInt32 aProgressDelta, @@ -1209,7 +1198,7 @@ void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(request, buffer); + GetURIStringFromChannel(aChannel, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: Progress (%s): curSelf: %d maxSelf: %d curTotal: %d maxTotal %d\n", this, (const char *)buffer, aProgress, aProgressMax, aTotalProgress, aMaxTotalProgress)); @@ -1236,7 +1225,7 @@ void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, continue; } - listener->OnProgressChange(aLoadInitiator,request, + listener->OnProgressChange(aLoadInitiator,aChannel, aProgress, aProgressMax, aTotalProgress, aMaxTotalProgress); } @@ -1245,7 +1234,7 @@ void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, // Pass the notification up to the parent... if (mParent) { - mParent->FireOnProgressChange(aLoadInitiator, request, + mParent->FireOnProgressChange(aLoadInitiator, aChannel, aProgress, aProgressMax, aProgressDelta, aTotalProgress, aMaxTotalProgress); @@ -1277,7 +1266,7 @@ void nsDocLoaderImpl::FireOnStateChange(nsIWebProgress *aProgress, #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromRequest(aRequest, buffer); + GetURIStringFromChannel(aRequest, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: Status (%s): code: %x\n", this, (const char *)buffer, aStateFlags)); @@ -1481,17 +1470,17 @@ NS_IMETHODIMP nsDocLoaderImpl::OnRedirect(nsISupports * aContext, nsIURI * aNewL PRInt32 stateFlags = nsIWebProgressListener::STATE_REDIRECTING | nsIWebProgressListener::STATE_IS_REQUEST | nsIWebProgressListener::STATE_IS_NETWORK; - nsCOMPtr request (do_QueryInterface(aContext)); + nsCOMPtr channel (do_QueryInterface(aContext)); // if the current channel == the document channel (then we must be getting a redirect on the // actual document and not a part in the document so be sure to set the state is document flag - // and to reset mDocumentRequest... - if (request.get() == mDocumentRequest.get()) + // and to reset mDocumentChannel... + if (channel.get() == mDocumentChannel.get()) { stateFlags |= nsIWebProgressListener::STATE_IS_DOCUMENT; - mDocumentRequest = request; // reset the document channel + mDocumentChannel = channel; // reset the document channel } - FireOnStateChange(this, request, stateFlags, NS_OK); + FireOnStateChange(this, channel, stateFlags, NS_OK); } return NS_OK; diff --git a/mozilla/uriloader/base/nsDocLoader.h b/mozilla/uriloader/base/nsDocLoader.h index 40aba8dd58a..819e874b3aa 100644 --- a/mozilla/uriloader/base/nsDocLoader.h +++ b/mozilla/uriloader/base/nsDocLoader.h @@ -90,20 +90,20 @@ protected: void DocLoaderIsEmpty(nsresult aStatus); void FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request); + nsIChannel* aChannel); void FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *aDocRequest, + nsIChannel *aDocChannel, nsresult aStatus); void FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request); + nsIChannel* channel); void FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request, nsresult aStatus); + nsIChannel* channel, nsresult aStatus); void FireOnProgressChange(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request, + nsIChannel* aChannel, PRInt32 aProgress, PRInt32 aProgressMax, PRInt32 aProgressDelta, @@ -111,14 +111,14 @@ protected: PRInt32 aMaxTotalProgress); void FireOnStateChange(nsIWebProgress *aProgress, - nsIRequest* request, + nsIRequest* aChannel, PRInt32 aStateFlags, nsresult aStatus); void doStartDocumentLoad(); - void doStartURLLoad(nsIRequest *request); - void doStopURLLoad(nsIRequest *request, nsresult aStatus); - void doStopDocumentLoad(nsIRequest *request, nsresult aStatus); + void doStartURLLoad(nsIChannel *aChannel); + void doStopURLLoad(nsIChannel *aChannel, nsresult aStatus); + void doStopDocumentLoad(nsIChannel* aChannel, nsresult aStatus); // get web progress returns our web progress listener or if // we don't have one, it will look up the doc loader hierarchy @@ -133,7 +133,7 @@ protected: // (ie, non owning) references. If you add any members to this // class, please make the ownership explicit (pinkerton, scc). - nsCOMPtr mDocumentRequest; // [OWNER] ???compare with document + nsCOMPtr mDocumentChannel; // [OWNER] ???compare with document nsVoidArray mDocObservers; nsCOMPtr mListenerList; nsISupports* mContainer; // [WEAK] it owns me! @@ -172,8 +172,8 @@ private: nsresult GetCurTotalProgress(PRInt32* aCurTotalProgress); nsresult GetMaxTotalProgress(PRInt32* aMaxTotalProgress); - nsresult AddChannelInfo(nsIChannel* channel); - nsChannelInfo *GetChannelInfo(nsIChannel* channel); + nsresult AddChannelInfo(nsIChannel *aChannel); + nsChannelInfo *GetChannelInfo(nsIChannel *aChannel); nsresult ClearChannelInfoList(void); void CalculateMaxProgress(PRInt32 *aMax); /// void DumpChannelInfo(void); diff --git a/mozilla/uriloader/base/nsIContentHandler.idl b/mozilla/uriloader/base/nsIContentHandler.idl index a47ccded2c4..d03c3401252 100644 --- a/mozilla/uriloader/base/nsIContentHandler.idl +++ b/mozilla/uriloader/base/nsIContentHandler.idl @@ -21,7 +21,7 @@ */ #include "nsISupports.idl" -interface nsIRequest; +interface nsIChannel; [scriptable, uuid(2F0F927A-8677-11d3-989D-001083010E9B)] interface nsIContentHandler : nsISupports @@ -31,11 +31,11 @@ interface nsIContentHandler : nsISupports trying to display. When is this typically used? Well, if handle content needs to create a new window in order to display the content, it needs to know about the dom window where the content originated from. - aRequest is a request whose content type is already known (aContentType) */ + aChannel is an open channel whose content type is already known (aContentType) */ void handleContent(in string aContentType, in string aCommand, in string aWindowTarget, in nsISupports aSourceContext, - in nsIRequest aRequest); + in nsIChannel aChannel); }; diff --git a/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl b/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl index 75ec3a47033..86c52fde5ac 100644 --- a/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl +++ b/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl @@ -28,7 +28,8 @@ interface nsIDocumentLoader; interface nsIURI; -interface nsIRequest; +interface nsIChannel; + /* we'll be phasing this interface out in place of a new improved progress sink interface */ @@ -54,7 +55,7 @@ interface nsIDocumentLoaderObserver : nsISupports /** * Notify the observer that a document has been completely loaded. */ - void onEndDocumentLoad(in nsIDocumentLoader loader, in nsIRequest request, in unsigned long aStatus); + void onEndDocumentLoad(in nsIDocumentLoader loader, in nsIChannel aChannel, in unsigned long aStatus); /** * Notify the observer that the specified nsIURI has just started to load. @@ -62,26 +63,26 @@ interface nsIDocumentLoaderObserver : nsISupports * This notification occurs after DNS resolution, and a connection to the * server has been established. */ - void onStartURLLoad(in nsIDocumentLoader aLoader, in nsIRequest request); + void onStartURLLoad(in nsIDocumentLoader aLoader, in nsIChannel channel); /** * Notify the observer that progress has occurred in the loading of the * specified URL... */ void onProgressURLLoad(in nsIDocumentLoader aLoader, - in nsIRequest aRequest, in unsigned long aProgress, + in nsIChannel aChannel, in unsigned long aProgress, in unsigned long aProgressMax); /** * Notify the observer that status text is available regarding the URL * being loaded... */ - [noscript] void onStatusURLLoad(in nsIDocumentLoader loader, in nsIRequest request, in nsStringRef aMsg); + [noscript] void onStatusURLLoad(in nsIDocumentLoader loader, in nsIChannel channel, in nsStringRef aMsg); /** * Notify the observer that the specified nsIURI has finished loading. */ - void onEndURLLoad(in nsIDocumentLoader aLoader, in nsIRequest aRequest, in unsigned long aStatus); + void onEndURLLoad(in nsIDocumentLoader aLoader, in nsIChannel aChannel, in unsigned long aStatus); }; /* the following is a transition define. nsIDocumentLoaderObserver wasn't scriptable and now it is. diff --git a/mozilla/uriloader/base/nsIURIContentListener.idl b/mozilla/uriloader/base/nsIURIContentListener.idl index b7ae95752f6..e7389c73593 100644 --- a/mozilla/uriloader/base/nsIURIContentListener.idl +++ b/mozilla/uriloader/base/nsIURIContentListener.idl @@ -31,7 +31,7 @@ #include "nsIURILoader.idl" interface nsIProtocolHandler; -interface nsIRequest; +interface nsIChannel; interface nsIStreamListener; interface nsIURI; @@ -79,7 +79,7 @@ interface nsIURIContentListener : nsISupports void doContent(in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, - in nsIRequest request, + in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); diff --git a/mozilla/uriloader/base/nsIURILoader.idl b/mozilla/uriloader/base/nsIURILoader.idl index c901dcf682c..7a77fe69553 100644 --- a/mozilla/uriloader/base/nsIURILoader.idl +++ b/mozilla/uriloader/base/nsIURILoader.idl @@ -48,7 +48,6 @@ interface nsILoadGroup; interface nsIDocumentLoader; interface nsIProgressEventSink; interface nsIChannel; -interface nsIRequest; interface nsIStreamListener; interface nsIInputStream; @@ -116,7 +115,7 @@ interface nsIURILoader : nsISupports void dispatchContent(in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, - in nsIRequest aRequest, + in nsIChannel aChannel, in nsISupports aCtxt, in nsIURIContentListener aContentListener, in nsISupports aSrcWindowContext, diff --git a/mozilla/uriloader/base/nsURILoader.cpp b/mozilla/uriloader/base/nsURILoader.cpp index 03def17acaa..6586a588216 100644 --- a/mozilla/uriloader/base/nsURILoader.cpp +++ b/mozilla/uriloader/base/nsURILoader.cpp @@ -37,6 +37,7 @@ #include "nsIInputStream.h" #include "nsIStreamConverterService.h" #include "nsWeakReference.h" + #include "nsIHTTPChannel.h" #include "nsIDocShellTreeItem.h" @@ -82,13 +83,13 @@ public: NS_DECL_ISUPPORTS - nsresult Open(nsIChannel* channel, + nsresult Open(nsIChannel * aChannel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aWindowContext); - nsresult DispatchContent(nsIRequest *request, nsISupports * aCtxt); - nsresult RetargetOutput(nsIRequest *request, const char * aSrcContentType, + nsresult DispatchContent(nsIChannel * aChannel, nsISupports * aCtxt); + nsresult RetargetOutput(nsIChannel * aChannel, const char * aSrcContentType, const char * aOutContentType, nsIStreamListener * aStreamListener); // nsIStreamObserver methods: @@ -103,7 +104,7 @@ protected: // ProcessCanceledCase will do a couple of things....(1) it checks to see if the channel was canceled, // if it was, it will go out and release all of the document open info's local state for this load // and it will return TRUE. - PRBool ProcessCanceledCase(nsIRequest *request); + PRBool ProcessCanceledCase(nsIChannel * aChannel); protected: nsCOMPtr m_contentListener; @@ -161,14 +162,14 @@ nsDocumentOpenInfo* nsDocumentOpenInfo::Clone() // ProcessCanceledCase will do a couple of things....(1) it checks to see if the channel was canceled, // if it was, it will go out and release all of the document open info's local state for this load // and it will return TRUE. -PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIRequest *request) +PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIChannel * aChannel) { PRBool canceled = PR_FALSE; nsresult rv = NS_OK; - if (request) + if (aChannel) { - request->GetStatus(&rv); + aChannel->GetStatus(&rv); // if we were aborted or if the js returned no result (i.e. we aren't replacing any window content) if (rv == NS_BINDING_ABORTED || rv == NS_ERROR_DOM_RETVAL_UNDEFINED) @@ -185,7 +186,7 @@ PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIRequest *request) return canceled; } -nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel, +nsresult nsDocumentOpenInfo::Open(nsIChannel * aChannel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aWindowContext) @@ -203,10 +204,8 @@ nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel, mCommand = aCommand; // now just open the channel! - if (aChannel){ - rv = aChannel->AsyncOpen(this, nsnull); - } - + if (aChannel) + rv = aChannel->AsyncRead(this, nsnull); if (rv == NS_ERROR_DOM_RETVAL_UNDEFINED) { NS_WARNING("js returned no result -- not replacing window contents"); rv = NS_OK; @@ -214,7 +213,7 @@ nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel, return rv; } -NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) +NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) { nsresult rv = NS_OK; @@ -225,7 +224,7 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest *request, nsISupport // content handler. Just return. This causes the request to be // ignored. // - nsCOMPtr httpChannel(do_QueryInterface(request, &rv)); + nsCOMPtr httpChannel(do_QueryInterface(aChannel, &rv)); if (NS_SUCCEEDED(rv)) { PRUint32 responseCode = 0; @@ -236,16 +235,16 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest *request, nsISupport } } - if (ProcessCanceledCase(request)) + if (ProcessCanceledCase(aChannel)) return NS_OK; - rv = DispatchContent(request, aCtxt); + rv = DispatchContent(aChannel, aCtxt); if (m_targetStreamListener) - rv = m_targetStreamListener->OnStartRequest(request, aCtxt); + rv = m_targetStreamListener->OnStartRequest(aChannel, aCtxt); return rv; } -NS_IMETHODIMP nsDocumentOpenInfo::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, +NS_IMETHODIMP nsDocumentOpenInfo::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * inStr, PRUint32 sourceOffset, PRUint32 count) { // if we have retarged to the end stream listener, then forward the call.... @@ -253,26 +252,26 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnDataAvailable(nsIRequest *request, nsISuppor nsresult rv = NS_OK; - if (ProcessCanceledCase(request)) + if (ProcessCanceledCase(aChannel)) return NS_OK; if (m_targetStreamListener) - rv = m_targetStreamListener->OnDataAvailable(request, aCtxt, inStr, sourceOffset, count); + rv = m_targetStreamListener->OnDataAvailable(aChannel, aCtxt, inStr, sourceOffset, count); return rv; } -NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, +NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIChannel * aChannel, nsISupports *aCtxt, nsresult aStatus, const PRUnichar * errorMsg) { nsresult rv = NS_OK; - if (ProcessCanceledCase(request)) + if (ProcessCanceledCase(aChannel)) return NS_OK; if (!mOnStopFired && m_targetStreamListener) { mOnStopFired = PR_TRUE; - m_targetStreamListener->OnStopRequest(request, aCtxt, aStatus, errorMsg); + m_targetStreamListener->OnStopRequest(aChannel, aCtxt, aStatus, errorMsg); } m_targetStreamListener = 0; @@ -280,15 +279,12 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIRequest *request, nsISupports return rv; } -nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * aCtxt) +nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports * aCtxt) { nsresult rv; nsXPIDLCString contentType; nsCOMPtr originalWindowContext = m_originalContext; // local variable to keep track of this. nsCOMPtr contentStreamListener; - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) - return NS_ERROR_FAILURE; rv = aChannel->GetContentType(getter_Copies(contentType)); if (NS_FAILED(rv)) return rv; @@ -306,7 +302,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * // PRBool abortDispatch = PR_FALSE; rv = pURILoader->DispatchContent(contentType, mCommand, m_windowTarget, - request, aCtxt, + aChannel, aCtxt, m_contentListener, m_originalContext, getter_Copies(desiredContentType), @@ -324,7 +320,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * // if (!contentListener) { - rv = RetargetOutput(request, contentType, "*/*", nsnull); + rv = RetargetOutput(aChannel, contentType, "*/*", nsnull); if (m_targetStreamListener) return NS_OK; } @@ -367,7 +363,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * } rv = contentListener->DoContent(contentTypeToUse, mCommand, m_windowTarget, - request, getter_AddRefs(contentStreamListener), + aChannel, getter_AddRefs(contentStreamListener), &bAbortProcess); // the listener is doing all the work from here...we are done!!! @@ -385,7 +381,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * { rv = helperAppService->DoContent(contentType, uri, m_originalContext, &abortProcess, getter_AddRefs(contentStreamListener)); if (NS_SUCCEEDED(rv) && contentStreamListener) - return RetargetOutput(request, contentType, contentType, contentStreamListener); + return RetargetOutput(aChannel, contentType, contentType, contentStreamListener); } rv = NS_ERROR_FAILURE; // this will cause us to bring up the unknown content handler dialog. } @@ -393,14 +389,14 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * // okay, all registered listeners have had a chance to handle this content... // did one of them give us a stream listener back? if so, let's start reading data // into it... - rv = RetargetOutput(request, contentType, desiredContentType, contentStreamListener); + rv = RetargetOutput(aChannel, contentType, desiredContentType, contentStreamListener); m_originalContext = nsnull; // we don't need this anymore.... } } return rv; } -nsresult nsDocumentOpenInfo::RetargetOutput(nsIRequest *request, const char * aSrcContentType, const char * aOutContentType, +nsresult nsDocumentOpenInfo::RetargetOutput(nsIChannel * aChannel, const char * aSrcContentType, const char * aOutContentType, nsIStreamListener * aStreamListener) { nsresult rv = NS_OK; @@ -439,7 +435,7 @@ nsresult nsDocumentOpenInfo::RetargetOutput(nsIRequest *request, const char * aS rv = StreamConvService->AsyncConvertData(from_w.GetUnicode(), to_w.GetUnicode(), nextLink, - request, + aChannel, getter_AddRefs(m_targetStreamListener)); NS_RELEASE(nextLink); } @@ -499,12 +495,12 @@ NS_IMETHODIMP nsURILoader::UnRegisterContentListener(nsIURIContentListener * aCo } -NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel, +NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel * aChannel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aWindowContext) { - return OpenURIVia(channel, aCommand, aWindowTarget, aWindowContext, 0 /* ip address */); + return OpenURIVia(aChannel, aCommand, aWindowTarget, aWindowContext, 0 /* ip address */); } // @@ -644,7 +640,7 @@ PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem, nsIDocShellTreeItem* return SameOrSubdomainOfTarget(originDocumentURI, targetPrincipalURI, documentDomainSet); } -NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel *channel, nsCString &aWindowTarget, +NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel * aChannel, nsCString &aWindowTarget, nsISupports * aWindowContext, nsISupports ** aRetargetedWindowContext) { @@ -771,7 +767,7 @@ NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel *channel, nsCString &aWindowTarg return NS_OK; } -NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel, +NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aOriginalWindowContext, @@ -779,19 +775,19 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel, { // we need to create a DocumentOpenInfo object which will go ahead and open the url // and discover the content type.... + nsresult rv = NS_OK; nsDocumentOpenInfo* loader = nsnull; - if (!channel) return NS_ERROR_NULL_POINTER; + if (!aChannel) return NS_ERROR_NULL_POINTER; // Let the window context's uriListener know that the open is starting. This // gives that window a chance to abort the load process. nsCOMPtr winContextListener(do_GetInterface(aOriginalWindowContext)); if(winContextListener) { - // get channel from request nsCOMPtr uri; - channel->GetURI(getter_AddRefs(uri)); + aChannel->GetURI(getter_AddRefs(uri)); if(uri) { PRBool doAbort = PR_FALSE; @@ -804,7 +800,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel, nsCAutoString windowTarget(aWindowTarget); nsCOMPtr retargetedWindowContext; - NS_ENSURE_SUCCESS(GetTarget(channel, windowTarget, aOriginalWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(GetTarget(aChannel, windowTarget, aOriginalWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE); NS_NEWXPCOM(loader, nsDocumentOpenInfo); if (!loader) return NS_ERROR_OUT_OF_MEMORY; @@ -816,7 +812,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel, loader->Init(retargetedWindowContext, aOriginalWindowContext); // Extra Info // now instruct the loader to go ahead and open the url - rv = loader->Open(channel, aCommand, windowTarget, retargetedWindowContext); + rv = loader->Open(aChannel, aCommand, windowTarget, retargetedWindowContext); NS_RELEASE(loader); return rv; @@ -966,7 +962,7 @@ PRBool nsURILoader::ShouldHandleContent(nsIURIContentListener * aCntListener, NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIRequest *request, + nsIChannel * aChannel, nsISupports * aCtxt, nsIURIContentListener * aContentListener, nsISupports * aSrcWindowContext, @@ -975,7 +971,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType, PRBool * aAbortProcess) { NS_ENSURE_ARG(aContentType); - NS_ENSURE_ARG(request); + NS_ENSURE_ARG(aChannel); // okay, now we've discovered the content type. We need to do the following: // (1) We always start with the original content listener (if any) that originated the request @@ -1055,7 +1051,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType, rv = nsComponentManager::CreateInstance(handlerContractID, nsnull, NS_GET_IID(nsIContentHandler), getter_AddRefs(aContentHandler)); if (NS_SUCCEEDED(rv)) // we did indeed have a content handler for this type!! yippee... { - rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aSrcWindowContext, request); + rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aSrcWindowContext, aChannel); *aAbortProcess = PR_TRUE; } diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index 500e9e281bf..6b58308e549 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -48,8 +48,7 @@ #include "nsIRefreshURI.h" #include "nsIDocumentLoader.h" #include "nsIHelperAppLauncherDialog.h" -#include "nsITransport.h" -#include "nsIFileTransportService.h" + #include "nsCExternalHandlerService.h" // contains contractids for the helper app service #include "nsMimeTypes.h" @@ -600,7 +599,7 @@ NS_IMETHODIMP nsExternalAppHandler::CloseProgressWindow() return NS_OK; } -void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel* aChannel) +void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel * aChannel) { // if the channel is an http channel and we have a content disposition header set, // then use the file name suggested there as the preferred file name to SUGGEST to the user. @@ -641,15 +640,12 @@ void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel* aChan } // if we had an http channel } -nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIRequest *request) +nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIChannel * aChannel) { // we are going to run the downloading of the helper app in our own little docloader / load group context. // so go ahead and force the creation of a load group and doc loader for us to use... nsresult rv = NS_OK; - nsCOMPtr aChannel = do_QueryInterface(request); - NS_ENSURE_TRUE(aChannel, NS_ERROR_FAILURE); - nsCOMPtr uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID)); NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE); @@ -672,12 +668,12 @@ nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIRequest *request) origContextLoader->GetDocumentChannel(getter_AddRefs(mOriginalChannel)); if(oldLoadGroup) - oldLoadGroup->RemoveRequest(request, nsnull, NS_OK, nsnull); + oldLoadGroup->RemoveChannel(aChannel, nsnull, NS_OK, nsnull); aChannel->SetLoadGroup(newLoadGroup); nsCOMPtr req (do_QueryInterface(mLoadCookie)); aChannel->SetNotificationCallbacks(req); - rv = newLoadGroup->AddRequest(request, nsnull); + rv = newLoadGroup->AddChannel(aChannel, nsnull); return rv; } @@ -756,16 +752,13 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel) mTempFile->Append(saltedTempLeafName); // make this file unique!!! mTempFile->CreateUnique(nsnull, nsIFile::NORMAL_FILE_TYPE, 0644); - NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); - NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr fileTransport; - rv = fts->CreateTransport(mTempFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0664, getter_AddRefs(fileTransport)); - if (NS_FAILED(rv)) return rv; - - rv = fileTransport->OpenOutputStream(0, -1, 0, getter_AddRefs(mOutStream)); - + nsCOMPtr fileChannel = do_CreateInstance(NS_LOCALFILECHANNEL_CONTRACTID); + if (fileChannel) + { + rv = fileChannel->Init(mTempFile, -1, 0); + if (NS_FAILED(rv)) return rv; + rv = fileChannel->OpenOutputStream(getter_AddRefs(mOutStream)); + if (NS_FAILED(rv)) return rv; #ifdef XP_MAC nsXPIDLCString contentType; mMimeInfo->GetMIMEType(getter_Copies(contentType)); @@ -780,25 +773,24 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel) } } #endif + } return rv; } -NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) +NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) { - NS_ENSURE_ARG(request); + NS_ENSURE_ARG(aChannel); // first, check to see if we've been canceled.... if (mCanceled) // then go cancel our underlying channel too - return request->Cancel(NS_BINDING_ABORTED); - - nsCOMPtr aChannel = do_QueryInterface(request); + return aChannel->Cancel(NS_BINDING_ABORTED); nsresult rv = SetUpTempFile(aChannel); // retarget all load notifcations to our docloader instead of the original window's docloader... - RetargetLoadNotifications(request); + RetargetLoadNotifications(aChannel); // ignore failure... ExtractSuggestedFileNameFromChannel(aChannel); nsCOMPtr httpChannel = do_QueryInterface( aChannel ); @@ -835,12 +827,12 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo return NS_OK; } -NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, +NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * inStr, PRUint32 sourceOffset, PRUint32 count) { // first, check to see if we've been canceled.... if (mCanceled) // then go cancel our underlying channel too - return request->Cancel(NS_BINDING_ABORTED); + return aChannel->Cancel(NS_BINDING_ABORTED); // read the data out of the stream and write it to the temp file. PRUint32 numBytesRead = 0; @@ -861,7 +853,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIRequest *request, nsISupp return NS_OK; } -NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, +NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIChannel * aChannel, nsISupports *aCtxt, nsresult aStatus, const PRUnichar * errorMsg) { nsresult rv = NS_OK; @@ -869,7 +861,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISuppor // first, check to see if we've been canceled.... if (mCanceled) // then go cancel our underlying channel too - return request->Cancel(NS_BINDING_ABORTED); + return aChannel->Cancel(NS_BINDING_ABORTED); // go ahead and execute the application passing in our temp file as an argument // this may involve us calling back into the OS external app service to make the call @@ -1143,7 +1135,7 @@ NS_IMETHODIMP nsExternalAppHandler::CanHandleContent(const char * aContentType, } NS_IMETHODIMP nsExternalAppHandler::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIRequest * aRequest, + nsIChannel * aOpenedChannel, nsIStreamListener ** aContentHandler,PRBool * aAbortProcess) { NS_NOTREACHED("DoContent"); diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.h b/mozilla/uriloader/exthandler/nsExternalHelperAppService.h index f126f1ca16b..0ff11d8f45e 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.h +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.h @@ -179,7 +179,7 @@ protected: // when we download a helper app, we are going to retarget all load notifications into our own docloader // and load group instead of using the window which initiated the load....RetargetLoadNotifications contains // that information... - nsresult RetargetLoadNotifications(nsIRequest *request); + nsresult RetargetLoadNotifications(nsIChannel * aChannel); // if the user tells us how they want to dispose of the content and we still haven't finished downloading while // they were deciding, then throw a progress dialog so they know what's going on... nsresult ShowProgressDialog(); diff --git a/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp b/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp index 46097106ba3..1141701f429 100644 --- a/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -144,18 +144,30 @@ nsresult nsExtProtocolChannel::OpenURL() return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsExtProtocolChannel::Open(nsIInputStream **_retval) +NS_IMETHODIMP nsExtProtocolChannel::OpenInputStream(nsIInputStream **_retval) { OpenURL(); // force caller to abort. return NS_ERROR_FAILURE; // force caller to abort. } -NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsExtProtocolChannel::OpenOutputStream(nsIOutputStream **_retval) +{ + NS_NOTREACHED("OpenOutputStream"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsExtProtocolChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) { OpenURL(); return NS_ERROR_FAILURE; // force caller to abort. } +NS_IMETHODIMP nsExtProtocolChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +{ + NS_NOTREACHED("AsyncWrite"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsExtProtocolChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes) { *aLoadAttributes = 0; @@ -190,6 +202,83 @@ nsExtProtocolChannel::SetContentLength(PRInt32 aContentLength) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsExtProtocolChannel::GetTransferOffset(PRUint32 *aTransferOffset) +{ + NS_NOTREACHED("GetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::SetTransferOffset(PRUint32 aTransferOffset) +{ + NS_NOTREACHED("SetTransferOffset"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::GetTransferCount(PRInt32 *aTransferCount) +{ + NS_NOTREACHED("GetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::SetTransferCount(PRInt32 aTransferCount) +{ + NS_NOTREACHED("SetTransferCount"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) +{ + NS_NOTREACHED("GetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +{ + NS_NOTREACHED("SetBufferSegmentSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::GetBufferMaxSize(PRUint32 *aBufferMaxSize) +{ + NS_NOTREACHED("GetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::SetBufferMaxSize(PRUint32 aBufferMaxSize) +{ + NS_NOTREACHED("SetBufferMaxSize"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::GetLocalFile(nsIFile* *file) +{ + NS_NOTREACHED("GetLocalFile"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsExtProtocolChannel::GetPipeliningAllowed(PRBool *aPipeliningAllowed) +{ + *aPipeliningAllowed = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +nsExtProtocolChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) +{ + NS_NOTREACHED("SetPipeliningAllowed"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsExtProtocolChannel::GetOwner(nsISupports * *aPrincipal) { NS_NOTREACHED("GetOwner"); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index c553970783f..09fcfd8d199 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2092,7 +2092,7 @@ nsBrowserWindow::OnStartDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, nsresult aStatus) { return NS_OK; @@ -2100,14 +2100,14 @@ nsBrowserWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest* request) + nsIChannel* channel) { return NS_OK; } NS_IMETHODIMP nsBrowserWindow::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -2116,7 +2116,7 @@ nsBrowserWindow::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, nsString& aMsg) { return NS_OK; @@ -2124,20 +2124,19 @@ nsBrowserWindow::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, nsresult aStatus) { return NS_OK; } NS_IMETHODIMP -nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt, +nsBrowserWindow::OnProgress(nsIChannel* channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv; nsCOMPtr aURL; - nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; @@ -2163,7 +2162,7 @@ nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt, } NS_IMETHODIMP -nsBrowserWindow::OnStatus(nsIRequest* request, nsISupports *ctxt, +nsBrowserWindow::OnStatus(nsIChannel* channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aStatusArg) { if (mStatus) { diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index 9736af8cc85..866e25121a9 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -335,7 +335,7 @@ nsWebCrawler::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, NS_IMETHODIMP nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, nsresult aStatus) { nsresult rv; @@ -356,7 +356,6 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, } nsCOMPtr aURL; - nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) { return rv; @@ -459,14 +458,14 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsWebCrawler::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest* request) + nsIChannel* channel) { return NS_OK; } NS_IMETHODIMP nsWebCrawler::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -475,14 +474,14 @@ nsWebCrawler::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsWebCrawler::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, + nsIChannel* channel, nsString& aMsg) { return NS_OK; } NS_IMETHODIMP -nsWebCrawler::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest* request, +nsWebCrawler::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) { return NS_OK; diff --git a/mozilla/widget/src/gtk/nsGtkMozRemoteHelper.cpp b/mozilla/widget/src/gtk/nsGtkMozRemoteHelper.cpp index 8a7acabba73..6011c9ee8df 100644 --- a/mozilla/widget/src/gtk/nsGtkMozRemoteHelper.cpp +++ b/mozilla/widget/src/gtk/nsGtkMozRemoteHelper.cpp @@ -127,7 +127,7 @@ NS_IMETHODIMP RemoteHelperContentListener::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, - nsIRequest *aOpenedRequest, + nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { diff --git a/mozilla/widget/src/gtk/nsSound.cpp b/mozilla/widget/src/gtk/nsSound.cpp index 8642de78f4c..4b77484fac8 100644 --- a/mozilla/widget/src/gtk/nsSound.cpp +++ b/mozilla/widget/src/gtk/nsSound.cpp @@ -116,19 +116,15 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, // print a load error on bad status if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr request; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) { + nsCOMPtr channel; + aLoader->GetChannel(getter_AddRefs(channel)); + if (channel) { nsCOMPtr uri; - nsCOMPtr channel = do_QueryInterface(request); - if (channel) { - channel->GetURI(getter_AddRefs(uri)); - if (uri) { - char* uriSpec; - uri->GetSpec(&uriSpec); - printf("Failed to load %s\n", uriSpec ? uriSpec : ""); - CRTFREEIF(uriSpec); - } + channel->GetURI(getter_AddRefs(uri)); + if (uri) { + char* uriSpec; + uri->GetSpec(&uriSpec); + printf("Failed to load %s\n", uriSpec ? uriSpec : ""); } } } diff --git a/mozilla/widget/src/os2/nsSound.cpp b/mozilla/widget/src/os2/nsSound.cpp index e5e50aad1dd..e95bcb5130c 100644 --- a/mozilla/widget/src/os2/nsSound.cpp +++ b/mozilla/widget/src/os2/nsSound.cpp @@ -61,19 +61,15 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, // print a load error on bad status if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr request; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) { + nsCOMPtr channel; + aLoader->GetChannel(getter_AddRefs(channel)); + if (channel) { nsCOMPtr uri; - nsCOMPtr channel = do_QueryInterface(request); - if (channel) { - channel->GetURI(getter_AddRefs(uri)); - if (uri) { - char* uriSpec; - uri->GetSpec(&uriSpec); - printf("Failed to load %s\n", uriSpec ? uriSpec : ""); - CRTFREEIF(uriSpec); - } + channel->GetURI(getter_AddRefs(uri)); + if (uri) { + char* uriSpec; + uri->GetSpec(&uriSpec); + printf("Failed to load %s\n", uriSpec ? uriSpec : ""); } } } diff --git a/mozilla/widget/src/windows/nsSound.cpp b/mozilla/widget/src/windows/nsSound.cpp index ed70430cfd2..3ce8b749c0d 100644 --- a/mozilla/widget/src/windows/nsSound.cpp +++ b/mozilla/widget/src/windows/nsSound.cpp @@ -95,11 +95,8 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, // print a load error on bad status if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr request; nsCOMPtr channel; - aLoader->GetRequest(getter_AddRefs(request)); - if (request) - channel = do_QueryInterface(request); + aLoader->GetChannel(getter_AddRefs(channel)); if (channel) { nsCOMPtr uri; channel->GetURI(getter_AddRefs(uri)); diff --git a/mozilla/xpcom/tests/PropertiesTest.cpp b/mozilla/xpcom/tests/PropertiesTest.cpp index ae35b483d89..581a52d9637 100644 --- a/mozilla/xpcom/tests/PropertiesTest.cpp +++ b/mozilla/xpcom/tests/PropertiesTest.cpp @@ -119,7 +119,7 @@ main(int argc, char* argv[]) ret = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQ); if (NS_FAILED(ret)) return ret; - ret = channel->Open(&in); + ret = channel->OpenInputStream(&in); if (NS_FAILED(ret)) return ret; nsIPersistentProperties* props = nsnull; diff --git a/mozilla/xpcom/tests/utils/io.js b/mozilla/xpcom/tests/utils/io.js index 2c7fa02b378..d1f351baa0c 100644 --- a/mozilla/xpcom/tests/utils/io.js +++ b/mozilla/xpcom/tests/utils/io.js @@ -293,7 +293,7 @@ write : function(buffer, perms) { var fileSize = parseInt( this.fileInst.fileSize ); - var outStream = this.fileChannel.open(); + var outStream = this.fileChannel.openOutputStream(); if( outStream.write(buffer, buffSize) ) dump("io.js:write: Write to file successful . . . \n\n"); @@ -341,7 +341,7 @@ read : function() { this.fileChannel.init(this.fileInst, READ, perm); - var inStream = this.fileChannel.open(); + var inStream = this.fileChannel.openInputStream(); this.inputStream.init(inStream); diff --git a/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl b/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl index 9e843cd5311..905ed94d91f 100644 --- a/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl +++ b/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl @@ -28,7 +28,7 @@ * it's ui. */ -interface nsIRequest; +interface nsIChannel; [scriptable, uuid(46B4015C-0121-11d4-9877-00C04FA0D27A)] interface nsIXULBrowserWindow : nsISupports @@ -57,7 +57,7 @@ interface nsIXULBrowserWindow : nsISupports Tells the browser window that there is a state change with the window. These state flags are specified in nsIWebProgress. */ - void onStateChange(in nsIRequest aRequest, in unsigned long aProgressStateFlags); + void onStateChange(in nsIChannel aChannel, in unsigned long aProgressStateFlags); /* Tells the browser window that the location of the window has changed. @@ -67,12 +67,12 @@ interface nsIXULBrowserWindow : nsISupports /* Tells the browser window that the progress for the current load has changed. */ - void onProgress (in nsIRequest aRequest, in long aCurrentProgress, in long aMaxProgress); + void onProgress (in nsIChannel aChannel, in long aCurrentProgress, in long aMaxProgress); /* Tells the browser window that a new status message is available. */ - void onStatus(in nsIRequest aRequest, in nsresult aStatus, in wstring aMsg); + void onStatus(in nsIChannel aChannel, in nsresult aStatus, in wstring aMsg); }; diff --git a/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl b/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl index 9e843cd5311..905ed94d91f 100644 --- a/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl +++ b/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl @@ -28,7 +28,7 @@ * it's ui. */ -interface nsIRequest; +interface nsIChannel; [scriptable, uuid(46B4015C-0121-11d4-9877-00C04FA0D27A)] interface nsIXULBrowserWindow : nsISupports @@ -57,7 +57,7 @@ interface nsIXULBrowserWindow : nsISupports Tells the browser window that there is a state change with the window. These state flags are specified in nsIWebProgress. */ - void onStateChange(in nsIRequest aRequest, in unsigned long aProgressStateFlags); + void onStateChange(in nsIChannel aChannel, in unsigned long aProgressStateFlags); /* Tells the browser window that the location of the window has changed. @@ -67,12 +67,12 @@ interface nsIXULBrowserWindow : nsISupports /* Tells the browser window that the progress for the current load has changed. */ - void onProgress (in nsIRequest aRequest, in long aCurrentProgress, in long aMaxProgress); + void onProgress (in nsIChannel aChannel, in long aCurrentProgress, in long aMaxProgress); /* Tells the browser window that a new status message is available. */ - void onStatus(in nsIRequest aRequest, in nsresult aStatus, in wstring aMsg); + void onStatus(in nsIChannel aChannel, in nsresult aStatus, in wstring aMsg); }; diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index b9a6556e3e2..2584db53086 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -195,9 +195,9 @@ nsXULBrowserWindow.prototype = statusTextFld.setAttribute("value", text); }, - onProgress : function (request, current, max) + onProgress : function (channel, current, max) { - if (!this.useRealProgressFlag && request) + if (!this.useRealProgressFlag && channel) return; if (!statusMeter) @@ -216,7 +216,7 @@ nsXULBrowserWindow.prototype = } }, - onStateChange : function(request, state) + onStateChange : function(channel, state) { const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; @@ -262,9 +262,9 @@ nsXULBrowserWindow.prototype = if (!this.useRealProgressFlag) this.onProgress(null, this.finishedRequests, this.totalRequests); } + if (state & nsIWebProgressListener.STATE_IS_NETWORK) { - var channel = request.QueryInterface(Components.interfaces.nsIChannel); - var location = channel.URI.spec; + var location = channel.URI.spec; var msg = ""; if (location != "about:blank") { // Record page loading time. @@ -289,8 +289,7 @@ nsXULBrowserWindow.prototype = } else if (state & nsIWebProgressListener.STATE_TRANSFERRING) { if (state & nsIWebProgressListener.STATE_IS_DOCUMENT) { - var channel = request.QueryInterface(Components.interfaces.nsIChannel); - var ctype=channel.contentType; + var ctype=channel.contentType; if (ctype != "text/html") this.useRealProgressFlag = true; @@ -320,7 +319,7 @@ nsXULBrowserWindow.prototype = UpdateBackForwardButtons(); }, - onStatus : function(request, status, msg) + onStatus : function(channel, status, msg) { this.setOverLink(msg); //this.setDefaultStatus(msg); diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index 29117cdc5e2..342ecd52f0b 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -903,7 +903,7 @@ nsBrowserInstance::FindNext() //***************************************************************************** nsresult nsBrowserInstance::StartDocumentLoad(nsIDOMWindow *aDOMWindow, - nsIRequest *request) + nsIChannel *aChannel) { nsresult rv; @@ -911,9 +911,6 @@ nsresult nsBrowserInstance::StartDocumentLoad(nsIDOMWindow *aDOMWindow, nsXPIDLCString uriCString; nsAutoString urlStr; - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; - // Get the URI strign and convert it to unicode... rv = aChannel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; @@ -961,14 +958,11 @@ nsresult nsBrowserInstance::StartDocumentLoad(nsIDOMWindow *aDOMWindow, } nsresult nsBrowserInstance::EndDocumentLoad(nsIDOMWindow *aDOMWindow, - nsIRequest *request, + nsIChannel *aChannel, nsresult aStatus) { nsresult rv; - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; - nsCOMPtr uri; rv = aChannel->GetOriginalURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; @@ -1096,7 +1090,7 @@ nsBrowserInstance::GetProtocolHandler(nsIURI * /* aURI */, nsIProtocolHandler ** NS_IMETHODIMP nsBrowserInstance::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, - nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) + nsIChannel *aChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { nsCOMPtr docShell; GetContentAreaDocShell(getter_AddRefs(docShell)); @@ -1104,7 +1098,7 @@ nsBrowserInstance::DoContent(const char *aContentType, nsURILoadCommand aCommand // forward the DoContent call to our content area webshell nsCOMPtr ctnListener (do_GetInterface(docShell)); if (ctnListener) - return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, request, aContentHandler, aAbortProcess); + return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, aChannel, aContentHandler, aAbortProcess); return NS_OK; } @@ -1217,7 +1211,13 @@ nsBrowserInstance::OnProgressChange(nsIWebProgress* aWebProgress, { EnsureXULBrowserWindow(); if(mXULBrowserWindow) { - mXULBrowserWindow->OnProgress(aRequest, aCurTotalProgress, aMaxTotalProgress); + nsresult rv; + nsCOMPtr channel; + + channel = do_QueryInterface(aRequest, &rv); + if (NS_SUCCEEDED(rv)) { + mXULBrowserWindow->OnProgress(channel, aCurTotalProgress, aMaxTotalProgress); + } } return NS_OK; } @@ -1229,11 +1229,12 @@ nsBrowserInstance::OnStateChange(nsIWebProgress* aWebProgress, nsresult aStatus) { nsresult rv; + nsCOMPtr channel(do_QueryInterface(aRequest)); EnsureXULBrowserWindow(); // Ignore this notification if it did not originate from a channel... - if (!aRequest) { + if (!channel) { return NS_OK; } @@ -1243,16 +1244,16 @@ nsBrowserInstance::OnStateChange(nsIWebProgress* aWebProgress, rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow)); if (NS_SUCCEEDED(rv)) { if (aStateFlags & nsIWebProgressListener::STATE_START) { - rv = StartDocumentLoad(domWindow, aRequest); + rv = StartDocumentLoad(domWindow, channel); } else if (aStateFlags & nsIWebProgressListener::STATE_STOP) { - rv = EndDocumentLoad(domWindow, aRequest, aStatus); + rv = EndDocumentLoad(domWindow, channel, aStatus); } } } if(mXULBrowserWindow) { - mXULBrowserWindow->OnStateChange(aRequest, aStateFlags); + mXULBrowserWindow->OnStateChange(channel, aStateFlags); } return NS_OK; } @@ -1281,7 +1282,13 @@ nsBrowserInstance::OnStatusChange(nsIWebProgress* aWebProgress, { EnsureXULBrowserWindow(); if(mXULBrowserWindow) { - mXULBrowserWindow->OnStatus(aRequest, aStatus, aMessage); + nsresult rv; + nsCOMPtr channel; + + channel = do_QueryInterface(aRequest, &rv); + if (NS_SUCCEEDED(rv)) { + mXULBrowserWindow->OnStatus(channel, aStatus, aMessage); + } } return NS_OK; } @@ -1492,11 +1499,11 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, - nsIRequest * aRequest) + nsIChannel * aChannel) { // we need a dom window to create the new browser window...in order // to do this, we need to get the window mediator service and ask it for a dom window - NS_ENSURE_ARG(aRequest); + NS_ENSURE_ARG(aChannel); nsCOMPtr parentWindow; JSContext* jsContext = nsnull; @@ -1526,10 +1533,6 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType, NS_ERROR_FAILURE); } - - nsCOMPtr aChannel = do_QueryInterface(aRequest); - if (!aChannel) return NS_ERROR_FAILURE; - nsCOMPtr uri; aChannel->GetURI(getter_AddRefs(uri)); NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE); @@ -1560,7 +1563,7 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType, JS_PopArguments(jsContext, mark); // now abort the current channel load... - aRequest->Cancel(NS_BINDING_ABORTED); + aChannel->Cancel(NS_BINDING_ABORTED); return NS_OK; } diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.h b/mozilla/xpfe/browser/src/nsBrowserInstance.h index 3dcd839dce7..56558bfe75e 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.h +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.h @@ -97,10 +97,10 @@ class nsBrowserInstance : public nsIBrowserInstance, // helper methods for dealing with document loading... nsresult StartDocumentLoad(nsIDOMWindow *aDOMWindow, - nsIRequest *request); + nsIChannel *aChannel); nsresult EndDocumentLoad(nsIDOMWindow *aDOMWindow, - nsIRequest *request, + nsIChannel *aChannel, nsresult aResult); PRBool mIsClosed; diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp index a5c9b7bde5d..c1d9d4485c6 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -2000,12 +2000,13 @@ nsBookmarksService::FireTimer(nsITimer* aTimer, void* aClosure) if (httpChannel) { bmks->htmlSize = 0; + nsCOMPtr headAtom = getter_AddRefs(NS_NewAtom("HEAD")); if (headAtom) { httpChannel->SetRequestMethod(headAtom); } - if (NS_SUCCEEDED(rv = channel->AsyncOpen(bmks, nsnull))) + if (NS_SUCCEEDED(rv = channel->AsyncRead(bmks, nsnull))) { bmks->busySchedule = PR_TRUE; } @@ -2041,7 +2042,7 @@ else NS_IMETHODIMP -nsBookmarksService::OnStartRequest(nsIRequest* request, nsISupports *ctxt) +nsBookmarksService::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { return(NS_OK); } @@ -2049,7 +2050,7 @@ nsBookmarksService::OnStartRequest(nsIRequest* request, nsISupports *ctxt) NS_IMETHODIMP -nsBookmarksService::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *aIStream, +nsBookmarksService::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { // calculate html page size if server doesn't tell us in headers @@ -2061,7 +2062,7 @@ nsBookmarksService::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsII NS_IMETHODIMP -nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, +nsBookmarksService::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsresult rv; @@ -2073,7 +2074,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, printf("Finished polling '%s'\n", uri); #endif } - nsCOMPtr channel = do_QueryInterface(request); + nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { diff --git a/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp b/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp index 6e6b7b56750..52527dea130 100644 --- a/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp @@ -299,7 +299,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsHTTPIndexParser, nsIStreamListener, nsIStreamObs NS_IMETHODIMP -nsHTTPIndexParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) +nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) { nsresult rv; @@ -356,8 +356,6 @@ nsHTTPIndexParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) return NS_ERROR_FAILURE; } - nsCOMPtr aChannel = do_QueryInterface(request); - // Save off some information about the stream we're about to parse. nsCOMPtr mDirectoryURI; rv = aChannel->GetURI(getter_AddRefs(mDirectoryURI)); @@ -388,7 +386,7 @@ nsHTTPIndexParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) NS_IMETHODIMP -nsHTTPIndexParser::OnStopRequest(nsIRequest *request, +nsHTTPIndexParser::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -427,7 +425,7 @@ nsHTTPIndexParser::OnStopRequest(nsIRequest *request, NS_IMETHODIMP -nsHTTPIndexParser::OnDataAvailable(nsIRequest *request, +nsHTTPIndexParser::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, nsIInputStream* aStream, PRUint32 aSourceOffset, @@ -1327,7 +1325,7 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure) } if (NS_SUCCEEDED(rv) && (listener)) { - rv = channel->AsyncOpen(listener, aSource); + rv = channel->AsyncRead(listener, aSource); } } } @@ -1696,7 +1694,7 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, aDocViewerResult); if (NS_FAILED(rv)) return rv; - rv = channel->AsyncOpen(listener, nsnull); + rv = channel->AsyncRead(listener, nsnull); if (NS_FAILED(rv)) return rv; // Create an HTTPIndex object so that we can stuff it into the script context diff --git a/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp b/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp index c9b08f442af..fa5f6225f4a 100644 --- a/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp +++ b/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp @@ -239,7 +239,7 @@ NS_IMPL_ISUPPORTS1(RelatedLinksStreamListener, nsIStreamListener) NS_IMETHODIMP -RelatedLinksStreamListener::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +RelatedLinksStreamListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { nsAutoString trueStr; trueStr.AssignWithConversion("true"); nsIRDFLiteral *literal = nsnull; @@ -255,7 +255,7 @@ RelatedLinksStreamListener::OnStartRequest(nsIRequest *request, nsISupports *ctx NS_IMETHODIMP -RelatedLinksStreamListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +RelatedLinksStreamListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsAutoString trueStr; trueStr.AssignWithConversion("true"); @@ -276,7 +276,7 @@ RelatedLinksStreamListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt NS_IMETHODIMP -RelatedLinksStreamListener::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +RelatedLinksStreamListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { nsresult rv = NS_OK; diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp index 5f3e086b838..0b4ae07d18b 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -632,7 +632,8 @@ InternetSearchDataSource::FireTimer(nsITimer* aTimer, void* aClosure) { httpChannel->SetRequestMethod(headAtom); } - if (NS_SUCCEEDED(rv = channel->AsyncOpen(search, engineContext))) + + if (NS_SUCCEEDED(rv = channel->AsyncRead(search, engineContext))) { search->busySchedule = PR_TRUE; @@ -2201,8 +2202,8 @@ InternetSearchDataSource::AddSearchEngine(const char *engineURL, const char *ico nsCOMPtr engineChannel; if (NS_FAILED(rv = NS_OpenURI(getter_AddRefs(engineChannel), engineURI, nsnull, mBackgroundLoadGroup))) return(rv); - - if (NS_FAILED(rv = engineChannel->AsyncOpen(this, engineContext))) + + if (NS_FAILED(rv = engineChannel->AsyncRead(this, engineContext))) return(rv); // download icon @@ -2221,7 +2222,8 @@ InternetSearchDataSource::AddSearchEngine(const char *engineURL, const char *ico nsCOMPtr iconChannel; if (NS_FAILED(rv = NS_OpenURI(getter_AddRefs(iconChannel), iconURI, nsnull, mBackgroundLoadGroup))) return(rv); - if (NS_FAILED(rv = iconChannel->AsyncOpen(this, iconContext))) + + if (NS_FAILED(rv = iconChannel->AsyncRead(this, iconContext))) return(rv); } return(NS_OK); @@ -2790,18 +2792,18 @@ InternetSearchDataSource::Stop() // cancel any outstanding connections if (mLoadGroup) { - nsCOMPtr requests; - if (NS_SUCCEEDED(rv = mLoadGroup->GetRequests(getter_AddRefs(requests)))) + nsCOMPtr channels; + if (NS_SUCCEEDED(rv = mLoadGroup->GetChannels(getter_AddRefs(channels)))) { PRBool more; - while (NS_SUCCEEDED(rv = requests->HasMoreElements(&more)) && (more == PR_TRUE)) + while (NS_SUCCEEDED(rv = channels->HasMoreElements(&more)) && (more == PR_TRUE)) { nsCOMPtr isupports; - if (NS_FAILED(rv = requests->GetNext(getter_AddRefs(isupports)))) + if (NS_FAILED(rv = channels->GetNext(getter_AddRefs(isupports)))) break; - nsCOMPtr request = do_QueryInterface(isupports); - if (!request) continue; - request->Cancel(NS_BINDING_ABORTED); + nsCOMPtr channel = do_QueryInterface(isupports); + if (!channel) continue; + channel->Cancel(NS_BINDING_ABORTED); } } mLoadGroup->Cancel(NS_BINDING_ABORTED); @@ -3552,8 +3554,7 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin } } - nsCOMPtr request; - if (NS_SUCCEEDED(rv = channel->AsyncOpen(this, context))) + if (NS_SUCCEEDED(rv = channel->AsyncRead(this, context))) { } } @@ -4277,7 +4278,7 @@ InternetSearchDataSource::GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult NS_IMETHODIMP -InternetSearchDataSource::OnStartRequest(nsIRequest *request, nsISupports *ctxt) +InternetSearchDataSource::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { #ifdef DEBUG_SEARCH_OUTPUT printf("InternetSearchDataSourceCallback::OnStartRequest entered.\n"); @@ -4288,7 +4289,7 @@ InternetSearchDataSource::OnStartRequest(nsIRequest *request, nsISupports *ctxt) NS_IMETHODIMP -InternetSearchDataSource::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, +InternetSearchDataSource::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { if (!ctxt) return(NS_ERROR_NO_INTERFACE); @@ -4381,13 +4382,11 @@ InternetSearchDataSource::OnDataAvailable(nsIRequest *request, nsISupports *ctxt NS_IMETHODIMP -InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +InternetSearchDataSource::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if (!mInner) return(NS_OK); - nsCOMPtr channel = do_QueryInterface(request); - nsCOMPtr context = do_QueryInterface(ctxt); if (!ctxt) return(NS_ERROR_NO_INTERFACE); diff --git a/mozilla/xpfe/components/ucth/public/nsIUnkContentTypeHandler.idl b/mozilla/xpfe/components/ucth/public/nsIUnkContentTypeHandler.idl index a08eab1f153..dbe656395bb 100644 --- a/mozilla/xpfe/components/ucth/public/nsIUnkContentTypeHandler.idl +++ b/mozilla/xpfe/components/ucth/public/nsIUnkContentTypeHandler.idl @@ -24,8 +24,6 @@ #include "domstubs.idl" #include "nsIChannel.idl" -interface nsIRequest; - /*----------------------- nsIUnknownContentTypeHandler ------------------------- | This file describes the interface for Mozilla's "unknown content-type | | handler" component. This component is notified whenever the browser | @@ -45,7 +43,7 @@ interface nsIRequest; [scriptable, uuid(a6cf90ef-15b3-11d2-932e-00805f8add32)] interface nsIUnknownContentTypeHandler : nsIAppShellComponent { - void HandleUnknownContentType( in nsIRequest request, + void HandleUnknownContentType( in nsIChannel aURL, in string aContentType, in nsIDOMWindowInternal aWindow ); }; diff --git a/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp b/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp index 91c0a0bb138..f55fc2edf31 100644 --- a/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp +++ b/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp @@ -87,20 +87,15 @@ public: // HandleUnknownContentType (from nsIUnknownContentTypeHandler) implementation. // XXX We can get the content type from the channel now so that arg could be dropped. NS_IMETHODIMP -nsUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request, +nsUnknownContentTypeHandler::HandleUnknownContentType( nsIChannel *aChannel, const char *aContentType, nsIDOMWindowInternal *aWindow ) { nsresult rv = NS_OK; - nsCOMPtr aChannel; nsCOMPtr channel; nsCAutoString contentDisp; - - - if ( request ) { - - channel = do_QueryInterface(request); + if ( aChannel ) { // Need root nsISupports for later JS_PushArguments call. channel = do_QueryInterface( aChannel ); @@ -119,7 +114,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request, } // Cancel input channel now. - rv = request->Cancel(NS_BINDING_ABORTED); + rv = aChannel->Cancel(NS_BINDING_ABORTED); if ( NS_FAILED( rv ) ) { DEBUG_PRINTF( PR_STDOUT, "%s %d: Cancel failed, rv=0x%08X\n", (char*)__FILE__, (int)__LINE__, (int)rv ); diff --git a/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp b/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp index 263359a094a..e4b1fa4fbed 100644 --- a/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp +++ b/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp @@ -80,15 +80,10 @@ private: // Get content type and suggested name from input channel in this case. NS_IMETHODIMP nsStreamTransfer::SelectFileAndTransferLocation( nsIChannel *aChannel, nsIDOMWindowInternal *parent ) { - - nsCOMPtr uri; - nsresult rv = aChannel->GetURI( getter_AddRefs( uri ) ); - if (NS_FAILED(rv)) return rv; - // Content type comes straight from channel. nsXPIDLCString contentType; aChannel->GetContentType( getter_Copies( contentType ) ); - + // Suggested name derived from content-disposition response header. nsCAutoString suggestedName; diff --git a/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp b/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp index 4424a91945e..b75f8de9516 100644 --- a/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp +++ b/mozilla/xpfe/components/xfer/src/nsStreamXferOp.cpp @@ -60,7 +60,7 @@ NS_IMPL_ISUPPORTS4(nsStreamXferOp, nsIStreamObserver, nsIStreamTransferOperation // ctor - save arguments in data members. nsStreamXferOp::nsStreamXferOp( nsIChannel *source, nsILocalFile *target ) : mInputChannel( source ), - mOutputTransport( 0 ), + mOutputChannel( 0 ), mOutputStream( 0 ), mOutputFile( target ), mObserver( 0 ), @@ -168,23 +168,22 @@ nsStreamXferOp::Start( void ) { nsresult rv = NS_OK; if ( mInputChannel ) { - if ( !mOutputTransport ) { + if ( !mOutputChannel ) { // First, get file transport service. NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); NS_WITH_SERVICE( nsIFileTransportService, fts, kFileTransportServiceCID, &rv ); if ( NS_SUCCEEDED( rv ) ) { // Next, create output file channel. - rv = fts->CreateTransport( mOutputFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0664, - getter_AddRefs( mOutputTransport ) ); + getter_AddRefs( mOutputChannel ) ); if ( NS_SUCCEEDED( rv ) ) { #ifdef USE_ASYNC_READ // Read the input channel (with ourself as the listener). - rv = mInputChannel->AsyncOpen(this, nsnull); + rv = mInputChannel->AsyncRead(this, nsnull); if ( NS_FAILED( rv ) ) { this->OnError( kOpAsyncRead, rv ); } @@ -199,7 +198,7 @@ nsStreamXferOp::Start( void ) { // get the input stream from the channel. nsCOMPtr inStream; - rv = mInputChannel->Open(getter_AddRefs(inStream)); + rv = mInputChannel->OpenInputStream(getter_AddRefs(inStream)); if (NS_FAILED(rv)) { this->OnError(0, rv); return rv; @@ -207,10 +206,7 @@ nsStreamXferOp::Start( void ) { // hand the output channel our input stream. it will take care // of reading data from the stream and writing it to disk. - nsCOMPtr dummyRequest; - rv = NS_AsyncWriteFromStream(getter_AddRefs(dummyRequest), - mOutputTransport, inStream, 0, -1, /*flags?*/ - NS_STATIC_CAST(nsIStreamObserver*, this)); + rv = NS_AsyncWriteFromStream(mOutputChannel, inStream, NS_STATIC_CAST(nsIStreamObserver*,this), nsnull); if ( NS_FAILED( rv ) ) { this->OnError( kOpAsyncWrite, rv ); } @@ -250,8 +246,7 @@ nsStreamXferOp::Stop( void ) { nsCOMPtr channel = mInputChannel; mInputChannel = 0; // Now cancel it. - if (channel) - rv = channel->Cancel(NS_BINDING_ABORTED); + rv = channel->Cancel(NS_BINDING_ABORTED); if ( NS_FAILED( rv ) ) { this->OnError( kOpInputCancel, rv ); } @@ -271,7 +266,7 @@ nsStreamXferOp::Stop( void ) { } // Cancel output channel. - mOutputTransport = 0; + mOutputChannel = 0; return rv; } @@ -280,19 +275,13 @@ nsStreamXferOp::Stop( void ) { // // We also open the output stream at this point. NS_IMETHODIMP -nsStreamXferOp::OnStartRequest(nsIRequest *request, nsISupports* aContext) { - nsresult rv = NS_OK; - -#ifdef DEBUG_law - DEBUG_PRINTF( PR_STDOUT, "nsStreamXferOp::OnStartRequest; request=0x%08X, context=0x%08X\n", - (int)(void*)request, (int)(void*)aContext ); -#endif +nsStreamXferOp::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { + nsresult rv = NS_ERROR_FAILURE; #ifdef USE_ASYNC_READ if ( !mOutputStream ) { // Open output stream. - rv = mOutputTransport->OpenOutputStream(0,-1,0,getter_AddRefs( mOutputStream ) ); - + rv = mOutputChannel->OpenOutputStream( getter_AddRefs( mOutputStream ) ); if ( NS_FAILED( rv ) ) { // Give up all hope. this->OnError( kOpOpenOutputStream, rv ); @@ -307,7 +296,7 @@ nsStreamXferOp::OnStartRequest(nsIRequest *request, nsISupports* aContext) { #ifdef USE_ASYNC_READ // Process the data by writing it to the output channel. NS_IMETHODIMP -nsStreamXferOp::OnDataAvailable( nsIRequest* request, +nsStreamXferOp::OnDataAvailable( nsIChannel *channel, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 offset, @@ -370,13 +359,11 @@ nsStreamXferOp::OnDataAvailable( nsIRequest* request, } else { // Fake OnProgress. mBytesProcessed += aLength; - if ( mContentLength == 0 && request ) { + if ( mContentLength == 0 && channel ) { // Get content length from input channel. - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; channel->GetContentLength( &mContentLength ); } - this->OnProgress( request, 0, mBytesProcessed, mContentLength ); + this->OnProgress( mOutputChannel, 0, mBytesProcessed, mContentLength ); } return rv; @@ -396,14 +383,12 @@ nsStreamXferOp::GetInterface(const nsIID &anIID, void **aResult ) { // expected. // NS_IMETHODIMP -nsStreamXferOp::OnProgress(nsIRequest *request, nsISupports* aContext, +nsStreamXferOp::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; if (mContentLength < 1) { - NS_ASSERTION(request, "should have a request"); - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) return NS_ERROR_FAILURE; + NS_ASSERTION(channel, "should have a channel"); rv = channel->GetContentLength(&mContentLength); if (NS_FAILED(rv)) return rv; } @@ -427,7 +412,7 @@ nsStreamXferOp::OnProgress(nsIRequest *request, nsISupports* aContext, // "subject", the topic is the component contractid (plus ";onStatus"), and // the data is the status text. NS_IMETHODIMP -nsStreamXferOp::OnStatus( nsIRequest *request, +nsStreamXferOp::OnStatus( nsIChannel *channel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusArg) { @@ -454,7 +439,7 @@ nsStreamXferOp::OnStatus( nsIRequest *request, // This is called when the end of input is reached on the input channel. NS_IMETHODIMP -nsStreamXferOp::OnStopRequest( nsIRequest *request, +nsStreamXferOp::OnStopRequest( nsIChannel *channel, nsISupports *aContext, nsresult aStatus, const PRUnichar *aMsg ) { @@ -477,7 +462,7 @@ nsStreamXferOp::OnStopRequest( nsIRequest *request, // Unhook input/output channels (don't need to cancel 'em). mInputChannel = 0; - mOutputTransport = 0; + mOutputChannel = 0; // Notify observer that the download is complete. if ( !mError && mObserver ) { diff --git a/mozilla/xpfe/components/xfer/src/nsStreamXferOp.h b/mozilla/xpfe/components/xfer/src/nsStreamXferOp.h index 5f93815573a..61d0ad0c4f9 100644 --- a/mozilla/xpfe/components/xfer/src/nsStreamXferOp.h +++ b/mozilla/xpfe/components/xfer/src/nsStreamXferOp.h @@ -29,7 +29,7 @@ #include "nsIChannel.h" #include "nsIOutputStream.h" #include "nsILocalFile.h" -#include "nsITransport.h" + #include "nsCOMPtr.h" class nsIDOMWindowInternal; @@ -83,7 +83,7 @@ public: private: nsCOMPtr mInputChannel; - nsCOMPtr mOutputTransport; + nsCOMPtr mOutputChannel; nsCOMPtr mOutputStream; nsCOMPtr mOutputFile; nsIObserver *mObserver; // Not owned; owner should call SetObserver(0) prior diff --git a/mozilla/xpinstall/src/nsInstallTrigger.cpp b/mozilla/xpinstall/src/nsInstallTrigger.cpp index 8e937b1f159..0e5797e8c14 100644 --- a/mozilla/xpinstall/src/nsInstallTrigger.cpp +++ b/mozilla/xpinstall/src/nsInstallTrigger.cpp @@ -110,14 +110,13 @@ nsInstallTrigger::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports* aWindowContext, - nsIRequest* request) + nsIChannel * aChannel) { nsresult rv = NS_OK; - if (!request) return NS_ERROR_NULL_POINTER; + if (!aChannel) return NS_ERROR_NULL_POINTER; if (nsCRT::strcasecmp(aContentType, "application/x-xpinstall") == 0) { nsCOMPtr uri; - nsCOMPtr aChannel = do_QueryInterface(request); rv = aChannel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/xpinstall/src/nsXPInstallManager.cpp b/mozilla/xpinstall/src/nsXPInstallManager.cpp index ddc43846bf6..b8e63e589bc 100644 --- a/mozilla/xpinstall/src/nsXPInstallManager.cpp +++ b/mozilla/xpinstall/src/nsXPInstallManager.cpp @@ -32,7 +32,6 @@ #include "nsIURL.h" -#include "nsITransport.h" #include "nsIFileTransportService.h" #include "nsIOutputStream.h" #include "nsNetUtil.h" @@ -456,7 +455,7 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext() if (NS_SUCCEEDED(rv)) { - rv = channel->AsyncOpen(this, nsnull); + rv = channel->AsyncRead(this, nsnull); } } } @@ -693,7 +692,7 @@ nsXPInstallManager::GetDestinationFile(nsString& url, nsILocalFile* *file) NS_IMETHODIMP -nsXPInstallManager::OnStartRequest(nsIRequest* request, nsISupports *ctxt) +nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) { nsresult rv = NS_ERROR_FAILURE; @@ -707,7 +706,7 @@ nsXPInstallManager::OnStartRequest(nsIRequest* request, nsISupports *ctxt) if (NS_SUCCEEDED(rv) && !mItem->mOutStream) { - nsCOMPtr outChannel; + nsCOMPtr outChannel; rv = fts->CreateTransport(mItem->mFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, @@ -717,7 +716,7 @@ nsXPInstallManager::OnStartRequest(nsIRequest* request, nsISupports *ctxt) if (NS_SUCCEEDED(rv)) { // Open output stream. - rv = outChannel->OpenOutputStream(0, -1, 0, getter_AddRefs( mItem->mOutStream ) ); + rv = outChannel->OpenOutputStream( getter_AddRefs( mItem->mOutStream ) ); } } } @@ -725,7 +724,7 @@ nsXPInstallManager::OnStartRequest(nsIRequest* request, nsISupports *ctxt) } NS_IMETHODIMP -nsXPInstallManager::OnStopRequest(nsIRequest *request, nsISupports *ctxt, +nsXPInstallManager::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsresult rv; @@ -781,7 +780,7 @@ nsXPInstallManager::OnStopRequest(nsIRequest *request, nsISupports *ctxt, NS_IMETHODIMP -nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, +nsXPInstallManager::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *pIStream, PRUint32 sourceOffset, PRUint32 length) @@ -819,7 +818,7 @@ nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, } NS_IMETHODIMP -nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) +nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; @@ -827,7 +826,6 @@ nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint32 if (!mCancelled && TimeToUpdate(now)) { if (mContentLength < 1) { - nsCOMPtr channel = do_QueryInterface(request); NS_ASSERTION(channel, "should have a channel"); rv = channel->GetContentLength(&mContentLength); if (NS_FAILED(rv)) return rv; @@ -840,7 +838,7 @@ nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint32 } NS_IMETHODIMP -nsXPInstallManager::OnStatus(nsIRequest* request, nsISupports *ctxt, +nsXPInstallManager::OnStatus(nsIChannel *channel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aStatusArg) { nsresult rv;