From 175245e2dea606aee8dcaf8db16964231593dbb8 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Wed, 21 Feb 2001 20:38:08 +0000 Subject: [PATCH] Relanding Necko Changes. Revising nsIChannel to allow for overlapped i/o. This consists of three parts: 1. Factoring nsIChannel into a protocol specific part, the nsIChannel, and a socket specific, the nsITransport. 2. Derive the nsIChannel from a nsIRequest. 2. Changes the notification system from necko and the URILoader to pass the nsIRequest interface instead of nsIChannel interface. This goal stems from wanting to be able to have active AsyncRead and AsyncWrite operations on nsSocketTransport. This is desired because it would greatly simplify the task of maintaining persistent/reusable socket connections for FTP, HTTP, and Imap (and potentially other protocols). The problem with the existing nsIChannel interface is that it does not allow one to selectively suspend just one of the read or write operations while keeping the other active. r=darin@netscape.com sr=rpotts@netscape.com git-svn-id: svn://10.0.0.236/trunk@87587 18797224-902f-48f8-a5cc-f745e15eee43 --- .../chrome/src/nsChromeProtocolHandler.cpp | 180 +- .../content/base/src/nsSyncLoadService.cpp | 2 +- .../html/document/src/nsHTMLContentSink.cpp | 8 +- .../html/document/src/nsHTMLDocument.cpp | 52 +- .../html/document/src/nsImageDocument.cpp | 16 +- mozilla/content/xbl/src/nsXBLService.cpp | 37 +- .../xml/document/src/nsXMLContentSink.cpp | 6 +- .../xml/document/src/nsXMLDocument.cpp | 14 +- .../content/xml/document/src/nsXMLDocument.h | 2 +- .../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 | 87 +- .../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 | 93 +- 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 +- mozilla/htmlparser/src/nsScanner.h | 1 + .../htmlparser/tests/grabpage/grabpage.cpp | 2 +- mozilla/intl/strres/src/nsStringBundle.cpp | 6 +- mozilla/layout/base/nsPresShell.cpp | 63 +- mozilla/layout/html/base/src/nsPresShell.cpp | 63 +- .../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 | 125 +- mozilla/mailnews/compose/src/nsURLFetcher.cpp | 46 +- mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp | 2 +- .../imap/src/nsImapIncomingServer.cpp | 5 +- .../mailnews/imap/src/nsImapMailFolder.cpp | 19 +- mozilla/mailnews/imap/src/nsImapProtocol.cpp | 200 +- 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 +- .../local/src/nsPop3IncomingServer.cpp | 2 +- mozilla/mailnews/local/src/nsPop3Protocol.cpp | 4 +- mozilla/mailnews/local/src/nsPop3Protocol.h | 2 +- mozilla/mailnews/local/src/nsPop3Service.cpp | 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 | 60 +- mozilla/mailnews/news/src/nsNNTPProtocol.h | 4 +- mozilla/mailnews/news/src/nsNntpService.cpp | 5 +- mozilla/modules/libjar/nsJARChannel.cpp | 165 +- 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 | 2 +- mozilla/netwerk/base/public/makefile.win | 5 +- mozilla/netwerk/base/public/nsIChannel.idl | 153 +- 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 | 406 +-- mozilla/netwerk/base/src/nsFileTransport.h | 12 +- .../base/src/nsFileTransportService.cpp | 31 +- .../netwerk/base/src/nsFileTransportService.h | 7 +- mozilla/netwerk/base/src/nsIOService.cpp | 46 +- mozilla/netwerk/base/src/nsIOService.h | 2 + .../netwerk/base/src/nsInputStreamChannel.cpp | 301 +- .../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 | 2617 ++++++++--------- mozilla/netwerk/base/src/nsSocketTransport.h | 282 +- .../base/src/nsSocketTransportService.cpp | 18 +- .../base/src/nsSocketTransportService.h | 2 - .../base/src/nsStreamListenerProxy.cpp | 94 +- .../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 | 6 +- .../base/src/nsStreamProviderProxy.cpp | 42 +- .../netwerk/base/src/nsSyncStreamListener.cpp | 6 +- .../filecache/nsDiskCacheRecordChannel.cpp | 191 +- .../filecache/nsDiskCacheRecordChannel.h | 13 +- .../cache/memcache/nsMemCacheChannel.cpp | 141 +- .../cache/memcache/nsMemCacheChannel.h | 11 +- .../netwerk/cache/mgr/nsCacheEntryChannel.cpp | 83 +- .../netwerk/cache/mgr/nsCacheEntryChannel.h | 23 +- mozilla/netwerk/cache/mgr/nsCachedNetData.cpp | 20 +- mozilla/netwerk/macbuild/netwerk.mcp | Bin 175988 -> 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 | 271 +- .../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 | 300 +- .../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 | 165 +- .../netwerk/protocol/jar/src/nsJARChannel.h | 6 +- mozilla/netwerk/protocol/res/src/Makefile.in | 2 +- .../netwerk/protocol/res/src/nsResChannel.cpp | 316 +- .../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 | 2 +- mozilla/netwerk/test/TestCacheMgr.cpp | 12 +- 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 | 17 +- 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 +- mozilla/parser/htmlparser/src/nsScanner.h | 1 + .../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 | 25 +- .../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/themes/classic/README | 1 - 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 | 13 +- .../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 +- 267 files changed, 5408 insertions(+), 7480 deletions(-) diff --git a/mozilla/chrome/src/nsChromeProtocolHandler.cpp b/mozilla/chrome/src/nsChromeProtocolHandler.cpp index 392fb916814..9d3566b0c6d 100644 --- a/mozilla/chrome/src/nsChromeProtocolHandler.cpp +++ b/mozilla/chrome/src/nsChromeProtocolHandler.cpp @@ -116,27 +116,25 @@ public: NS_DECL_ISUPPORTS // nsIRequest - NS_IMETHOD GetName(PRUnichar* *result) { - NS_NOTREACHED("nsCachedChromeChannel::GetName"); - return NS_ERROR_NOT_IMPLEMENTED; - } + NS_IMETHOD GetName(PRUnichar* *result) { 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 + +// nsIChannel NS_DECL_NSICHANNEL + }; #ifdef PR_LOGGING PRLogModuleInfo* nsCachedChromeChannel::gLog; #endif -NS_IMPL_ADDREF(nsCachedChromeChannel); -NS_IMPL_RELEASE(nsCachedChromeChannel); -NS_IMPL_QUERY_INTERFACE2(nsCachedChromeChannel, nsIRequest, nsIChannel); +NS_IMPL_ISUPPORTS2(nsCachedChromeChannel, + nsIChannel, + nsIRequest); nsresult nsCachedChromeChannel::Create(nsIURI* aURI, nsIChannel** aResult) @@ -211,7 +209,7 @@ nsCachedChromeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsCachedChromeChannel::OpenInputStream(nsIInputStream **_retval) +nsCachedChromeChannel::Open(nsIInputStream **_retval) { // NS_NOTREACHED("don't do that"); *_retval = nsnull; @@ -219,15 +217,7 @@ nsCachedChromeChannel::OpenInputStream(nsIInputStream **_retval) } NS_IMETHODIMP -nsCachedChromeChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("don't do that"); - *_retval = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { if (listener) { nsresult rv; @@ -237,7 +227,7 @@ nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: adding self to load group %p", this, mLoadGroup.get())); - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -257,7 +247,7 @@ nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: removing self from load group %p", this, mLoadGroup.get())); - (void) mLoadGroup->RemoveChannel(this, nsnull, nsnull, nsnull); + (void) mLoadGroup->RemoveRequest(this, nsnull, nsnull, nsnull); } return rv; @@ -271,10 +261,9 @@ nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) } NS_IMETHODIMP -nsCachedChromeChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - NS_NOTREACHED("don't do that"); - return NS_ERROR_FAILURE; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -291,113 +280,6 @@ 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) { @@ -441,12 +323,34 @@ nsCachedChromeChannel::SetNotificationCallbacks(nsIInterfaceRequestor * aNotific return NS_OK; // ignored } - NS_IMETHODIMP -nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +nsCachedChromeChannel::GetContentType(char * *aContentType) { - *aSecurityInfo = nsnull; - return NS_OK; + *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; } nsresult @@ -523,12 +427,14 @@ 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(channel, channel->mContext, + (void) channel->mListener->OnStopRequest(request, channel->mContext, channel->mStatus, nsnull); if (channel->mLoadGroup) { @@ -536,7 +442,7 @@ nsCachedChromeChannel::HandleStopLoadEvent(PLEvent* aEvent) ("nsCachedChromeChannel[%p]: removing self from load group %p", channel, channel->mLoadGroup.get())); - (void) channel->mLoadGroup->RemoveChannel(channel, nsnull, nsnull, nsnull); + (void) channel->mLoadGroup->RemoveRequest(request, nsnull, nsnull, nsnull); } channel->mListener = nsnull; diff --git a/mozilla/content/base/src/nsSyncLoadService.cpp b/mozilla/content/base/src/nsSyncLoadService.cpp index d60c04a4f18..b117e9653c9 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->AsyncRead(listener, nsnull); + rv = channel->AsyncOpen(listener, nsnull); if (NS_FAILED(rv)) { if (modalEventQueue) { diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 6612eb566e4..18d1c0a64d4 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -4715,8 +4715,12 @@ HTMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader, nsCOMPtr httpChannel; nsCOMPtr channel; - rv = aLoader->GetChannel(getter_AddRefs(channel)); - NS_ASSERTION(channel, "StreamLoader's channel went away prematurely"); + 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); if (channel) { httpChannel = do_QueryInterface(channel); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index aa0468a13d1..6b2289d5e76 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -596,33 +596,35 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, nsCOMPtr file; rv = fileChannel->GetFile(getter_AddRefs(file)); - 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; + 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; - 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/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 25273539b74..35f5130880c 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -121,10 +121,14 @@ ImageListener::~ImageListener() NS_IMPL_THREADSAFE_ISUPPORTS1(ImageListener, nsIStreamListener) NS_IMETHODIMP -ImageListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +ImageListener::OnStartRequest(nsIRequest* request, 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; @@ -133,11 +137,11 @@ ImageListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStartRequest(channel, ctxt); + return mNextStream->OnStartRequest(request, ctxt); } NS_IMETHODIMP -ImageListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +ImageListener::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if(mDocument){ @@ -147,17 +151,17 @@ ImageListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); + return mNextStream->OnStopRequest(request, ctxt, status, errorMsg); } NS_IMETHODIMP -ImageListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +ImageListener::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); + return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index ace03aa71b3..65ca0b2f7e3 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -260,38 +260,37 @@ 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(nsIChannel* aChannel, nsISupports* aCtxt, nsIInputStream* aInStr, +nsXBLStreamListener::OnDataAvailable(nsIRequest *request, nsISupports* aCtxt, nsIInputStream* aInStr, PRUint32 aSourceOffset, PRUint32 aCount) { if (mInner) - return mInner->OnDataAvailable(aChannel, aCtxt, aInStr, aSourceOffset, aCount); + return mInner->OnDataAvailable(request, aCtxt, aInStr, aSourceOffset, aCount); return NS_ERROR_FAILURE; } -/* void onStartRequest (in nsIChannel channel, in nsISupports ctxt); */ NS_IMETHODIMP -nsXBLStreamListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aCtxt) +nsXBLStreamListener::OnStartRequest(nsIRequest* request, nsISupports* aCtxt) { if (mInner) - return mInner->OnStartRequest(aChannel, aCtxt); + return mInner->OnStartRequest(request, aCtxt); return NS_ERROR_FAILURE; } -/* void onStopRequest (in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); */ NS_IMETHODIMP -nsXBLStreamListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aCtxt, nsresult aStatus, const PRUnichar* aStatusArg) +nsXBLStreamListener::OnStopRequest(nsIRequest* request, nsISupports* aCtxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mInner) { - rv = mInner->OnStopRequest(aChannel, aCtxt, aStatus, aStatusArg); + rv = mInner->OnStopRequest(request, aCtxt, aStatus, aStatusArg); } if (NS_FAILED(rv) || NS_FAILED(aStatus)) { - if (aChannel) + + nsCOMPtr aChannel = do_QueryInterface(request); + if (aChannel) { nsCOMPtr channelURI; aChannel->GetURI(getter_AddRefs(channelURI)); @@ -1191,7 +1190,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; @@ -1233,18 +1232,22 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun xblListener->AddRequest(req); // Now kick off the async read. - channel->AsyncRead(xblListener, nsnull); + channel->AsyncOpen(xblListener, nsnull); return NS_OK; } // Now do a blocking synchronous parse of the file. nsCOMPtr in; PRUint32 sourceOffset = 0; - rv = channel->OpenInputStream(getter_AddRefs(in)); + rv = channel->Open(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; @@ -1253,7 +1256,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun if (! proxy) return NS_ERROR_FAILURE; - listener->OnStartRequest(channel, nsnull); + listener->OnStartRequest(request, nsnull); while (PR_TRUE) { char buf[1024]; PRUint32 readCount; @@ -1266,12 +1269,12 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun proxy->SetBuffer(buf, readCount); - rv = listener->OnDataAvailable(channel, nsnull, proxy, sourceOffset, readCount); + rv = listener->OnDataAvailable(request, nsnull, proxy, sourceOffset, readCount); sourceOffset += readCount; if (NS_FAILED(rv)) break; } - listener->OnStopRequest(channel, nsnull, NS_OK, nsnull); + listener->OnStopRequest(request, nsnull, NS_OK, nsnull); // don't leak proxy! proxy->Close(); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index ccf919ab43b..de51c6171c8 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -1664,7 +1664,11 @@ nsXMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader, if (NS_OK == aStatus) { { // scope in block so nsCOMPtr released at one point nsCOMPtr channel; - aLoader->GetChannel(getter_AddRefs(channel)); + nsCOMPtr request; + aLoader->GetRequest(getter_AddRefs(request)); + if (request) + channel = do_QueryInterface(request); + 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 c6f85d09db3..bfd86ccb357 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -77,6 +77,12 @@ #include "nsContentCID.h" static NS_DEFINE_CID(kHTMLStyleSheetCID,NS_HTMLSTYLESHEET_CID); +#include "nsCExternalHandlerService.h" +#include "nsIMIMEService.h" +#include "nsNetUtil.h" +#include "nsMimeTypes.h" + + // XXX The XML world depends on the html atoms #include "nsHTMLAtoms.h" @@ -350,7 +356,7 @@ nsXMLDocument::Load(const nsAReadableString& aUrl) } // Start an asynchronous read of the XML document - rv = channel->AsyncRead(listener, nsnull); + rv = channel->AsyncOpen(listener, nsnull); return rv; } @@ -380,8 +386,10 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, rv = aChannel->GetURI(getter_AddRefs(aUrl)); if (NS_FAILED(rv)) return rv; - rv = aChannel->GetContentType(&aContentType); - + nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + rv = MIMEService->GetTypeFromURI(aUrl, &aContentType); + if (NS_SUCCEEDED(rv)) { if ( 0 == PL_strcmp(aContentType, "text/html")) { bIsHTML = PR_TRUE; diff --git a/mozilla/content/xml/document/src/nsXMLDocument.h b/mozilla/content/xml/document/src/nsXMLDocument.h index 8832b5cf43a..c5fe3152dd1 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.h +++ b/mozilla/content/xml/document/src/nsXMLDocument.h @@ -52,7 +52,7 @@ public: NS_IMETHOD GetContentType(nsAWritableString& aContentType) const; NS_IMETHOD StartDocumentLoad(const char* aCommand, - nsIChannel* aChannel, + nsIChannel* channel, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, diff --git a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp index 46cf82af769..2e3b2bef92d 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp @@ -54,7 +54,9 @@ 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() @@ -212,7 +214,7 @@ nsLDAPChannel::Cancel(nsresult aStatus) // remove self from loadgroup to stop the throbber // if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, mResponseContext, aStatus, + rv = mLoadGroup->RemoveRequest(this, mResponseContext, aStatus, nsnull); if (NS_FAILED(rv)) return rv; @@ -283,55 +285,6 @@ 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 @@ -563,86 +516,6 @@ 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. @@ -653,35 +526,14 @@ nsLDAPChannel::SetPipeliningAllowed(PRBool aPipeliningAllowed) // the data, the amount available is returned in the stream. // NS_IMETHODIMP -nsLDAPChannel::OpenInputStream(nsIInputStream* *result) +nsLDAPChannel::Open(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::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, +nsLDAPChannel::AsyncOpen(nsIStreamListener* aListener, nsISupports* aCtxt) { nsresult rv; @@ -696,7 +548,7 @@ nsLDAPChannel::AsyncRead(nsIStreamListener* aListener, // add ourselves to the appropriate loadgroup // if (mLoadGroup) { - mLoadGroup->AddChannel(this, mResponseContext); + mLoadGroup->AddRequest(this, mResponseContext); } // slurp out relevant pieces of the URL @@ -812,24 +664,6 @@ nsLDAPChannel::AsyncRead(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. * @@ -1004,7 +838,7 @@ nsLDAPChannel::OnLDAPSearchResult(nsILDAPMessage *aMessage) // remove self from loadgroup to stop the throbber // if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, mResponseContext, NS_OK, nsnull); + rv = mLoadGroup->RemoveRequest(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 d58838aea4b..af965962ef1 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, - nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler, + nsIRequest* request, nsIStreamListener** aContentHandler, PRBool* aAbortProcess) { NS_ENSURE_ARG_POINTER(aContentHandler); @@ -89,6 +89,8 @@ 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); @@ -100,7 +102,7 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, } nsresult rv = mDocShell->CreateContentViewer(aContentType, - aOpenedChannel, aContentHandler); + request, 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 feeb51e4c44..35a0c583664 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2752,7 +2752,7 @@ NS_IMETHODIMP nsDocShell::CreateAboutBlankContentViewer() } NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, - nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler) + nsIRequest *request, nsIStreamListener** aContentHandler) { // Can we check the content type of the current content viewer // and reuse it without destroying it and re-creating it? @@ -2762,12 +2762,17 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, // Instantiate the content viewer object nsCOMPtr viewer; - if(NS_FAILED(NewContentViewerObj(aContentType, aOpenedChannel, loadGroup, - aContentHandler, getter_AddRefs(viewer)))) + nsresult rv = NewContentViewerObj(aContentType, request, loadGroup, + aContentHandler, getter_AddRefs(viewer)); + + if(NS_FAILED(rv)) 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... @@ -2798,9 +2803,9 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, aOpenedChannel->SetLoadAttributes(loadAttribs); - loadGroup->AddChannel(aOpenedChannel, nsnull); + loadGroup->AddRequest(request, nsnull); if(currentLoadGroup) - currentLoadGroup->RemoveChannel(aOpenedChannel, nsnull, nsnull, nsnull); + currentLoadGroup->RemoveRequest(request, nsnull, nsnull, nsnull); } #ifdef SH_IN_FRAMES @@ -2814,7 +2819,7 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType, } nsresult nsDocShell::NewContentViewerObj(const char* aContentType, - nsIChannel* aOpenedChannel, nsILoadGroup* aLoadGroup, + nsIRequest *request, nsILoadGroup* aLoadGroup, nsIStreamListener** aContentHandler, nsIContentViewer** aViewer) { //XXX This should probably be some category thing.... @@ -2841,6 +2846,8 @@ 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 493487652b7..b9b0b8ab958 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -194,9 +194,9 @@ protected: NS_IMETHOD EnsureDeviceContext(); NS_IMETHOD CreateAboutBlankContentViewer(); NS_IMETHOD CreateContentViewer(const char* aContentType, - nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler); + nsIRequest *request, nsIStreamListener** aContentHandler); NS_IMETHOD NewContentViewerObj(const char* aContentType, - nsIChannel* aOpenedChannel, nsILoadGroup* aLoadGroup, + nsIRequest *request, 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 86bd29b344c..e1ad70b4d50 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 *aRequest, +nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *request, PRInt32 aStateFlags, nsresult aStatus) { - if (!aRequest) { + if (!request) { return NS_OK; } @@ -903,7 +903,8 @@ nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, if (aProgress == webProgress.get()) { nsCOMPtr url; - nsCOMPtr channel(do_QueryInterface(aRequest)); + + nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr dlObserver; (void) channel->GetURI(getter_AddRefs(url)); @@ -936,21 +937,21 @@ nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, * Fire the OnEndDocumentLoad of the DocLoaderobserver */ if(dlObserver && url) { - dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus); + dlObserver->OnEndDocumentLoad(mDocLoader, request, aStatus); } } } } if (aStateFlags & STATE_IS_REQUEST) { - nsCOMPtr channel(do_QueryInterface(aRequest)); - + nsCOMPtr channel = do_QueryInterface(request); + if (aStateFlags & STATE_START) { /* *Fire the OnStartDocumentLoad of the webshell observer */ if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) { - mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel); + mDocLoaderObserver->OnStartURLLoad(mDocLoader, request); } } else if (aStateFlags & STATE_STOP) { @@ -958,27 +959,26 @@ nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, *Fire the OnEndDocumentLoad of the webshell observer */ if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) { - mDocLoaderObserver->OnEndURLLoad(mDocLoader, channel, aStatus); + mDocLoaderObserver->OnEndURLLoad(mDocLoader, request, aStatus); } } } - return nsDocShell::OnStateChange(aProgress, aRequest, aStateFlags, aStatus); + return nsDocShell::OnStateChange(aProgress, request, aStateFlags, aStatus); } //---------------------------------------------------------------------- nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, - nsIChannel *aChannel, + nsIChannel* channel, nsresult aStatus) { nsresult rv = NS_OK; - if(!aChannel) + if(!channel) return NS_ERROR_NULL_POINTER; - + nsCOMPtr url; - - rv = aChannel->GetURI(getter_AddRefs(url)); + rv = channel->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, aChannel, aStatus); + nsDocShell::EndPageLoad(aProgress, channel, 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 20998508efb..707b016846f 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 *aChannel, + nsIChannel* channel, nsresult aStatus); nsIEventQueue* mThreadEventQueue; @@ -156,7 +156,7 @@ protected: nsresult FireUnloadForChildren(); - nsresult CreateViewer(nsIChannel* aChannel, + nsresult CreateViewer(nsIRequest* request, const char* aContentType, const char* aCommand, nsIStreamListener** aResult); diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 29596bf8f24..5bd402056fb 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, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) +NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest* request, 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 29596bf8f24..5bd402056fb 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, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) +NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest* request, 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 94f2fc814c9..c0f618763b5 100644 --- a/mozilla/embedding/browser/Makefile.in +++ b/mozilla/embedding/browser/Makefile.in @@ -35,4 +35,5 @@ 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 d0159701dc5..caf32dccf82 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 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) +/* 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) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -714,7 +714,7 @@ CWebBrowserContainer::GetPersistence(PRBool* aPersistX, PRBool* aPersistY, NS_IMETHODIMP -CWebBrowserContainer::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) +CWebBrowserContainer::OnStartRequest(nsIRequest *request, nsISupports* aContext) { USES_CONVERSION; NG_TRACE(_T("CWebBrowserContainer::OnStartRequest(...)\n")); @@ -724,7 +724,7 @@ CWebBrowserContainer::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext NS_IMETHODIMP -CWebBrowserContainer::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) +CWebBrowserContainer::OnStopRequest(nsIRequest *request, 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, nsIChannel *aChannel, nsresult aStatus) +CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) { NG_TRACE(_T("CWebBrowserContainer::OnEndDocumentLoad(..., \"\")\n")); @@ -776,6 +776,9 @@ CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *a char* aString = nsnull; nsIURI* pURI = nsnull; + nsCOMPtr aChannel = do_QueryInterface(request); + if (!aChannel) return NS_ERROR_NULL_POINTER; + aChannel->GetURI(&pURI); if (pURI == nsnull) { @@ -804,7 +807,7 @@ CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *a NS_IMETHODIMP -CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel) +CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) { NG_TRACE(_T("CWebBrowserContainer::OnStartURLLoad(..., \"\")\n")); @@ -815,7 +818,7 @@ CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aCha NS_IMETHODIMP -CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, PRUint32 aProgress, PRUint32 aProgressMax) +CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) { USES_CONVERSION; NG_TRACE(_T("CWebBrowserContainer::OnProgress(..., \"%d\", \"%d\")\n"), (int) aProgress, (int) aProgressMax); @@ -825,7 +828,7 @@ CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* a NS_IMETHODIMP -CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, nsString& aMsg) +CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) { NG_TRACE(_T("CWebBrowserContainer::OnStatusURLLoad(..., \"\")\n")); @@ -840,7 +843,7 @@ CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* aCh NS_IMETHODIMP -CWebBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) +CWebBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest *request, 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 10700b14ce4..1f39b40cf36 100644 --- a/mozilla/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp +++ b/mozilla/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp @@ -264,7 +264,8 @@ NS_IMETHODIMP GtkMozEmbedChrome::OpenStream (const char *aBaseURI, const char *a return rv; // start our request - rv = mStreamListener->OnStartRequest(mChannel, NULL); + nsCOMPtr request = do_QueryInterface(mChannel); + rv = mStreamListener->OnStartRequest(request, NULL); if (NS_FAILED(rv)) return rv; @@ -281,7 +282,8 @@ NS_IMETHODIMP GtkMozEmbedChrome::AppendToStream (const char *aData, gint32 aLen) rv = embedStream->Append(aData, aLen); if (NS_FAILED(rv)) return rv; - rv = mStreamListener->OnDataAvailable(mChannel, + nsCOMPtr request = do_QueryInterface(mChannel); + rv = mStreamListener->OnDataAvailable(request, NULL, mStream, mOffset, /* offset */ @@ -297,7 +299,8 @@ NS_IMETHODIMP GtkMozEmbedChrome::CloseStream (void) nsresult rv; NS_ENSURE_STATE(mDoingStream); mDoingStream = PR_FALSE; - rv = mStreamListener->OnStopRequest(mChannel, + nsCOMPtr request = do_QueryInterface(mChannel); + rv = mStreamListener->OnStopRequest(request, NULL, NS_OK, NULL); @@ -531,7 +534,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::GetProtocolHandler(nsIURI *aURI, nsIProtocolHan } NS_IMETHODIMP GtkMozEmbedChrome::DoContent(const char *aContentType, nsURILoadCommand aCommand, - const char *aWindowTarget, nsIChannel *aOpenedChannel, + const char *aWindowTarget, nsIRequest *request, 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 091b92acf63..72cf6bce23c 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, - nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler, + nsIRequest* request, 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 0e1953382dd..e0e04f6fee0 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; } - mOutputChannel = nsnull; + mOutputTransport = nsnull; } NS_IMPL_ADDREF(nsWebBrowserPersist) @@ -162,10 +162,6 @@ 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); @@ -188,7 +184,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)) @@ -197,10 +193,12 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa return NS_ERROR_FAILURE; } - mOutputChannel = outputChannel; + mOutputTransport = outputChannel; +//dougt wtf?! why both a async and sync read? + // Read from the input channel - rv = inputChannel->AsyncRead(this, nsnull); + rv = inputChannel->AsyncOpen(this, nsnull); if (NS_FAILED(rv)) { OnEndDownload(); @@ -208,7 +206,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa } nsCOMPtr inStream; - rv = inputChannel->OpenInputStream(getter_AddRefs(inStream)); + rv = inputChannel->Open(getter_AddRefs(inStream)); if (NS_FAILED(rv)) { OnEndDownload(); @@ -219,7 +217,10 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa mInputStream = inStream; // Get the output channel ready for writing - rv = NS_AsyncWriteFromStream(outputChannel, inStream, NS_STATIC_CAST(nsIStreamObserver *, this), nsnull); + nsCOMPtr writeRequest; + rv = NS_AsyncWriteFromStream(getter_AddRefs(writeRequest), + outputChannel, inStream, 0, 0, 0, + NS_STATIC_CAST(nsIStreamObserver*, this), nsnull); if (NS_FAILED(rv)) { OnEndDownload(); @@ -394,15 +395,13 @@ NS_IMETHODIMP nsWebBrowserPersist::OnProgress(PRUint32 aStatus, nsIURI *aURI, PR //***************************************************************************** -/* void onStartRequest (in nsIChannel channel, in nsISupports ctxt); */ -NS_IMETHODIMP nsWebBrowserPersist::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) +NS_IMETHODIMP nsWebBrowserPersist::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { - nsresult rv = mOutputChannel->OpenOutputStream(getter_AddRefs(mOutputStream)); + nsresult rv = mOutputTransport->OpenOutputStream(0, -1, 0, getter_AddRefs(mOutputStream)); return rv; } -/* 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) +NS_IMETHODIMP nsWebBrowserPersist::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult status, const PRUnichar *statusArg) { OnEndDownload(); CleanUp(); @@ -415,7 +414,7 @@ NS_IMETHODIMP nsWebBrowserPersist::OnStopRequest(nsIChannel *channel, nsISupport //***************************************************************************** -NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 aOffset, PRUint32 aLength) +NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(nsIRequest* request, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 aOffset, PRUint32 aLength) { nsresult rv = NS_OK; unsigned long bytesRemaining = aLength; @@ -453,9 +452,9 @@ NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(nsIChannel *aChannel, nsISupp // Cancel reading? if (cancel) { - if (aChannel) + if (request) { - aChannel->Cancel(NS_BINDING_ABORTED); + request->Cancel(NS_BINDING_ABORTED); } CleanUp(); OnEndDownload(); @@ -544,8 +543,6 @@ 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) @@ -613,8 +610,6 @@ 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 @@ -892,30 +887,36 @@ nsWebBrowserPersist::MakeAndStoreLocalFilenameInURIMap(const char *aURI, nsStrin // Create a unique file name for the uri MakeFilenameFromURI(uri, inputChannel, filename); - // Query the content type - nsXPIDLCString contentType; - inputChannel->GetContentType(getter_Copies(contentType)); - - // Strap on the file extension using the mime lookup service - if (mMIMEService) + if (!mMIMEService) { - nsCOMPtr mimeInfo; - mMIMEService->GetFromMIMEType(contentType, getter_AddRefs(mimeInfo)); - if (mimeInfo) - { - // 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); - } - } + mMIMEService = do_GetService(NS_MIMESERVICE_CONTRACTID); + if (!mMIMEService) + return NS_ERROR_FAILURE; } + // Strap on the file extension using the mime lookup service + + 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) + { + // 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 20584876067..2a20abf5a78 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 mOutputChannel; + nsCOMPtr mOutputTransport; nsCOMPtr mOutputStream; nsCOMPtr mBaseURI; nsCOMPtr mURI; diff --git a/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp b/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp index 64ca57e3a06..abeaaf2c62c 100644 --- a/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp +++ b/mozilla/extensions/cookie/nsCookieHTTPNotify.cpp @@ -162,8 +162,10 @@ nsCookieHTTPNotify::ModifyRequest(nsISupports *aContext) nsCOMPtr pChannel; if (pLoadGroup) { - rv = pLoadGroup->GetDefaultLoadChannel(getter_AddRefs(pChannel)); - if (NS_FAILED(rv)) return rv; + nsCOMPtr pRequest; + rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest)); + if (pRequest) + pChannel = do_QueryInterface(pRequest); } nsCOMPtr pFirstURL; @@ -222,8 +224,10 @@ nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext) if (NS_FAILED(rv)) return rv; nsCOMPtr pChannel; if (pLoadGroup) { - rv = pLoadGroup->GetDefaultLoadChannel(getter_AddRefs(pChannel)); + nsCOMPtr pRequest; + rv = pLoadGroup->GetDefaultLoadRequest(getter_AddRefs(pRequest)); 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 082a0a6cc27..bffed0e9da7 100644 --- a/mozilla/extensions/datetime/nsDateTimeChannel.cpp +++ b/mozilla/extensions/datetime/nsDateTimeChannel.cpp @@ -28,6 +28,8 @@ #include "nsIInterfaceRequestor.h" #include "nsXPIDLString.h" #include "nsISocketTransportService.h" +#include "nsITransport.h" +#include "nsIProgressEventSink.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -41,7 +43,11 @@ 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) @@ -156,57 +162,48 @@ nsDateTimeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsDateTimeChannel::OpenInputStream(nsIInputStream **_retval) +nsDateTimeChannel::Open(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, 32, 32, getter_AddRefs(channel)); + nsCOMPtr transport; + rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + transport->SetProgressEventSink(sink); + } - return channel->OpenInputStream(_retval); + return transport->OpenInputStream(0, -1, 0, _retval); } NS_IMETHODIMP -nsDateTimeChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("nsDateTimeChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener, - nsISupports *ctxt) +nsDateTimeChannel::AsyncOpen(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, 0, 32, 32, getter_AddRefs(channel)); + nsCOMPtr transport; + rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + transport->SetProgressEventSink(sink); + } mListener = aListener; - - return channel->AsyncRead(this, ctxt); -} - -NS_IMETHODIMP -nsDateTimeChannel::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt) -{ - NS_NOTREACHED("nsDateTimeChannel::AsyncWrite"); - return NS_ERROR_NOT_IMPLEMENTED; + + nsCOMPtr request; + return transport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(request)); } NS_IMETHODIMP @@ -256,83 +253,6 @@ 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) { @@ -345,11 +265,11 @@ NS_IMETHODIMP nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) { if (mLoadGroup) // if we already had a load group remove ourselves... - (void)mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); + (void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); mLoadGroup = aLoadGroup; if (mLoadGroup) { - return mLoadGroup->AddChannel(this, nsnull); + return mLoadGroup->AddRequest(this, nsnull); } return NS_OK; } @@ -384,25 +304,26 @@ nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification return NS_OK; } -NS_IMETHODIMP -nsDateTimeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +NS_IMETHODIMP +nsDateTimeChannel::GetSecurityInfo(nsISupports **sec) { - *aSecurityInfo = nsnull; + NS_ENSURE_ARG_POINTER(sec); + *sec = nsnull; return NS_OK; } // nsIStreamObserver methods NS_IMETHODIMP -nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { +nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { return mListener->OnStartRequest(this, aContext); } NS_IMETHODIMP -nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, +nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { if (mLoadGroup) { - nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); + nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } return mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); @@ -411,7 +332,7 @@ nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsDateTimeChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, +nsDateTimeChannel::OnDataAvailable(nsIRequest *request, 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 e80a83681c8..278f9c7a198 100644 --- a/mozilla/extensions/datetime/nsDateTimeChannel.h +++ b/mozilla/extensions/datetime/nsDateTimeChannel.h @@ -39,7 +39,10 @@ #include "nsIStreamListener.h" -class nsDateTimeChannel : public nsIChannel, public nsIStreamListener { +class nsDateTimeChannel +: public nsIChannel, + public nsIStreamListener { + public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -67,8 +70,6 @@ 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 f85e08414cf..c43dadd3a62 100644 --- a/mozilla/extensions/finger/nsFingerChannel.cpp +++ b/mozilla/extensions/finger/nsFingerChannel.cpp @@ -32,6 +32,7 @@ #include "nsMimeTypes.h" #include "nsIStreamConverterService.h" #include "nsITXTToHTMLConv.h" +#include "nsIProgressEventSink.h" #include "nsNetUtil.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -53,8 +54,11 @@ 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) @@ -144,8 +148,8 @@ nsFingerChannel::Cancel(nsresult status) nsresult rv = NS_ERROR_FAILURE; mStatus = status; - if (mTransport) { - rv = mTransport->Cancel(status); + if (mTransportRequest) { + rv = mTransportRequest->Cancel(status); } return rv; } @@ -198,60 +202,48 @@ nsFingerChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsFingerChannel::OpenInputStream(nsIInputStream **_retval) +nsFingerChannel::Open(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(channel)); + BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + mTransport->SetProgressEventSink(sink); + } - return channel->OpenInputStream(_retval); + return mTransport->OpenInputStream(0, -1, 0, _retval); } NS_IMETHODIMP -nsFingerChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("nsFingerChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt) +nsFingerChannel::AsyncOpen(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(channel)); + BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + mTransport->SetProgressEventSink(sink); + } mListener = aListener; mResponseContext = ctxt; - mTransport = channel; - return SendRequest(channel); -} - -NS_IMETHODIMP -nsFingerChannel::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt) -{ - NS_NOTREACHED("nsFingerChannel::AsyncWrite"); - return NS_ERROR_NOT_IMPLEMENTED; + return SendRequest(mTransport); } NS_IMETHODIMP @@ -301,83 +293,6 @@ 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) { @@ -432,7 +347,7 @@ nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) // nsIStreamObserver methods NS_IMETHODIMP -nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { +nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { if (!mActAsObserver) { // acting as a listener return mListener->OnStartRequest(this, mResponseContext); @@ -445,14 +360,14 @@ nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP -nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, +nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (NS_FAILED(aStatus) || !mActAsObserver) { if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); + rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } rv = mListener->OnStopRequest(this, mResponseContext, aStatus, aStatusArg); @@ -487,7 +402,8 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, converter->PreFormatHTML(PR_TRUE); } - return aChannel->AsyncRead(converterListener, mResponseContext); + return mTransport->AsyncRead(converterListener, mResponseContext, 0,-1, 0, + getter_AddRefs(mTransportRequest)); } } @@ -495,7 +411,7 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsFingerChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, +nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { mContentLength = aLength; @@ -503,7 +419,7 @@ nsFingerChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, } nsresult -nsFingerChannel::SendRequest(nsIChannel* aChannel) { +nsFingerChannel::SendRequest(nsITransport* aTransport) { // The text to send should already be in mUser nsresult rv = NS_OK; @@ -512,7 +428,7 @@ nsFingerChannel::SendRequest(nsIChannel* aChannel) { nsCString requestBuffer(mUser); if (mLoadGroup) { - mLoadGroup->AddChannel(this, nsnull); + mLoadGroup->AddRequest(this, nsnull); } requestBuffer.Append(CRLF); @@ -525,9 +441,10 @@ nsFingerChannel::SendRequest(nsIChannel* aChannel) { charstream = do_QueryInterface(result, &rv); if (NS_FAILED(rv)) return rv; - rv = aChannel->SetTransferCount(requestBuffer.Length()); - if (NS_FAILED(rv)) return rv; - rv = NS_AsyncWriteFromStream(aChannel, charstream, this, nsnull); + rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest), + aTransport, charstream, + 0, requestBuffer.Length(), 0, + this, nsnull); return rv; } diff --git a/mozilla/extensions/finger/nsFingerChannel.h b/mozilla/extensions/finger/nsFingerChannel.h index dc24c0e6d24..e77455dc689 100644 --- a/mozilla/extensions/finger/nsFingerChannel.h +++ b/mozilla/extensions/finger/nsFingerChannel.h @@ -33,9 +33,12 @@ #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 @@ -74,11 +77,12 @@ protected: nsXPIDLCString mRequest; nsCOMPtr mResponseContext; - nsCOMPtr mTransport; + nsCOMPtr mTransport; + nsCOMPtr mTransportRequest; nsresult mStatus; protected: - nsresult SendRequest(nsIChannel* aChannel); + nsresult SendRequest(nsITransport* aTransport); }; #endif /* nsFingerChannel_h___ */ diff --git a/mozilla/extensions/irc/js/lib/chatzilla-service.js b/mozilla/extensions/irc/js/lib/chatzilla-service.js index e1ebdf96c22..6b5e09c3a17 100644 --- a/mozilla/extensions/irc/js/lib/chatzilla-service.js +++ b/mozilla/extensions/irc/js/lib/chatzilla-service.js @@ -107,13 +107,14 @@ function (iid) { } IRCContentHandler.prototype.handleContent = -function (aContentType, aCommand, aWindowTarget, aSourceContext, aChannel) +function (aContentType, aCommand, aWindowTarget, aSourceContext, aRequest) { var e; - + var channel = aRequest.QueryInterface(nsIChannel); + dump ("ircLoader.handleContent (" + aContentType + ", " + aCommand + ", " + aWindowTarget + ", " + aSourceContext + ", " + - aChannel.URI.spec + ")\n"); + channel.URI.spec + ")\n"); var windowManager = Components.classes[MEDIATOR_CONTRACTID].getService(nsIWindowMediator); @@ -123,13 +124,13 @@ function (aContentType, aCommand, aWindowTarget, aSourceContext, aChannel) if (w) { w.focus(); - w.gotoIRCURL(aChannel.URI.spec); + w.gotoIRCURL(channel.URI.spec); } else { var ass = Components.classes[ASS_CONTRACTID].getService(nsIAppShellService); w = ass.getHiddenDOMWindow(); - w.open("chrome://chatzilla/content/chatzilla.xul?" + aChannel.URI.spec, + w.open("chrome://chatzilla/content/chatzilla.xul?" + channel.URI.spec, "_blank", "chrome,menubar,toolbar,resizable"); } @@ -210,8 +211,6 @@ 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; @@ -219,14 +218,9 @@ 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.openInputStream = -BogusChannel.prototype.openOutputStream = -BogusChannel.prototype.asyncWrite = +BogusChannel.prototype.open = +BogusChannel.prototype.asyncOpen = 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 ce3d61f0ada..e9663251113 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); + this._outputStream = this._channel.openOutputStream(0, -1, 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, 0)); + toScriptableInputStream(this._channel.openInputStream (0, -1, 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); + this._channel.asyncRead (new StreamListener (server), this, 0, -1, 0); } } @@ -179,20 +179,20 @@ function StreamListener(server) } StreamListener.prototype.onStartRequest = -function (channel, ctxt) +function (request, ctxt) { - dd ("onStartRequest: " + channel + ", " + ctxt); + dd ("onStartRequest: " + request + ", " + ctxt); } StreamListener.prototype.onStopRequest = -function (channel, ctxt, status, errorMsg) +function (request, ctxt, status, errorMsg) { - dd ("onStopRequest: " + channel + ", " + ctxt + ", " + status + ", " + + dd ("onStopRequest: " + request + ", " + ctxt + ", " + status + ", " + errorMsg); } StreamListener.prototype.onDataAvailable = -function (channel, ctxt, inStr, sourceOffset, count) +function (request, 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 0534ca77871..18c3594bb08 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, 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 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 OnConnectionsComplete(); @@ -696,7 +696,7 @@ nsPICS::OnStartDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsPICS::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, nsresult aStatus) { nsresult rv = NS_OK; @@ -719,9 +719,13 @@ nsPICS::OnEndDocumentLoad(nsIDocumentLoader* loader, } NS_IMETHODIMP -nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel) +nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) { nsresult rv = NS_OK; + + nsCOMPtr channel = do_QueryInterface(request); + if (!channel) + return NS_ERROR_FAILURE; nsCOMPtr aURL; rv = channel->GetURI(getter_AddRefs(aURL)); @@ -798,7 +802,7 @@ nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel) NS_IMETHODIMP nsPICS::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -809,7 +813,7 @@ nsPICS::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsPICS::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, nsString& aMsg) { if(!mPICSRatingsEnabled) @@ -819,11 +823,13 @@ nsPICS::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsPICS::OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, 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 7b97b561eb9..56b302a7932 100644 --- a/mozilla/extensions/psm-glue/public/psm-glue.js +++ b/mozilla/extensions/psm-glue/public/psm-glue.js @@ -9,3 +9,5 @@ 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 e6f60adf8dc..9d6c61b5bd7 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp +++ b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp @@ -719,12 +719,15 @@ NS_IMPL_ISUPPORTS(CertDownloader,NS_GET_IID(nsIStreamListener)); const PRInt32 kDefaultCertAllocLength = 2048; NS_IMETHODIMP -CertDownloader::OnStartRequest(nsIChannel* channel, nsISupports* context) +CertDownloader::OnStartRequest(nsIRequest *request, nsISupports* context) { - nsresult rv; - - rv = channel->GetContentLength(&mContentLength); - if (rv != NS_OK || mContentLength == -1) + nsresult rv = NS_OK; + + nsCOMPtr channel = do_QueryInterface(request); + if (channel) + rv = channel->GetContentLength(&mContentLength); + + if (!channel || rv != NS_OK || mContentLength == -1) mContentLength = kDefaultCertAllocLength; mBufferOffset = 0; @@ -737,7 +740,7 @@ CertDownloader::OnStartRequest(nsIChannel* channel, nsISupports* context) NS_IMETHODIMP -CertDownloader::OnDataAvailable(nsIChannel* channel, +CertDownloader::OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -776,7 +779,7 @@ CertDownloader::OnDataAvailable(nsIChannel* channel, NS_IMETHODIMP -CertDownloader::OnStopRequest(nsIChannel* channel, +CertDownloader::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aMsg) @@ -857,20 +860,23 @@ nsPSMComponent::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports* aWindowContext, - nsIChannel * aChannel) + nsIRequest *request) { // We were called via CI. We better protect ourselves and addref. NS_ADDREF_THIS(); nsresult rv = NS_OK; - if (!aChannel) return NS_ERROR_NULL_POINTER; + if (!request) return NS_ERROR_NULL_POINTER; CMUint32 type = getPSMCertType(aContentType); if (type != -1) { - // I can't directly open the passed channel cause it fails :-( + nsCOMPtr aChannel = do_QueryInterface(request); + if (!aChannel) + return NS_ERROR_FAILURE; + nsCOMPtr uri; rv = aChannel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; @@ -879,10 +885,11 @@ nsPSMComponent::HandleContent(const char * aContentType, rv = NS_OpenURI(getter_AddRefs(channel), uri); if (NS_FAILED(rv)) return rv; - return channel->AsyncRead(new CertDownloader(type), NS_STATIC_CAST(nsIPSMComponent*,this)); + return channel->AsyncOpen(new CertDownloader(type), NS_STATIC_CAST(nsIPSMComponent*,this)); + } - return NS_ERROR_NOT_IMPLEMENTED; + return NS_ERROR_FAILURE; } NS_IMPL_ISUPPORTS(CertContentListener, NS_GET_IID(nsIURIContentListener)); @@ -957,7 +964,7 @@ NS_IMETHODIMP CertContentListener::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIChannel * aOpenedChannel, + nsIRequest * request, 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 d60c04a4f18..b117e9653c9 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->AsyncRead(listener, nsnull); + rv = channel->AsyncOpen(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 9d0e8e0f470..e46dfdaeac8 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -254,7 +254,7 @@ nsWalletlibService::OnStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI* aURL #include "prmem.h" NS_IMETHODIMP -nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* channel, nsresult aStatus) +nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *request, nsresult aStatus) { nsresult rv = NS_OK; @@ -374,6 +374,7 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch nsCOMPtr interfaces; nsCOMPtr prompter; + nsCOMPtr channel = do_QueryInterface(request); if (channel) channel->GetNotificationCallbacks(getter_AddRefs(interfaces)); if (interfaces) @@ -408,21 +409,21 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch NS_IMETHODIMP nsWalletlibService::OnStartURLLoad - (nsIDocumentLoader* loader, nsIChannel* channel) + (nsIDocumentLoader* loader, nsIRequest *request) { return NS_OK; } NS_IMETHODIMP nsWalletlibService::OnProgressURLLoad - (nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax) + (nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP nsWalletlibService::OnStatusURLLoad - (nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg) + (nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) { return NS_OK; } @@ -430,7 +431,7 @@ nsWalletlibService::OnStatusURLLoad NS_IMETHODIMP nsWalletlibService::OnEndURLLoad - (nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) + (nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) { return NS_OK; } diff --git a/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js b/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js index 820ca6e15fc..bfb7da7bca4 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.14 $ + * Version: $Revision: 1.15 $ * - * $Id: nsXmlRpcClient.js,v 1.14 2001-02-12 03:12:39 disttsc%bart.nl Exp $ + * $Id: nsXmlRpcClient.js,v 1.15 2001-02-21 20:36:32 dougt%netscape.com Exp $ */ /* @@ -125,7 +125,7 @@ nsXmlRpcClient.prototype = { debug('Do the deed.'); - var input = channel.openInputStream(); + var input = channel.open(0, 0, 0); input = toScriptableStream(input); var now = new Date() @@ -220,7 +220,7 @@ nsXmlRpcClient.prototype = { var chann = this._getChannel(requestBody); // And...... call! - chann.asyncRead(this, context); + chann.asyncOpen(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 5dbd5ecbbc8..c532a274cae 100644 --- a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp @@ -82,7 +82,9 @@ nsDOMParserChannel::~nsDOMParserChannel() { } -NS_IMPL_ISUPPORTS2(nsDOMParserChannel, nsIRequest, nsIChannel) +NS_IMPL_ISUPPORTS2(nsDOMParserChannel, + nsIChannel, + nsIRequest) /* boolean isPending (); */ NS_IMETHODIMP nsDOMParserChannel::GetName(PRUnichar* *result) @@ -159,38 +161,6 @@ 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) { @@ -232,6 +202,16 @@ 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) { @@ -262,62 +242,12 @@ NS_IMETHODIMP nsDOMParserChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) return NS_ERROR_NOT_IMPLEMENTED; } -/* attribute unsigned long bufferSegmentSize; */ -NS_IMETHODIMP nsDOMParserChannel::GetBufferSegmentSize(PRUint32 *aBufferSegmentSize) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -NS_IMETHODIMP nsDOMParserChannel::SetBufferSegmentSize(PRUint32 aBufferSegmentSize) +NS_IMETHODIMP nsDOMParserChannel::Open(nsIInputStream **_retval) { return NS_ERROR_NOT_IMPLEMENTED; } -/* 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) +NS_IMETHODIMP nsDOMParserChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -509,6 +439,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream, if (principal) { channel->SetOwner(principal); } + nsCOMPtr request = NS_STATIC_CAST(nsIRequest*, parserChannel); // Tell the document to start loading nsCOMPtr listener; @@ -525,15 +456,15 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream, // Now start pumping data to the listener nsresult status; - rv = listener->OnStartRequest(channel, nsnull); - channel->GetStatus(&status); + rv = listener->OnStartRequest(request, nsnull); + request->GetStatus(&status); if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) { - rv = listener->OnDataAvailable(channel, nsnull, stream, 0, contentLength); - channel->GetStatus(&status); + rv = listener->OnDataAvailable(request, nsnull, stream, 0, contentLength); + request->GetStatus(&status); } - rv = listener->OnStopRequest(channel, nsnull, status, nsnull); + rv = listener->OnStopRequest(request, 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 f58c87b0c07..92a45280c4e 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 (mChannel) { - return mChannel->Cancel(NS_BINDING_ABORTED); + if (mReadRequest) { + return mReadRequest->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->AsyncRead(listener, nsnull); + rv = mChannel->AsyncOpen(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 eb258639522..4dfaa4905bb 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.h @@ -89,6 +89,7 @@ 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 971f1983234..0bdebf9b80a 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->OpenInputStream( getter_AddRefs( pInputStream ) ); + rv = pChannel->Open( 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 0510d9dfd5b..fff6c9d0ff6 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, nsIChannel* channel, +mozXMLTerminal::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest* request, nsresult aStatus) { @@ -1068,7 +1068,7 @@ mozXMLTerminal::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel NS_IMETHODIMP mozXMLTerminal::OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel) + nsIRequest* request) { return NS_OK; @@ -1076,7 +1076,7 @@ mozXMLTerminal::OnStartURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP mozXMLTerminal::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, PRUint32 aProgress, + nsIRequest* request, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; @@ -1084,14 +1084,14 @@ mozXMLTerminal::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP mozXMLTerminal::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, nsString& aMsg) + nsIRequest* request, nsString& aMsg) { return NS_OK; } NS_IMETHODIMP mozXMLTerminal::OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, nsresult aStatus) + nsIRequest* request, 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 90b7a7f85af..39ee1a941bc 100644 --- a/mozilla/extensions/xmlterm/ui/xmlterm-service.js +++ b/mozilla/extensions/xmlterm/ui/xmlterm-service.js @@ -114,10 +114,12 @@ function (iid) { } TelnetContentHandler.prototype.handleContent = -function (aContentType, aCommand, aWindowTarget, aSourceContext, aChannel) +function (aContentType, aCommand, aWindowTarget, aSourceContext, aRequest) { var e; + var aChannel = aRequest.QueryInterface(Components.interfaces.nsIChannel); + dump ("telnetLoader.handleContent (" + aContentType + ", " + aCommand + ", " + aWindowTarget + ", " + aSourceContext + ", " + aChannel.URI.spec + ")\n"); @@ -218,8 +220,11 @@ function (aURI) //dump("gSystemPrincipal="+gSystemPrincipal+"\n"); // Cancel XUL request and release channel - temChannel.cancel(Components.results.NS_BINDING_ABORTED); - temChannel = null; + + // why are you canceling here?! you have not even opened anything yet - dougt. + // temChannel.cancel(Components.results.NS_BINDING_ABORTED); + + temChannel = null; // Get current process directory var dscontractid = "@mozilla.org/file/directory_service;1"; @@ -279,8 +284,6 @@ 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; @@ -288,14 +291,10 @@ 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.openInputStream = -BogusChannel.prototype.openOutputStream = -BogusChannel.prototype.asyncWrite = +BogusChannel.prototype.open = +BogusChannel.prototype.asyncOpen = function () { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; @@ -307,12 +306,6 @@ function (observer, ctxt) observer.onStartRequest (this, ctxt); } -BogusChannel.prototype.asyncRead = -function (listener, ctxt) -{ - return listener.onStartRequest (this, ctxt); -} - /* nsIRequest */ BogusChannel.prototype.isPending = function () @@ -328,6 +321,7 @@ 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 2ee95c0fae0..408794e691c 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, nsIChannel* channel, - nsISupports* ctxt, nsresult status, const PRUnichar* aMsg); + nsresult RequestDone(ImageConsumer *aConsumer, nsIRequest* request, + 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(nsIChannel* channel, nsISupports* context) { - NS_ADDREF(channel); - NS_IF_RELEASE(mChannel); - mChannel = channel; + void SetKeepPumpingData(nsIRequest* request, nsISupports* context) { + NS_ADDREF(request); + NS_IF_RELEASE(mRequest); + mRequest = request; NS_IF_ADDREF(context); NS_IF_RELEASE(mUserContext); @@ -145,7 +145,7 @@ protected: PRBool mFirstRead; char *mBuffer; PRInt32 mStatus; - nsIChannel* mChannel; + nsIRequest* mRequest; nsISupports* mUserContext; PRBool mIsMulti; }; @@ -162,7 +162,7 @@ ImageConsumer::ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext) mStream = nsnull; mBuffer = nsnull; mStatus = 0; - mChannel = nsnull; + mRequest = nsnull; mUserContext = nsnull; mIsMulti = PR_FALSE; } @@ -262,7 +262,7 @@ NS_IMETHODIMP ImageConsumer::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIChannel * aOpenedChannel, + nsIRequest * aOpenedChannel, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { @@ -294,8 +294,10 @@ ImageConsumer::DoContent(const char * aContentType, NS_IMETHODIMP -ImageConsumer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) +ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) { + nsCOMPtr channel = do_QueryInterface(aRequest); + PRUint32 httpStatus; if (mInterrupted) { mStatus = MK_INTERRUPTED; @@ -318,7 +320,7 @@ ImageConsumer::OnStartRequest(nsIChannel* channel, 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; @@ -353,13 +355,15 @@ ImageConsumer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) NS_IMETHODIMP -ImageConsumer::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, nsIInputStream *pIStream, - PRUint32 offset, PRUint32 length) +ImageConsumer::OnDataAvailable(nsIRequest* request, 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); @@ -482,12 +486,12 @@ ImageConsumer::KeepPumpingStream(nsITimer *aTimer, void *aClosure) ImageConsumer *consumer = (ImageConsumer *)aClosure; nsAutoString status; - consumer->OnStopRequest(consumer->mChannel, consumer->mUserContext, + consumer->OnStopRequest(consumer->mRequest, consumer->mUserContext, NS_BINDING_SUCCEEDED, status.GetUnicode()); } NS_IMETHODIMP -ImageConsumer::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) +ImageConsumer::OnStopRequest(nsIRequest* request, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) { if (mTimer) { mTimer->Cancel(); @@ -506,12 +510,12 @@ ImageConsumer::OnStopRequest(nsIChannel* channel, 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(channel, aContext, mStream, 0, str_length); // XXX fix offset + err = OnDataAvailable(request, 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(channel, aContext); + SetKeepPumpingData(request, aContext); nsresult rv; mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); @@ -550,7 +554,7 @@ ImageConsumer::OnStopRequest(nsIChannel* channel, nsISupports* aContext, nsresul reader->NetRequestDone(mURL, mStatus); NS_RELEASE(reader); - return mContext->RequestDone(this, channel, aContext, status, aMsg); + return mContext->RequestDone(this, request, aContext, status, aMsg); } void @@ -583,7 +587,7 @@ ImageConsumer::~ImageConsumer() if (mBuffer != nsnull) { PR_DELETE(mBuffer); } - NS_IF_RELEASE(mChannel); + NS_IF_RELEASE(mRequest); NS_IF_RELEASE(mUserContext); } @@ -708,24 +712,7 @@ ImageNetContextImpl::IsURLInDiskCache(ilIURL *aUrl) int ImageNetContextImpl::GetContentLength (ilIURL * aURL) { - nsresult rv; - int content_length=0; - - nsCOMPtr nsurl = do_QueryInterface(aURL, &rv); - if (NS_FAILED(rv)) return 0; - - - nsCOMPtr channel; - nsCOMPtr loadContext (do_QueryReferent(mLoadContext)); - nsCOMPtr group (do_GetInterface(loadContext)); - nsCOMPtr sink(do_QueryInterface(loadContext)); - - rv = NS_OpenURI(getter_AddRefs(channel), nsurl, nsnull, group, sink); - if (NS_FAILED(rv)) return 0; - - rv = channel->GetContentLength(&content_length); - return content_length; - + return -1; } @@ -785,14 +772,16 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { - // Get the defloadchannel from the loadgroup- - nsCOMPtr defLoadChannel; - if (NS_SUCCEEDED(group->GetDefaultLoadChannel( - getter_AddRefs(defLoadChannel))) && defLoadChannel) + // Get the defloadRequest from the loadgroup- + nsCOMPtr defLoadRequest; + if (NS_SUCCEEDED(group->GetDefaultLoadRequest( + getter_AddRefs(defLoadRequest))) && defLoadRequest) { + nsCOMPtr reqchannel = do_QueryInterface(defLoadRequest); + // Get the referrer from the loadchannel- nsCOMPtr referrer; - if (NS_SUCCEEDED(defLoadChannel->GetURI(getter_AddRefs(referrer)))) + if (NS_SUCCEEDED(reqchannel->GetURI(getter_AddRefs(referrer)))) { // Set the referrer- httpChannel->SetReferrer(referrer, @@ -826,7 +815,7 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, rv = pURILoader->OpenURI(channel, loadCmd, nsnull /* window target */, window); } - // rv = channel->AsyncRead(ic, nsnull); + // rv = channel->AsyncOpen(ic, nsnull); if (NS_FAILED(rv)) goto error; } @@ -851,8 +840,8 @@ ImageNetContextImpl::RemoveRequest(ImageConsumer *aConsumer) } nsresult -ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer, nsIChannel* channel, - nsISupports* ctxt, nsresult status, const PRUnichar* aMsg) +ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer, nsIRequest* request, + nsISupports* ctxt, nsresult status, const PRUnichar* aMsg) { RemoveRequest(aConsumer); /// if (mLoadGroup) @@ -879,14 +868,18 @@ 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 defLoadChannel; - if (NS_SUCCEEDED(group->GetDefaultLoadChannel( - getter_AddRefs(defLoadChannel))) && defLoadChannel) - defLoadChannel->GetLoadAttributes(&defchan_attribs); + nsCOMPtr defLoadRequest; + nsCOMPtr channel; + if (NS_SUCCEEDED(group->GetDefaultLoadRequest( + getter_AddRefs(defLoadRequest))) && defLoadRequest) + { + channel = do_QueryInterface(defLoadRequest); + if (channel) channel->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 463c0525ce3..95b588980d3 100644 --- a/mozilla/gfx/src/nsImageNetContextSync.cpp +++ b/mozilla/gfx/src/nsImageNetContextSync.cpp @@ -218,6 +218,9 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, if(aContentType){ nsCRT::free(aContentType); } + } + + if (!aContentType) { aContentType = nsCRT::strdup("unknown"); } if(nsCRT::strlen(aContentType) > 50){ @@ -226,8 +229,8 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, nsCRT::free(aContentType); aContentType = nsCRT::strdup("unknown"); } - - rv = channel->OpenInputStream(&stream); + + rv = channel->Open( &stream); NS_RELEASE(channel); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index 41be60fa94d..b425214c371 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, - nsIChannel* channel, + nsIRequest *request, nsresult aStatus) { fputs("done.\n",stdout); @@ -162,14 +162,14 @@ CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel) + nsIRequest *request) { return NS_OK; } NS_IMETHODIMP CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -178,7 +178,7 @@ CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, nsString& aMsg) { return NS_OK; @@ -186,7 +186,7 @@ CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, nsresult aStatus) { return NS_OK; diff --git a/mozilla/htmlparser/src/CParserContext.cpp b/mozilla/htmlparser/src/CParserContext.cpp index c3bbaaacf78..4bafaaf0a63 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; - mChannel=0; + mRequest=0; mValidator=0; } @@ -92,7 +92,7 @@ CParserContext::CParserContext(const CParserContext &aContext) : mMimeType() { mStreamListenerState=aContext.mStreamListenerState; mMultipart=aContext.mMultipart; mContextType=aContext.mContextType; - mChannel=aContext.mChannel; + mRequest=aContext.mRequest; mParserCommand=aContext.mParserCommand; SetMimeType(aContext.mMimeType); } diff --git a/mozilla/htmlparser/src/CParserContext.h b/mozilla/htmlparser/src/CParserContext.h index 9e282589875..e9ac2471984 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... - nsIChannel* mChannel; // provided by necko to differnciate different input streams + nsIRequest* mRequest; // 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 995604f35a2..bdcf8d22e93 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(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) +nsParser::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult result=0; if (nsnull != mProgressEventSink) { - mProgressEventSink->OnProgress(channel, aContext, aProgress, aProgressMax); + mProgressEventSink->OnProgress(request, aContext, aProgress, aProgressMax); } return result; } @@ -2079,12 +2079,12 @@ nsParser::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgr * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, +nsParser::OnStatus(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; if (nsnull != mProgressEventSink) { - rv = mProgressEventSink->OnStatus(channel, aContext, aStatus, aStatusArg); + rv = mProgressEventSink->OnStatus(request, aContext, aStatus, aStatusArg); NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } return NS_OK; @@ -2102,19 +2102,22 @@ nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, * @param * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { +nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { NS_PRECONDITION((eNone==mParserContext->mStreamListenerState),kBadListenerInit); if (nsnull != mObserver) { - mObserver->OnStartRequest(channel, aContext); + mObserver->OnStartRequest(request, aContext); } mParserContext->mStreamListenerState=eOnStart; mParserContext->mAutoDetectStatus=eUnknownDetect; - mParserContext->mChannel=channel; + mParserContext->mRequest=request; 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)) { @@ -2310,7 +2313,7 @@ ParserWriteFunc(nsIInputStream* in, * @return error code (usually 0) */ -nsresult nsParser::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, +nsresult nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext, nsIInputStream *pIStream, PRUint32 sourceOffset, PRUint32 aLength) { @@ -2322,12 +2325,12 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail CParserContext *theContext=mParserContext; while(theContext) { - if(theContext->mChannel!=channel && theContext->mPrevContext) + if(theContext->mRequest!=request && theContext->mPrevContext) theContext=theContext->mPrevContext; else break; } - if(theContext && theContext->mChannel==channel) { + if(theContext && theContext->mRequest==request) { theContext->mStreamListenerState=eOnDataAvail; @@ -2366,7 +2369,7 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail * @param * @return */ -nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, +nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) { @@ -2398,7 +2401,7 @@ nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, // XXX Should we wait to notify our observers as well if the // parser isn't yet enabled? if (nsnull != mObserver) { - mObserver->OnStopRequest(channel, aContext, status, aMsg); + mObserver->OnStopRequest(request, aContext, status, aMsg); } #ifdef rickgdebug diff --git a/mozilla/htmlparser/src/nsScanner.h b/mozilla/htmlparser/src/nsScanner.h index 0ef5a3d451f..2dfbd16de95 100644 --- a/mozilla/htmlparser/src/nsScanner.h +++ b/mozilla/htmlparser/src/nsScanner.h @@ -48,6 +48,7 @@ class nsScannerString : public nsSlidingString { nsScannerString(PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd); + virtual void UngetReadable(const nsAReadableString& aReadable, const nsReadingIterator& aCurrentPosition) { InsertReadable(aReadable,aCurrentPosition); } virtual void ReplaceCharacter(nsReadingIterator& aPosition, PRUnichar aChar); diff --git a/mozilla/htmlparser/tests/grabpage/grabpage.cpp b/mozilla/htmlparser/tests/grabpage/grabpage.cpp index 4b42cfac0d7..07a224ece41 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->AsyncRead(copier, nsnull); + rv = channel->AsyncOpen(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 30d10b2c1b2..556ac838c28 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -238,8 +238,10 @@ nsStringBundle::OnStreamComplete(nsIStreamLoader* aLoader, nsXPIDLCString uriSpec; if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr channel; - aLoader->GetChannel(getter_AddRefs(channel)); + nsCOMPtr request; + aLoader->GetRequest(getter_AddRefs(request)); + nsCOMPtr channel(do_QueryInterface(request)); + if (channel) { nsCOMPtr uri; channel->GetURI(getter_AddRefs(uri)); diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 18527d22e62..47a97d87765 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -632,13 +632,12 @@ protected: public: static nsresult - Create(nsIChannel** aResult, nsIPresShell* aPresShell); + Create(nsIRequest** 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; } @@ -647,39 +646,27 @@ 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 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 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 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;} + 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; } + }; PRInt32 DummyLayoutRequest::gRefCnt; @@ -690,15 +677,13 @@ NS_IMPL_RELEASE(DummyLayoutRequest); NS_IMPL_QUERY_INTERFACE2(DummyLayoutRequest, nsIRequest, nsIChannel); nsresult -DummyLayoutRequest::Create(nsIChannel** aResult, nsIPresShell* aPresShell) +DummyLayoutRequest::Create(nsIRequest** aResult, nsIPresShell* aPresShell) { DummyLayoutRequest* request = new DummyLayoutRequest(aPresShell); if (!request) return NS_ERROR_OUT_OF_MEMORY; - *aResult = request; - NS_ADDREF(*aResult); - return NS_OK; + return request->QueryInterface(NS_GET_IID(nsIRequest), (void**) aResult); } @@ -1063,7 +1048,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. @@ -5277,10 +5262,10 @@ PresShell::AddDummyLayoutRequest(void) } if (loadGroup) { - rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); + nsCOMPtr channel = do_QueryInterface(mDummyLayoutRequest); + rv = channel->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; - - rv = loadGroup->AddChannel(mDummyLayoutRequest, nsnull); + rv = loadGroup->AddRequest(mDummyLayoutRequest, nsnull); if (NS_FAILED(rv)) return rv; } @@ -5304,7 +5289,7 @@ PresShell::RemoveDummyLayoutRequest(void) } if (loadGroup && mDummyLayoutRequest) { - rv = loadGroup->RemoveChannel(mDummyLayoutRequest, nsnull, NS_OK, nsnull); + rv = loadGroup->RemoveRequest(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 18527d22e62..47a97d87765 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -632,13 +632,12 @@ protected: public: static nsresult - Create(nsIChannel** aResult, nsIPresShell* aPresShell); + Create(nsIRequest** 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; } @@ -647,39 +646,27 @@ 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 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 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 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;} + 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; } + }; PRInt32 DummyLayoutRequest::gRefCnt; @@ -690,15 +677,13 @@ NS_IMPL_RELEASE(DummyLayoutRequest); NS_IMPL_QUERY_INTERFACE2(DummyLayoutRequest, nsIRequest, nsIChannel); nsresult -DummyLayoutRequest::Create(nsIChannel** aResult, nsIPresShell* aPresShell) +DummyLayoutRequest::Create(nsIRequest** aResult, nsIPresShell* aPresShell) { DummyLayoutRequest* request = new DummyLayoutRequest(aPresShell); if (!request) return NS_ERROR_OUT_OF_MEMORY; - *aResult = request; - NS_ADDREF(*aResult); - return NS_OK; + return request->QueryInterface(NS_GET_IID(nsIRequest), (void**) aResult); } @@ -1063,7 +1048,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. @@ -5277,10 +5262,10 @@ PresShell::AddDummyLayoutRequest(void) } if (loadGroup) { - rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); + nsCOMPtr channel = do_QueryInterface(mDummyLayoutRequest); + rv = channel->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; - - rv = loadGroup->AddChannel(mDummyLayoutRequest, nsnull); + rv = loadGroup->AddRequest(mDummyLayoutRequest, nsnull); if (NS_FAILED(rv)) return rv; } @@ -5304,7 +5289,7 @@ PresShell::RemoveDummyLayoutRequest(void) } if (loadGroup && mDummyLayoutRequest) { - rv = loadGroup->RemoveChannel(mDummyLayoutRequest, nsnull, NS_OK, nsnull); + rv = loadGroup->RemoveRequest(mDummyLayoutRequest, nsnull, NS_OK, nsnull); if (NS_FAILED(rv)) return rv; mDummyLayoutRequest = nsnull; diff --git a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp index c179a9dc4fb..c0d5e58bb20 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, - nsIChannel * aOpenedChannel, + nsIRequest *request, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { @@ -391,7 +391,7 @@ nsAbSyncPostEngine::StillRunning(PRBool *running) // Methods for nsIStreamListener... nsresult -nsAbSyncPostEngine::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream, +nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { PRUint32 readLen = aLength; @@ -417,7 +417,7 @@ nsAbSyncPostEngine::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, n // Methods for nsIStreamObserver nsresult -nsAbSyncPostEngine::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt) +nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { if (mAuthenticationRunning) NotifyListenersOnStartAuthOperation(); @@ -427,7 +427,7 @@ nsAbSyncPostEngine::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt) } nsresult -nsAbSyncPostEngine::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) +nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) { #ifdef NS_DEBUG_rhp printf("nsAbSyncPostEngine::OnStopRequest()\n"); @@ -441,20 +441,20 @@ nsAbSyncPostEngine::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */ mStillRunning = PR_FALSE; // Check the content type! - if (aChannel) + nsCOMPtr channel = do_QueryInterface(request); + if (channel) { char *contentType = nsnull; char *charset = nsnull; - if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType) + if (NS_SUCCEEDED(channel->GetContentType(&contentType)) && contentType) { if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE)) { mContentType = contentType; } } - - nsCOMPtr httpChannel = do_QueryInterface(aChannel); + nsCOMPtr httpChannel = do_QueryInterface(channel); 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->AsyncRead(this, nsnull); + + httpChannel->AsyncOpen(this, nsnull); return NS_OK; } @@ -844,11 +844,9 @@ nsAbSyncPostEngine::CancelAbSync() { rv = mSyncMojo->CancelTheMojo(); } - else + else if (mChannel) { - nsCOMPtr httpChannel = do_QueryInterface(mChannel); - if (httpChannel) - rv = httpChannel->Cancel(NS_BINDING_ABORTED); + rv = mChannel->Cancel(NS_BINDING_ABORTED); } return rv; diff --git a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h index 43df4ca17b5..4395ea10530 100644 --- a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h +++ b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.h @@ -109,7 +109,6 @@ 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 f4d3ede8a30..fabf8d84609 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 nsIFileChannel; +interface nsITransport; typedef long nsMsgBiffState; // enumerated type for determining if a message has been replied to, forwarded, etc. @@ -349,7 +349,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); - nsIFileChannel getOfflineFileChannel(in nsMsgKey msgKey); + nsITransport getOfflineFileTransport(in nsMsgKey msgKey, out PRUint32 offset, out PRUint32 size); 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 475ee920e7a..9b86f290a96 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(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) +NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIRequest * /* request */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { nsresult rv; rv = mDestination->CopyData(aIStream, aLength); return rv; } -NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) +NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest * request, nsISupports *ctxt) { nsCOMPtr message; nsresult rv = NS_OK; @@ -154,7 +154,7 @@ NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIChannel * aChannel, return rv; } -NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIRequest* request, 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 d237878b76d..a171845b71f 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(nsIChannel* aChannel, nsISupports* aSupport) +nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport) { nsresult rv = NS_OK; if (m_fileSpec) @@ -1612,7 +1612,7 @@ nsSaveMsgListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aSupport) } NS_IMETHODIMP -nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport, +nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport, nsresult status, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -1710,7 +1710,7 @@ nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport, } NS_IMETHODIMP -nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel, +nsSaveMsgListener::OnDataAvailable(nsIRequest* request, nsISupports* aSupport, nsIInputStream* inStream, PRUint32 srcOffset, diff --git a/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp b/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp index 1a1b4328949..f9567916a1a 100644 --- a/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp +++ b/mozilla/mailnews/base/src/nsMsgFolderCompactor.cpp @@ -356,7 +356,7 @@ nsFolderCompactState::GetMessage(nsIMessage **message) NS_IMETHODIMP -nsFolderCompactState::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) +nsFolderCompactState::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsresult rv = NS_ERROR_FAILURE; NS_ASSERTION(m_fileStream, "Fatal, null m_fileStream...\n"); @@ -371,7 +371,7 @@ nsFolderCompactState::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) } NS_IMETHODIMP -nsFolderCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, +nsFolderCompactState::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { @@ -430,7 +430,7 @@ done: } NS_IMETHODIMP -nsFolderCompactState::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, +nsFolderCompactState::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { @@ -472,7 +472,7 @@ nsOfflineStoreCompactState::InitDB(nsIMsgDatabase *db) } NS_IMETHODIMP -nsOfflineStoreCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, +nsOfflineStoreCompactState::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { diff --git a/mozilla/mailnews/base/src/nsMsgFolderCompactor.h b/mozilla/mailnews/base/src/nsMsgFolderCompactor.h index 7366ffe86e5..09d75b802c5 100644 --- a/mozilla/mailnews/base/src/nsMsgFolderCompactor.h +++ b/mozilla/mailnews/base/src/nsMsgFolderCompactor.h @@ -77,7 +77,7 @@ public: virtual ~nsOfflineStoreCompactState(void); virtual nsresult InitDB(nsIMsgDatabase *db); - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIRequest *request, 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 add6c20c352..33fd24cbade 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, nsIChannel *aChannel, PRUint32 aStatus) +nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *request, PRUint32 aStatus) { // Now, fire off the print operation! nsresult rv = NS_ERROR_FAILURE; @@ -107,10 +107,12 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChan PR_FREEIF(msg); NS_ASSERTION(mDocShell,"can't print, there is no docshell"); - if ( (!mDocShell) || (!aChannel) ) + if ( (!mDocShell) || (!request) ) { 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; @@ -158,25 +160,25 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChan } NS_IMETHODIMP -nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIChannel *channel) +nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request) { return NS_OK; } NS_IMETHODIMP -nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, PRUint32 aProgress, PRUint32 aProgressMax) +nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP -nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIChannel *channel, nsString & aMsg) +nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIRequest *request, nsString & aMsg) { return NS_OK; } NS_IMETHODIMP -nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, PRUint32 aStatus) +nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aStatus) { return NS_OK; } diff --git a/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp b/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp index 5d84e3b9be1..177609aed77 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(nsIChannel* channel, nsISupports* ctxt, +NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIRequest *request, nsISupports* ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { // XXX: What should the nsIWebProgress be? - return OnProgressChange(nsnull, channel, aProgress, aProgressMax, + return OnProgressChange(nsnull, request, aProgress, aProgressMax, aProgress /* current total progress */, aProgressMax /* max total progress */); } -NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIChannel* channel, nsISupports* ctxt, +NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, 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 51d366b3951..ec0b742cc52 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, - nsIChannel *aChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) + nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { if (aContentType) { @@ -408,6 +408,9 @@ 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... @@ -419,7 +422,7 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand if (mailnewsUrl) mailnewsUrl->SetMsgWindow(this); } - return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, aChannel, aContentHandler, aAbortProcess); + return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, request, aContentHandler, aAbortProcess); } } return NS_OK; diff --git a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp index d2bcb652d5a..d0dfcfed6d4 100644 --- a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp @@ -35,6 +35,8 @@ #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 @@ -587,10 +589,12 @@ nsresult nsMsgDBFolder::GetOfflineStoreInputStream(nsIInputStream **stream) return rv; } -NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel) +NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *offset, PRUint32 *size, nsITransport **aFileChannel) { NS_ENSURE_ARG(aFileChannel); + *offset = *size = 0; + nsresult rv; rv = nsComponentManager::CreateInstance(NS_LOCALFILECHANNEL_CONTRACTID, nsnull, @@ -604,7 +608,14 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChann rv = NS_NewLocalFile(nativePath, PR_TRUE, getter_AddRefs(localStore)); if (NS_SUCCEEDED(rv) && localStore) { - rv = (*aFileChannel)->Init(localStore, PR_CREATE_FILE | PR_RDWR, 0); + 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); + if (NS_SUCCEEDED(rv)) { @@ -612,12 +623,8 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChann rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(hdr)); if (hdr && NS_SUCCEEDED(rv)) { - PRUint32 messageOffset; - PRUint32 messageSize; - hdr->GetMessageOffset(&messageOffset); - hdr->GetOfflineMessageSize(&messageSize); - (*aFileChannel)->SetTransferOffset(messageOffset); - (*aFileChannel)->SetTransferCount(messageSize); + hdr->GetMessageOffset(offset); + hdr->GetOfflineMessageSize(size); } } } @@ -637,11 +644,6 @@ 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) @@ -649,8 +651,7 @@ nsresult nsMsgDBFolder::GetOfflineStoreOutputStream(nsIOutputStream **outputStre rv = fileChannel->Init(localStore, PR_CREATE_FILE | PR_RDWR, 0); if (NS_FAILED(rv)) return rv; - fileChannel->SetTransferOffset(fileSize); - rv = fileChannel->OpenOutputStream(outputStream); + rv = fileChannel->Open(outputStream); if (NS_FAILED(rv)) return rv; } @@ -696,7 +697,6 @@ 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 7c43ceda81e..87ab859fba0 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 GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel); + NS_IMETHOD GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *offset, PRUint32 *size, nsITransport **_retval); 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 b19a0768105..134d3f2c391 100644 --- a/mozilla/mailnews/base/util/nsMsgFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgFolder.cpp @@ -2473,6 +2473,7 @@ 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 409c2bdb288..89148e7b9f3 100644 --- a/mozilla/mailnews/base/util/nsMsgProtocol.cpp +++ b/mozilla/mailnews/base/util/nsMsgProtocol.cpp @@ -28,7 +28,9 @@ #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" @@ -37,7 +39,11 @@ 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_ISUPPORTS3(nsMsgProtocol, nsIStreamListener, nsIStreamObserver, nsIChannel) +NS_IMPL_ISUPPORTS4(nsMsgProtocol, + nsIStreamListener, + nsIStreamObserver, + nsIChannel, + nsIRequest) nsMsgProtocol::nsMsgProtocol(nsIURI * aURL) { @@ -83,7 +89,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_channel)); + rv = socketService->CreateTransportOfType(connectionType, aHostName, aGetPort, nsnull, -1, 0, 0, getter_AddRefs(m_transport)); if (NS_FAILED(rv)) return rv; m_socketIsOpen = PR_FALSE; @@ -120,11 +126,28 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSp aURL->GetPath(getter_Copies(filePath)); char * urlSpec = PR_smprintf("file://%s", (const char *) filePath); - rv = netService->NewChannel(urlSpec, - nsnull, // null base URI - getter_AddRefs(m_channel)); +// 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)); PR_FREEIF(urlSpec); - m_socketIsOpen = PR_FALSE; + m_socketIsOpen = PR_FALSE; } return rv; @@ -134,9 +157,9 @@ nsresult nsMsgProtocol::SetupTransportState() { nsresult rv = NS_OK; - if (!m_socketIsOpen && m_channel) + if (!m_socketIsOpen && m_transport) { - rv = m_channel->OpenOutputStream(getter_AddRefs(m_outputStream)); + rv = m_transport->OpenOutputStream(0, -1, 0, getter_AddRefs(m_outputStream)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create an output stream"); // we want to open the stream @@ -154,10 +177,11 @@ 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_channel) { - rv = m_channel->Cancel(NS_BINDING_ABORTED); + if (m_request) { + rv = m_request->Cancel(NS_BINDING_ABORTED); } - m_channel = null_nsCOMPtr(); + m_request = 0; + m_transport = 0; return rv; } @@ -187,14 +211,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(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) +NS_IMETHODIMP nsMsgProtocol::OnDataAvailable(nsIRequest *request, 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(nsIChannel * aChannel, nsISupports *ctxt) +NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsresult rv = NS_OK; nsCOMPtr aMsgUrl = do_QueryInterface(ctxt, &rv); @@ -202,7 +226,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports * { rv = aMsgUrl->SetUrlState(PR_TRUE, NS_OK); if (m_loadGroup) - m_loadGroup->AddChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull /* context isupports */); + m_loadGroup->AddRequest(NS_STATIC_CAST(nsIRequest *, this), nsnull /* context isupports */); } // if we are set up as a channel, we should notify our channel listener that we are starting... @@ -219,7 +243,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports * } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -234,7 +258,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *c { rv = msgUrl->SetUrlState(PR_FALSE, aStatus); if (m_loadGroup) - m_loadGroup->RemoveChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull, aStatus, nsnull); + m_loadGroup->RemoveRequest(NS_STATIC_CAST(nsIRequest *, 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() @@ -312,19 +336,10 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer) if (!m_socketIsOpen) { nsCOMPtr urlSupports = do_QueryInterface(aURL); - if (m_channel) + if (m_transport) { - // 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_channel->AsyncRead(this /* stream observer */, urlSupports); + rv = m_transport->AsyncRead(this, urlSupports, m_startPosition, m_readCount, 0, getter_AddRefs(m_request)); NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed"); m_socketIsOpen = PR_TRUE; // mark the channel as open } @@ -378,19 +393,13 @@ NS_IMETHODIMP nsMsgProtocol::SetURI(nsIURI* aURI) return NS_OK; } -NS_IMETHODIMP nsMsgProtocol::OpenInputStream(nsIInputStream **_retval) +NS_IMETHODIMP nsMsgProtocol::Open(nsIInputStream **_retval) { - NS_NOTREACHED("OpenInputStream"); + NS_NOTREACHED("Open"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsMsgProtocol::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsMsgProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { // set the stream listener and then load the url m_channelContext = ctxt; @@ -417,12 +426,6 @@ NS_IMETHODIMP nsMsgProtocol::AsyncRead(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; @@ -461,6 +464,18 @@ 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) { @@ -468,83 +483,6 @@ 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; @@ -591,26 +529,10 @@ 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; @@ -619,8 +541,8 @@ NS_IMETHODIMP nsMsgProtocol::IsPending(PRBool *result) NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status) { - if (m_channel) - return m_channel->GetStatus(status); + if (m_request) + return m_request->GetStatus(status); *status = NS_ERROR_FAILURE; return *status; @@ -628,12 +550,12 @@ NS_IMETHODIMP nsMsgProtocol::GetStatus(nsresult *status) NS_IMETHODIMP nsMsgProtocol::Cancel(nsresult status) { - NS_ASSERTION(m_channel,"no channel"); - if (!m_channel) { + NS_ASSERTION(m_request,"no channel"); + if (!m_request) { return NS_ERROR_FAILURE; } - return m_channel->Cancel(status); + return m_request->Cancel(status); } NS_IMETHODIMP nsMsgProtocol::Suspend() diff --git a/mozilla/mailnews/base/util/nsMsgProtocol.h b/mozilla/mailnews/base/util/nsMsgProtocol.h index abe2ac0cf75..cce8339153e 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,7 +42,9 @@ 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); @@ -101,8 +103,10 @@ protected: virtual nsresult InitFromURI(nsIURI *aUrl); // Ouput stream for writing commands to the socket - nsCOMPtr m_channel; - nsCOMPtr m_outputStream; // this will be obtained from the transport interface + nsCOMPtr m_transport; + nsCOMPtr m_request; + + 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 4db47dc58b5..843561e32b6 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -1169,12 +1169,12 @@ QuotingOutputStreamListener::ConvertToPlainText(PRBool formatflowed /* = PR_FALS return rv; } -NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIChannel * /* aChannel */, nsISupports * /* ctxt */) +NS_IMETHODIMP QuotingOutputStreamListener::OnStartRequest(nsIRequest *request, nsISupports * /* ctxt */) { return NS_OK; } -NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */) +NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult status, const PRUnichar * /* errorMsg */) { nsresult rv = NS_OK; nsAutoString aCharset; @@ -1370,7 +1370,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel *aChannel, n return rv; } -NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIChannel * /* aChannel */, +NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIRequest *request, 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 2b054dd0593..8e92c30f8c6 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeContentHandler.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeContentHandler.cpp @@ -42,15 +42,18 @@ nsMsgComposeContentHandler::~nsMsgComposeContentHandler() } NS_IMETHODIMP nsMsgComposeContentHandler::HandleContent(const char * aContentType, const char * aCommand, - const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel) + const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request) { nsresult rv = NS_OK; - if (!aChannel) + if (!request) 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 0dddb0a4038..81c6b1cbdc2 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->AsyncRead(convertedListener, ctxt); + rv = mQuoteChannel->AsyncOpen(convertedListener, ctxt); ReleaseMessageServiceFromURI(aMsgUri, msgService); return rv; diff --git a/mozilla/mailnews/compose/src/nsMsgSendLater.cpp b/mozilla/mailnews/compose/src/nsMsgSendLater.cpp index f2252e86c35..cbd8f6c91de 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(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) +nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsresult rv; @@ -179,6 +179,9 @@ nsMsgSendLater::OnStopRequest(nsIChannel *channel, 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; @@ -260,7 +263,7 @@ nsMsgSendLater::BuildNewBuffer(const char* aBuf, PRUint32 aCount, PRUint32 *tota // Got data? nsresult -nsMsgSendLater::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) +nsMsgSendLater::OnDataAvailable(nsIRequest *request, 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 @@ -316,7 +319,7 @@ nsMsgSendLater::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInput } nsresult -nsMsgSendLater::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) +nsMsgSendLater::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsSmtpProtocol.cpp b/mozilla/mailnews/compose/src/nsSmtpProtocol.cpp index 1eae670da51..670986eccdd 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(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { nsMsgProtocol::OnStopRequest(nsnull, ctxt, aStatus, aMsg); @@ -763,7 +763,8 @@ PRInt32 nsSmtpProtocol::SendTLSResponse() { nsCOMPtr secInfo; - rv = m_channel->GetSecurityInfo(getter_AddRefs(secInfo)); + nsCOMPtr channel = do_QueryInterface(m_request); + rv = 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 0a74067c880..81ec1cde68f 100644 --- a/mozilla/mailnews/compose/src/nsSmtpProtocol.h +++ b/mozilla/mailnews/compose/src/nsSmtpProtocol.h @@ -116,7 +116,7 @@ public: //////////////////////////////////////////////////////////////////////////////////////// // stop binding is a "notification" informing us that the stream associated with aURL is going away. - NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); + NS_IMETHOD OnStopRequest(nsIRequest *request, 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 7065f478e1c..1c982b1718d 100644 --- a/mozilla/mailnews/compose/src/nsSmtpService.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpService.cpp @@ -210,9 +210,11 @@ nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer) // almost there...now create a nntp protocol instance to run the url in... smtpProtocol = new nsSmtpProtocol(aUrl); if (smtpProtocol == nsnull) - rv = NS_ERROR_OUT_OF_MEMORY; - else - rv = smtpProtocol->LoadUrl(aUrl, aConsumer); // protocol will get destroyed when url is completed... + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(smtpProtocol); + rv = smtpProtocol->LoadUrl(aUrl, aConsumer); // protocol will get destroyed when url is completed... + NS_RELEASE(smtpProtocol); } return rv; @@ -251,7 +253,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSICHANNEL NS_DECL_NSIREQUEST - + nsMailtoChannel(nsIURI * aURI); virtual ~nsMailtoChannel(); @@ -293,13 +295,6 @@ 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; @@ -324,29 +319,17 @@ NS_IMETHODIMP nsMailtoChannel::SetURI(nsIURI* aURI) return NS_OK; } -NS_IMETHODIMP nsMailtoChannel::OpenInputStream(nsIInputStream **_retval) +NS_IMETHODIMP nsMailtoChannel::Open(nsIInputStream **_retval) { - NS_NOTREACHED("OpenInputStream"); + NS_NOTREACHED("Open"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsMailtoChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsMailtoChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsMailtoChannel::AsyncOpen(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; @@ -382,83 +365,6 @@ 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"); @@ -471,13 +377,19 @@ 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 //////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsMailtoChannel::GetName(PRUnichar* *result) +/* readonly attribute wstring name; */ +NS_IMETHODIMP nsMailtoChannel::GetName(PRUnichar * *aName) { - NS_NOTREACHED("nsMailtoChannel::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } @@ -511,7 +423,6 @@ 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) @@ -869,7 +780,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 23817cd4c80..984bf09e322 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, - nsIChannel * aOpenedChannel, + nsIRequest *request, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { @@ -230,7 +230,7 @@ nsURLFetcher::StillRunning(PRBool *running) // Methods for nsIStreamListener... nsresult -nsURLFetcher::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInputStream *aIStream, +nsURLFetcher::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { PRUint32 readLen = aLength; @@ -263,13 +263,13 @@ nsURLFetcher::OnDataAvailable(nsIChannel * aChannel, nsISupports * ctxt, nsIInpu // Methods for nsIStreamObserver nsresult -nsURLFetcher::OnStartRequest(nsIChannel *aChannel, nsISupports *ctxt) +nsURLFetcher::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { return NS_OK; } nsresult -nsURLFetcher::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) +nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus, const PRUnichar* aMsg) { #ifdef NS_DEBUG_rhp printf("nsURLFetcher::OnStopRequest()\n"); @@ -294,29 +294,30 @@ nsURLFetcher::OnStopRequest(nsIChannel *aChannel, nsISupports * /* ctxt */, nsre mOutStream = nsnull; } + // Check the content type! - if (aChannel) + char *contentType = nsnull; + char *charset = nsnull; + + nsCOMPtr aChannel = do_QueryInterface(request); + if(!aChannel) return NS_ERROR_FAILURE; + + if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType) { - char *contentType = nsnull; - char *charset = nsnull; - - if (NS_SUCCEEDED(aChannel->GetContentType(&contentType)) && contentType) + if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE)) { - if (PL_strcasecmp(contentType, UNKNOWN_CONTENT_TYPE)) - { - mContentType = contentType; - } + mContentType = contentType; } + } - nsCOMPtr httpChannel = do_QueryInterface(aChannel); - if (httpChannel) + nsCOMPtr httpChannel = do_QueryInterface(aChannel); + if (httpChannel) + { + if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset) { - if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset) - { - mCharset = charset; - } + mCharset = charset; } - } + } // Now if there is a callback, we need to call it... if (mCallback) @@ -402,10 +403,7 @@ nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest, // the url.... if (NS_FAILED(aStatus)) - { - nsCOMPtr channel (do_QueryInterface(aRequest)); - OnStopRequest(channel, nsnull, aStatus, nsnull); - } + OnStopRequest(aRequest, nsnull, aStatus, nsnull); return NS_OK; } diff --git a/mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp b/mozilla/mailnews/imap/src/nsIMAPBodyShell.cpp index e5c146ef7c4..933d512eb85 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 e483c54d7d9..874ff15ffdb 100644 --- a/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp @@ -478,7 +478,10 @@ nsImapIncomingServer::LoadNextQueuedUrl(PRBool *aResult) if (NS_SUCCEEDED(aImapUrl->GetMockChannel(getter_AddRefs(mockChannel))) && mockChannel) { - mockChannel->GetStatus(&rv); + nsCOMPtr request = do_QueryInterface(mockChannel); + if (!request) + return NS_ERROR_FAILURE; + request->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 68c131dacef..80a477a7b1b 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -1038,7 +1038,7 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *msgWindow, if (empytingOnExit) { nsCOMPtr imapServer; - nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer)); + rv = GetImapIncomingServer(getter_AddRefs(imapServer)); if (NS_SUCCEEDED(rv) && imapServer) { @@ -3649,18 +3649,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(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) +NS_IMETHODIMP nsImapMailFolder::OnDataAvailable(nsIRequest * /* request */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { nsresult rv = NS_OK; return rv; } -NS_IMETHODIMP nsImapMailFolder::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) +NS_IMETHODIMP nsImapMailFolder::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { return NS_OK; } -NS_IMETHODIMP nsImapMailFolder::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsImapMailFolder::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) { return NS_OK; } @@ -4212,7 +4212,9 @@ nsresult nsImapMailFolder::DisplayStatusMsg(nsIImapUrl *aImapUrl, const PRUnicha mockChannel->GetProgressEventSink(getter_AddRefs(progressSink)); if (progressSink) { - progressSink->OnStatus(mockChannel, nsnull, NS_OK, msg); // XXX i18n message + nsCOMPtr request = do_QueryInterface(mockChannel); + if (!request) return NS_ERROR_FAILURE; + progressSink->OnStatus(request, nsnull, NS_OK, msg); // XXX i18n message } } return NS_OK; @@ -4275,9 +4277,12 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol, mockChannel->GetProgressEventSink(getter_AddRefs(progressSink)); if (progressSink) { - progressSink->OnProgress(mockChannel, nsnull, aInfo->currentProgress, aInfo->maxProgress); + nsCOMPtr request = do_QueryInterface(mockChannel); + if (!request) return NS_ERROR_FAILURE; + + progressSink->OnProgress(request, nsnull, aInfo->currentProgress, aInfo->maxProgress); if (aInfo->message) - progressSink->OnStatus(mockChannel, nsnull, NS_OK, aInfo->message); // XXX i18n message + progressSink->OnStatus(request, 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 1a272313af7..2cfadd46a21 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(getter_AddRefs(m_outputStream)); + rv = m_channel->OpenOutputStream(0, -1, 0, getter_AddRefs(m_outputStream)); } } // if m_runningUrl @@ -616,7 +616,12 @@ 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)); - m_channel->SetNotificationCallbacks(callbacks); + if (callbacks) { + nsCOMPtr progressSink; + (void)callbacks->GetInterface(NS_GET_IID(nsIProgressEventSink), + getter_AddRefs(progressSink)); + m_channel->SetProgressEventSink(progressSink); + } // 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. @@ -1004,7 +1009,8 @@ PRBool nsImapProtocol::ProcessCurrentURL() if (!TestFlag(IMAP_CONNECTION_IS_OPEN) && m_channel) { - m_channel->AsyncRead(this /* stream observer */, nsnull); + nsCOMPtr request; + m_channel->AsyncRead(this /* stream observer */, nsnull, 0,-1,0, getter_AddRefs(request)); SetFlag(IMAP_CONNECTION_IS_OPEN); } #ifdef DEBUG_bienvenu @@ -1036,9 +1042,10 @@ 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) - m_channelListener->OnStartRequest(m_mockChannel, m_channelContext); - + if (m_channelListener) { + nsCOMPtr request = do_QueryInterface(m_mockChannel); + m_channelListener->OnStartRequest(request, 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 @@ -1123,9 +1130,13 @@ 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) - rv = m_channelListener->OnStopRequest(m_mockChannel, m_channelContext, NS_OK, nsnull); + if (m_channelListener) + { + nsCOMPtr request = do_QueryInterface(m_mockChannel); + if (!request) return NS_ERROR_FAILURE; + 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() @@ -1189,7 +1200,7 @@ void nsImapProtocol::ParseIMAPandCheckForNewMail(const char* commandString, PRBo ///////////////////////////////////////////////////////////////////////////////////////////// // we suppport the nsIStreamListener interface //////////////////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) +NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { nsresult res = NS_OK; @@ -1213,7 +1224,7 @@ NS_IMETHODIMP nsImapProtocol::OnDataAvailable(nsIChannel * /* aChannel */, nsISu return res; } -NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt) +NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIRequest *request, 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 @@ -1230,7 +1241,7 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISup } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aMsg) { PRBool killThread = PR_FALSE; @@ -2809,8 +2820,11 @@ nsImapProtocol::PostLineDownLoadEvent(msg_line_info *downloadLineDontDelete) { nsresult rv = m_channelOutputStream->Write(line, PL_strlen(line), &count); if (NS_SUCCEEDED(rv)) - 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 + { + 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 } if (m_imapMessageSink) m_imapMessageSink->GetNotifyDownloadedLines(&echoLineToMessageSink); @@ -3509,8 +3523,11 @@ 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) - m_mockChannel->GetStatus(&returnValue); - + { + nsCOMPtr request = do_QueryInterface(m_mockChannel); + if (request) + request->GetStatus(&returnValue); + } if (NS_SUCCEEDED(returnValue)) // check the other way of cancelling. { PR_EnterMonitor(m_threadDeathMonitor); @@ -6709,23 +6726,25 @@ nsresult nsImapCacheStreamListener::Init(nsIStreamListener * aStreamListener, ns } NS_IMETHODIMP -nsImapCacheStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) +nsImapCacheStreamListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) { nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr ourRequest = do_QueryInterface(mChannelToUse); if (loadGroup) - loadGroup->AddChannel(mChannelToUse, nsnull /* context isupports */); - return mListener->OnStartRequest(mChannelToUse, aCtxt); + loadGroup->AddRequest(ourRequest, nsnull /* context isupports */); + return mListener->OnStartRequest(ourRequest, aCtxt); } NS_IMETHODIMP -nsImapCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) +nsImapCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = mListener->OnStopRequest(mChannelToUse, aCtxt, aStatus, aMsg); + nsCOMPtr ourRequest = do_QueryInterface(mChannelToUse); + nsresult rv = mListener->OnStopRequest(ourRequest, aCtxt, aStatus, aMsg); nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->RemoveChannel(mChannelToUse, nsnull, aStatus, nsnull); + loadGroup->RemoveRequest(ourRequest, nsnull, aStatus, nsnull); mListener = nsnull; mChannelToUse = nsnull; @@ -6733,9 +6752,10 @@ nsImapCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aC } NS_IMETHODIMP -nsImapCacheStreamListener::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) +nsImapCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) { - return mListener->OnDataAvailable(mChannelToUse, aCtxt, aInStream, aSourceOffset, aCount); + nsCOMPtr ourRequest = do_QueryInterface(mChannelToUse); + return mListener->OnDataAvailable(ourRequest, aCtxt, aInStream, aSourceOffset, aCount); } NS_IMPL_THREADSAFE_ADDREF(nsImapMockChannel) @@ -6767,12 +6787,6 @@ 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; @@ -6855,19 +6869,13 @@ NS_IMETHODIMP nsImapMockChannel::SetURI(nsIURI* aURI) return NS_OK; } -NS_IMETHODIMP nsImapMockChannel::OpenInputStream(nsIInputStream **_retval) +NS_IMETHODIMP nsImapMockChannel::Open(nsIInputStream **_retval) { - NS_NOTREACHED("nsImapMockChannel::OpenInputStream"); + NS_NOTREACHED("nsImapMockChannel::Open"); return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsImapMockChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("nsImapMockChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { nsCOMPtr cacheEntry; PRUint32 contentLength = 0; @@ -6943,7 +6951,7 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo nsImapCacheStreamListener * cacheListener = new nsImapCacheStreamListener(); NS_ADDREF(cacheListener); cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this)); - rv = cacheChannel->AsyncRead(cacheListener, m_channelContext); + rv = cacheChannel->AsyncOpen(cacheListener, m_channelContext); NS_RELEASE(cacheListener); if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return @@ -6960,7 +6968,6 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo nsCOMPtr securityInfo; cacheEntry->GetSecurityInfo(getter_AddRefs(securityInfo)); SetSecurityInfo(securityInfo); - return rv; } } @@ -6979,14 +6986,17 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(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); - rv = folder->GetOfflineFileChannel(msgKey, getter_AddRefs(fileChannel)); + PRUint32 size, offset; + rv = folder->GetOfflineFileTransport(msgKey, &offset, &size, 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)) { - fileChannel->SetLoadGroup(m_loadGroup); + // dougt - This may break the ablity to "cancel" a read from offline mail reading. + // 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); @@ -6995,7 +7005,8 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISuppo nsImapCacheStreamListener * cacheListener = new nsImapCacheStreamListener(); NS_ADDREF(cacheListener); cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this)); - rv = fileChannel->AsyncRead(cacheListener, m_channelContext); + nsCOMPtr request; + rv = fileChannel->AsyncRead(cacheListener, m_channelContext, offset, size, 0, getter_AddRefs(request)); NS_RELEASE(cacheListener); if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return @@ -7031,12 +7042,6 @@ NS_IMETHODIMP nsImapMockChannel::AsyncRead(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; @@ -7078,83 +7083,6 @@ 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; @@ -7168,13 +7096,22 @@ 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; } @@ -7234,10 +7171,3 @@ 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 31c54261f94..fd490484520 100644 --- a/mozilla/mailnews/imap/src/nsImapProtocol.h +++ b/mozilla/mailnews/imap/src/nsImapProtocol.h @@ -35,6 +35,7 @@ #include "nsString.h" #include "nsIProgressEventSink.h" #include "nsIInterfaceRequestor.h" +#include "nsITransport.h" // imap event sinks #include "nsIImapMailFolderSink.h" @@ -315,7 +316,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 1137a01cc22..10c40f40cbd 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->AsyncRead(aStreamListener, aCtxt); + // now try to open the channel passing in our display consumer as the listener + rv = aChannel->AsyncOpen(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->AsyncRead(aStreamListener, aCtxt); + rv = aChannel->AsyncOpen(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 42658b31dd6..04a29bc2863 100644 --- a/mozilla/mailnews/imap/src/nsImapUrl.cpp +++ b/mozilla/mailnews/imap/src/nsImapUrl.cpp @@ -1132,7 +1132,8 @@ NS_IMETHODIMP nsImapUrl::AddChannelToLoadGroup() if (loadGroup) { - loadGroup->AddChannel(m_mockChannel, nsnull /* context isupports */); + nsCOMPtr request = do_QueryInterface(m_mockChannel); + loadGroup->AddRequest(request, nsnull /* context isupports */); } } return NS_OK; @@ -1150,7 +1151,8 @@ NS_IMETHODIMP nsImapUrl::RemoveChannel(nsresult status) GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) { - loadGroup->RemoveChannel(m_mockChannel, nsnull, status, nsnull); + nsCOMPtr request = do_QueryInterface(m_mockChannel); + loadGroup->RemoveRequest(request, 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 16f0b922836..2ddb2af3415 100644 --- a/mozilla/mailnews/local/src/nsMailboxProtocol.cpp +++ b/mozilla/mailnews/local/src/nsMailboxProtocol.cpp @@ -82,11 +82,13 @@ 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_channel) - return m_channel->GetContentLength(aContentLength); - else + if (!m_request) return NS_OK; + nsCOMPtr info = do_QueryInterface(m_request); + if (info) info->GetContentLength(aContentLength); + return NS_OK; + } else if (m_runningUrl) { @@ -144,7 +146,7 @@ void nsMailboxProtocol::Initialize(nsIURI * aURL) // we suppport the nsIStreamListener interface //////////////////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) +NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIRequest *request, 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 @@ -152,19 +154,19 @@ NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIChannel * aChannel, nsISuppor if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser) { // we need to inform our mailbox parser that it's time to start... - m_mailboxParser->OnStartRequest(aChannel, ctxt); + m_mailboxParser->OnStartRequest(request, ctxt); } - return nsMsgProtocol::OnStartRequest(aChannel, ctxt); + return nsMsgProtocol::OnStartRequest(request, ctxt); } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, 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(aChannel, ctxt, aStatus, nsnull); + m_mailboxParser->OnStopRequest(request, ctxt, aStatus, nsnull); } else if (m_nextState == MAILBOX_READ_MESSAGE) { @@ -196,7 +198,7 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIChannel * aChannel, nsISupport */ if (aStatus == NS_BINDING_ABORTED) aStatus = NS_OK; - nsMsgProtocol::OnStopRequest(aChannel, ctxt, aStatus, aMsg); + nsMsgProtocol::OnStopRequest(request, ctxt, aStatus, aMsg); return CloseSocket(); } @@ -479,8 +481,8 @@ nsresult nsMailboxProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * case MAILBOX_DONE: case MAILBOX_ERROR_DONE: { - nsCOMPtr url = do_QueryInterface(m_runningUrl); - url->SetUrlState(PR_FALSE, m_nextState == MAILBOX_DONE ? + nsCOMPtr anotherUrl = do_QueryInterface(m_runningUrl); + anotherUrl->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 236682848c0..18e1bc35cf2 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(nsIChannel * aChannel, nsISupports *ctxt); - NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg); + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt); + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg); NS_IMETHOD GetContentLength(PRInt32 * aContentLength); private: @@ -127,3 +127,9 @@ private: }; #endif // nsMailboxProtocol_h___ + + + + + + diff --git a/mozilla/mailnews/local/src/nsParseMailbox.cpp b/mozilla/mailnews/local/src/nsParseMailbox.cpp index 72dd2a56fc5..9b5d9d173b6 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(nsIChannel * /* aChannel */, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, +NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIRequest *request, 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(nsIChannel * /* aChannel */, n return rv; } -NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt) +NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsTime currentTime; m_startTime = currentTime; @@ -143,7 +143,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, ns } // stop binding is a "notification" informing us that the stream associated with aURL is going away. -NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIChannel * /* aChannel */, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aMsg) +NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIRequest *request, 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/nsPop3IncomingServer.cpp b/mozilla/mailnews/local/src/nsPop3IncomingServer.cpp index eb3787655a8..accc1ee28dd 100644 --- a/mozilla/mailnews/local/src/nsPop3IncomingServer.cpp +++ b/mozilla/mailnews/local/src/nsPop3IncomingServer.cpp @@ -286,7 +286,7 @@ NS_IMETHODIMP nsPop3IncomingServer::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlL { nsresult rv; - NS_WITH_SERVICE(nsIPop3Service, pop3Service, kCPop3ServiceCID, &rv); + nsCOMPtr pop3Service = do_GetService(kCPop3ServiceCID, &rv); NS_ENSURE_SUCCESS(rv,rv); rv = pop3Service->GetNewMail(aMsgWindow, aUrlListener, inbox, this, aResult); diff --git a/mozilla/mailnews/local/src/nsPop3Protocol.cpp b/mozilla/mailnews/local/src/nsPop3Protocol.cpp index c68b9afa4a6..e60d1d7ba4e 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(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = nsMsgProtocol::OnStopRequest(aChannel, aContext, aStatus, aMsg); + nsresult rv = nsMsgProtocol::OnStopRequest(request, 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 016b7f0b91b..06805c280b5 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(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD OnStopRequest(nsIRequest *request, 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/local/src/nsPop3Service.cpp b/mozilla/mailnews/local/src/nsPop3Service.cpp index 4c41bc59ef7..3f94d4ec730 100644 --- a/mozilla/mailnews/local/src/nsPop3Service.cpp +++ b/mozilla/mailnews/local/src/nsPop3Service.cpp @@ -276,6 +276,7 @@ nsresult nsPop3Service::RunPopUrl(nsIMsgIncomingServer * aServer, nsIURI * aUrlT nsPop3Protocol * protocol = new nsPop3Protocol(aUrlToRun); if (protocol) { + NS_ADDREF(protocol); rv = protocol->Initialize(aUrlToRun); if(NS_FAILED(rv)) { @@ -285,6 +286,7 @@ nsresult nsPop3Service::RunPopUrl(nsIMsgIncomingServer * aServer, nsIURI * aUrlT // the protocol stores the unescaped username, so there is no need to escape it. protocol->SetUsername(userName); rv = protocol->LoadUrl(aUrlToRun); + NS_RELEASE(protocol); } } } // if server diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp index 11c36d75e27..0dfc3fe100c 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp @@ -268,7 +268,10 @@ NS_IMETHODIMP nsMimeBaseEmitter::OnFull(nsIOutputStream* out) PRUint32 bytesAvailable = 0; rv = mInputStream->Available(&bytesAvailable); NS_ASSERTION(NS_SUCCEEDED(rv), "Available failed"); - rv = mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, bytesAvailable); + + nsCOMPtr request = do_QueryInterface(mChannel); + rv = mOutListener->OnDataAvailable(request, mURL, mInputStream, 0, bytesAvailable); + } else rv = NS_ERROR_NULL_POINTER; @@ -283,7 +286,7 @@ NS_IMETHODIMP nsMimeBaseEmitter::OnClose(nsIInputStream* in) /////////////////////////////////////////////////////////////////////////// // nsMimeBaseEmitter Interface -/////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsMimeBaseEmitter::SetPipe(nsIInputStream * aInputStream, nsIOutputStream *outStream) { @@ -862,7 +865,8 @@ nsMimeBaseEmitter::Complete() PRUint32 bytesInStream; nsresult rv2 = mInputStream->Available(&bytesInStream); NS_ASSERTION(NS_SUCCEEDED(rv2), "Available failed"); - rv2 = mOutListener->OnDataAvailable(mChannel, mURL, mInputStream, 0, bytesInStream); + nsCOMPtr request = do_QueryInterface(mChannel); + rv2 = mOutListener->OnDataAvailable(request, 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 29ba3f8d342..a24cb06bf9e 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 85b6980164c..f5bda080f36 100644 --- a/mozilla/mailnews/mime/src/mimemoz2.cpp +++ b/mozilla/mailnews/mime/src/mimemoz2.cpp @@ -59,7 +59,6 @@ #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 43f3e59a533..334df5c7020 100644 --- a/mozilla/mailnews/mime/src/nsStreamConverter.cpp +++ b/mozilla/mailnews/mime/src/nsStreamConverter.cpp @@ -49,6 +49,7 @@ #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" @@ -610,6 +611,7 @@ 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); @@ -816,7 +818,7 @@ nsStreamConverter::SetIdentity(nsIMsgIdentity * aIdentity) // networking library... // nsresult -nsStreamConverter::OnDataAvailable(nsIChannel * /* aChannel */, nsISupports *ctxt, +nsStreamConverter::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) @@ -887,7 +889,7 @@ char *output = "\ // called only once, at the beginning of a URL load. // nsresult -nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) +nsStreamConverter::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { #ifdef DEBUG_rhp printf("nsStreamConverter::OnStartRequest()\n"); @@ -900,25 +902,21 @@ nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) // here's a little bit of hackery.... // since the mime converter is now between the channel // and the - nsresult rv = NS_OK; - if (aChannel) + if (request) { - nsXPIDLCString contentType; - GetContentType(getter_Copies(contentType)); - aChannel->SetContentType(contentType); + nsCOMPtr channel = do_QueryInterface(request); + if (channel) + { + nsXPIDLCString contentType; + GetContentType(getter_Copies(contentType)); + + channel->SetContentType(contentType); + } } - // forward the start request to any listeners + // forward the start rquest to any listeners if (mOutListener) - 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); - + mOutListener->OnStartRequest(request, ctxt); return NS_OK; } @@ -927,7 +925,7 @@ nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt) // called once when the networking library has finished processing the // nsresult -nsStreamConverter::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) +nsStreamConverter::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { #ifdef DEBUG_rhp printf("nsStreamConverter::OnStopRequest()\n"); @@ -1006,7 +1004,7 @@ nsStreamConverter::OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsres // forward on top request to any listeners if (mOutListener) - mOutListener->OnStopRequest(/* mOutgoingChannel */ aChannel, ctxt, status, errorMsg); + mOutListener->OnStopRequest(request, ctxt, status, errorMsg); mAlreadyKnowOutputType = PR_FALSE; @@ -1070,7 +1068,6 @@ 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 e842d08f674..25eb6528a82 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 * aChannelToUse, nsIMsgMailNewsUrl *aRunningUrl); + nsresult Init(nsIStreamListener * aStreamListener, nsIChannel* channel, nsIMsgMailNewsUrl *aRunningUrl); protected: - nsCOMPtr mChannelToUse; + nsCOMPtr mChannelToUse; nsCOMPtr mListener; nsCOMPtr mRunningUrl; }; @@ -718,36 +718,37 @@ nsNntpCacheStreamListener::nsNntpCacheStreamListener() nsNntpCacheStreamListener::~nsNntpCacheStreamListener() {} -nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel * aChannelToUse, +nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel* channel, nsIMsgMailNewsUrl *aRunningUrl) { NS_ENSURE_ARG(aStreamListener); - NS_ENSURE_ARG(aChannelToUse); + NS_ENSURE_ARG(channel); + + mChannelToUse = channel; - mChannelToUse = aChannelToUse; mListener = aStreamListener; mRunningUrl = aRunningUrl; return NS_OK; } NS_IMETHODIMP -nsNntpCacheStreamListener::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) +nsNntpCacheStreamListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) { nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->AddChannel(mChannelToUse, nsnull /* context isupports */); - return mListener->OnStartRequest(mChannelToUse, aCtxt); + loadGroup->AddRequest(request, nsnull /* context isupports */); + return mListener->OnStartRequest(request, aCtxt); } NS_IMETHODIMP -nsNntpCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) +nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg) { - nsresult rv = mListener->OnStopRequest(mChannelToUse, aCtxt, aStatus, aMsg); + nsresult rv = mListener->OnStopRequest(request, aCtxt, aStatus, aMsg); nsCOMPtr loadGroup; mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) - loadGroup->RemoveChannel(mChannelToUse, nsnull, aStatus, nsnull); + loadGroup->RemoveRequest(request, nsnull, aStatus, nsnull); // clear out mem cache entry so we're not holding onto it. if (mRunningUrl) @@ -759,13 +760,13 @@ nsNntpCacheStreamListener::OnStopRequest(nsIChannel * aChannel, nsISupports * aC } NS_IMETHODIMP -nsNntpCacheStreamListener::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) +nsNntpCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, PRUint32 aSourceOffset, PRUint32 aCount) { - return mListener->OnDataAvailable(mChannelToUse, aCtxt, aInStream, aSourceOffset, aCount); + return mListener->OnDataAvailable(request, aCtxt, aInStream, aSourceOffset, aCount); } -NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; nsCOMPtr mailnewsUrl = do_QueryInterface(m_runningURL, &rv); @@ -793,18 +794,22 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(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; - rv = folder->GetOfflineFileChannel(key, getter_AddRefs(fileChannel)); + nsCOMPtr fileChannel; + PRUint32 offset=0, size=0; + rv = folder->GetOfflineFileTransport(key, &offset, &size, 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)) { - fileChannel->SetLoadGroup(m_loadGroup); + // dougt - This may break the ablity to "cancel" a read from offline mail reading. + // 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); - rv = fileChannel->AsyncRead(cacheListener, m_channelContext); + nsCOMPtr request; + rv = fileChannel->AsyncRead(cacheListener, m_channelContext, offset, size, 0, getter_AddRefs(request)); NS_RELEASE(cacheListener); MarkCurrentMsgRead(); @@ -840,10 +845,11 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports { // we're going to fill up this cache entry, // do we have a listener here? - nsIStreamListener *listener = m_channelListener; - rv = cacheEntry->InterceptAsyncRead(listener, 0, getter_AddRefs(m_channelListener)); + nsIStreamListener *anotherListener = m_channelListener; + rv = cacheEntry->InterceptAsyncRead(anotherListener, 0, getter_AddRefs(m_channelListener)); + nsCOMPtr request; if (NS_SUCCEEDED(rv)) - return nsMsgProtocol::AsyncRead(m_channelListener, ctxt); + return nsMsgProtocol::AsyncOpen(m_channelListener, ctxt); } } } @@ -860,7 +866,8 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports SetLoadGroup(m_loadGroup); m_typeWanted = ARTICLE_WANTED; cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this), mailnewsUrl); - rv = cacheChannel->AsyncRead(cacheListener, m_channelContext); + nsCOMPtr request; + rv = cacheChannel->AsyncOpen(cacheListener, m_channelContext); NS_RELEASE(cacheListener); MarkCurrentMsgRead(); @@ -875,7 +882,8 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports } } - return nsMsgProtocol::AsyncRead(listener, ctxt); + nsCOMPtr parentRequest; + return nsMsgProtocol::AsyncOpen(listener, ctxt); } nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer) @@ -1211,9 +1219,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(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) +NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg) { - nsMsgProtocol::OnStopRequest(aChannel, aContext, aStatus, aMsg); + nsMsgProtocol::OnStopRequest(request, aContext, aStatus, aMsg); // nsMsgProtocol::OnStopRequest() has called m_channelListener. There is // no need to be called again in CloseSocket(). Let's clear it here. @@ -5409,7 +5417,7 @@ nsresult nsNNTPProtocol::CleanupAfterRunningUrl() rv = m_channelListener->OnStopRequest(this, m_channelContext, NS_OK, nsnull); if (m_loadGroup) - m_loadGroup->RemoveChannel(NS_STATIC_CAST(nsIChannel *, this), nsnull, NS_OK, nsnull); + m_loadGroup->RemoveRequest(NS_STATIC_CAST(nsIRequest *, 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 87ca654f68f..03611f042cf 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(nsIChannel * aChannel, nsISupports * aCtxt, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD OnStopRequest(nsIRequest *request, 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 AsyncRead(nsIStreamListener *listener, nsISupports *ctxt); + NS_IMETHOD AsyncOpen(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 83a241c7d7a..4aa7bbbcd01 100644 --- a/mozilla/mailnews/news/src/nsNntpService.cpp +++ b/mozilla/mailnews/news/src/nsNntpService.cpp @@ -1610,9 +1610,12 @@ NS_IMETHODIMP nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask) NS_IMETHODIMP -nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel) +nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request) { 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 5ef89b162d8..9ae0ba2b1e1 100644 --- a/mozilla/modules/libjar/nsJARChannel.cpp +++ b/mozilla/modules/libjar/nsJARChannel.cpp @@ -31,6 +31,7 @@ #include "nsMimeTypes.h" #include "nsScriptSecurityManager.h" #include "nsIAggregatePrincipal.h" +#include "nsIProgressEventSink.h" #include "nsXPIDLString.h" static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); @@ -60,13 +61,9 @@ 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) { @@ -174,9 +171,9 @@ nsJARChannel::Cancel(nsresult status) if (mJarExtractionTransport) { rv = mJarExtractionTransport->Cancel(status); - if (NS_FAILED(rv)) return rv; mJarExtractionTransport = nsnull; } + mStatus = status; return rv; } @@ -184,29 +181,27 @@ nsJARChannel::Cancel(nsresult status) NS_IMETHODIMP nsJARChannel::Suspend() { - nsresult rv; + nsresult rv = NS_OK; nsAutoMonitor monitor(mMonitor); if (mJarExtractionTransport) { rv = mJarExtractionTransport->Suspend(); - if (NS_FAILED(rv)) return rv; } - return NS_OK; + return rv; } NS_IMETHODIMP nsJARChannel::Resume() { - nsresult rv; + nsresult rv = NS_OK; nsAutoMonitor monitor(mMonitor); if (mJarExtractionTransport) { rv = mJarExtractionTransport->Resume(); - if (NS_FAILED(rv)) return rv; } - return NS_OK; + return rv; } //////////////////////////////////////////////////////////////////////////////// @@ -255,12 +250,12 @@ nsJARChannel::OpenJARElement() rv = Open(nsnull, nsnull); if (NS_SUCCEEDED(rv)) rv = GetInputStream(getter_AddRefs(mSynchronousInputStream)); - mon.Notify(); // wake up OpenInputStream + mon.Notify(); // wake up nsIChannel::Open return rv; } NS_IMETHODIMP -nsJARChannel::OpenInputStream(nsIInputStream* *result) +nsJARChannel::Open(nsIInputStream* *result) { nsAutoCMonitor mon(this); nsresult rv; @@ -273,7 +268,7 @@ nsJARChannel::OpenInputStream(nsIInputStream* *result) { *result = mSynchronousInputStream; // Result of GetInputStream called on transport thread NS_ADDREF(*result); - mSynchronousInputStream = null_nsCOMPtr(); + mSynchronousInputStream = 0; return NS_OK; } else @@ -281,14 +276,7 @@ nsJARChannel::OpenInputStream(nsIInputStream* *result) } NS_IMETHODIMP -nsJARChannel::OpenOutputStream(nsIOutputStream* *result) -{ - NS_NOTREACHED("nsJARChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsJARChannel::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) +nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt) { nsresult rv; mUserContext = ctxt; @@ -310,7 +298,7 @@ nsJARChannel::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) } } } - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -342,7 +330,7 @@ nsJARChannel::EnsureJARFileAvailable() rv = NS_NewDownloader(getter_AddRefs(mDownloader), mJARBaseURI, this, nsnull, mSynchronousRead, mLoadGroup, mCallbacks, - mLoadAttributes, mBufferSegmentSize, mBufferMaxSize); + mLoadAttributes); // if DownloadComplete() was called early, need to release the reference. if (mSynchronousRead && mSynchronousInputStream) @@ -350,7 +338,7 @@ nsJARChannel::EnsureJARFileAvailable() error: if (NS_FAILED(rv) && mLoadGroup) { - nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); + nsresult rv2 = mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } return rv; @@ -366,20 +354,18 @@ nsJARChannel::AsyncReadJARElement() NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - 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); + nsCOMPtr jarTransport; + rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport)); if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) { + // don't think that this is not needed anymore + // jarTransport->SetProgressEventSink(sink); + } + } + #ifdef PR_LOGGING nsXPIDLCString jarURLStr; mURI->GetSpec(getter_Copies(jarURLStr)); @@ -387,18 +373,12 @@ nsJARChannel::AsyncReadJARElement() ("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr)); #endif - rv = mJarExtractionTransport->AsyncRead(this, nsnull); + rv = jarTransport->AsyncRead(this, nsnull, 0, -1, 0, getter_AddRefs(mJarExtractionTransport)); + mJarExtractionTransport = 0; + jarTransport = 0; 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) { @@ -491,83 +471,6 @@ 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) { @@ -667,7 +570,7 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu else rv = AsyncReadJARElement(); } - mDownloader = null_nsCOMPtr(); + mDownloader = 0; return rv; } @@ -675,14 +578,14 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu // nsIStreamObserver methods: NS_IMETHODIMP -nsJARChannel::OnStartRequest(nsIChannel* jarExtractionTransport, +nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport, nsISupports* context) { return mUserListener->OnStartRequest(this, mUserContext); } NS_IMETHODIMP -nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* context, +nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -698,12 +601,10 @@ nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* con #endif rv = mUserListener->OnStopRequest(this, mUserContext, aStatus, aStatusArg); + NS_ASSERTION(NS_SUCCEEDED(rv), "OnStopRequest failed"); - if (mLoadGroup) { - if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); - } - } + if (mLoadGroup) + mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); mUserListener = nsnull; mUserContext = nsnull; @@ -715,7 +616,7 @@ nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* con // nsIStreamListener methods: NS_IMETHODIMP -nsJARChannel::OnDataAvailable(nsIChannel* jarCacheTransport, +nsJARChannel::OnDataAvailable(nsIRequest* jarCacheTransport, nsISupports* context, nsIInputStream *inStr, PRUint32 sourceOffset, diff --git a/mozilla/modules/libjar/nsJARChannel.h b/mozilla/modules/libjar/nsJARChannel.h index 9bfdf71c3c4..e8d08e93c06 100644 --- a/mozilla/modules/libjar/nsJARChannel.h +++ b/mozilla/modules/libjar/nsJARChannel.h @@ -89,8 +89,6 @@ protected: nsLoadFlags mLoadAttributes; nsCOMPtr mOwner; - PRUint32 mStartPosition; - PRInt32 mReadCount; nsCOMPtr mUserContext; nsCOMPtr mUserListener; @@ -100,15 +98,13 @@ 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 c3c6ff579f4..21d5213a01d 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -965,7 +965,7 @@ public: private: nsresult SetUpCache(nsIURI* aURL); - nsresult SetUpStreamListener(nsIChannel *channel, nsIURI* aURL); + nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL); nsIURI *mURL; nsIPluginInstanceOwner *mOwner; @@ -1026,13 +1026,13 @@ nsPluginCacheListener::~nsPluginCacheListener() NS_IMPL_ISUPPORTS(nsPluginCacheListener, kIStreamListenerIID); NS_IMETHODIMP -nsPluginCacheListener::OnStartRequest(nsIChannel* channel, nsISupports* ctxt) +nsPluginCacheListener::OnStartRequest(nsIRequest *request, nsISupports* ctxt) { return NS_OK; } NS_IMETHODIMP -nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt, +nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt, nsIInputStream* aIStream, PRUint32 sourceOffset, PRUint32 aLength) @@ -1055,7 +1055,7 @@ nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt, } NS_IMETHODIMP -nsPluginCacheListener::OnStopRequest(nsIChannel* channel, +nsPluginCacheListener::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) @@ -1223,10 +1223,15 @@ nsresult nsPluginStreamListenerPeer::InitializeFullPage(nsIPluginInstance *aInst NS_IMETHODIMP -nsPluginStreamListenerPeer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) +nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, 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; @@ -1299,14 +1304,14 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIChannel* channel, nsISupports* aCo } - rv = SetUpStreamListener(channel, aURL); + rv = SetUpStreamListener(request, aURL); if (NS_FAILED(rv)) return rv; return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) @@ -1315,7 +1320,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) @@ -1323,7 +1328,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, return NS_OK; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, nsISupports* aContext, nsIInputStream *aIStream, PRUint32 sourceOffset, @@ -1331,6 +1336,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, { 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; @@ -1352,7 +1360,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, // if a plugin returns an error, the peer must kill the stream // else the stream and PluginStreamListener leak if (NS_FAILED(rv)) - channel->Cancel(rv); + request->Cancel(rv); } else { @@ -1365,13 +1373,15 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, 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; @@ -1379,7 +1389,11 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel, { char* urlString; nsCOMPtr localFile; - rv = channel->GetLocalFile(getter_AddRefs(localFile)); + nsCOMPtr fileChannel = do_QueryInterface(channel); + + if (fileChannel) + rv = fileChannel->GetFile(getter_AddRefs(localFile)); + if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; @@ -1434,7 +1448,7 @@ nsresult nsPluginStreamListenerPeer::SetUpCache(nsIURI* aURL) return NS_OpenURI(cacheListener, nsnull, aURL, nsnull); } -nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, +nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, nsIURI* aURL) { nsresult rv = NS_OK; @@ -1466,6 +1480,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, nsCOMPtr headerListener = do_QueryInterface(mPStreamListener); if (headerListener) { + + nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener); @@ -1477,6 +1493,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, 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; @@ -3826,8 +3844,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, } } - - rv = channel->AsyncRead(listenerPeer, nsnull); + rv = channel->AsyncOpen(listenerPeer, nsnull); } NS_RELEASE(listenerPeer); diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index 3c84ff6194d..41f13125d9b 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -37,6 +37,7 @@ 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 48f61986459..e4bc9ddd236 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(nsIPluginHost* aHost, const nsRect& aBounds, + nsresult CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult); nsresult MakeWindow(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, const nsRect& aBounds); - nsresult StartLoad(nsIChannel* channel, nsIStreamListener*& aResult); + nsresult StartLoad(nsIRequest* request, nsIStreamListener*& aResult); void ForceRefresh(void); @@ -307,15 +307,18 @@ PluginViewerImpl::Init(nsIWidget* aParentWidget, } nsresult -PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult) +PluginViewerImpl::StartLoad(nsIRequest* request, 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; - mChannel->GetContentType(&contentType); + channel->GetContentType(&contentType); printf("PluginViewerImpl::StartLoad: content-type=%s\n", contentType); nsCRT::free(contentType); #endif @@ -331,14 +334,14 @@ PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult) { nsRect r; mWindow->GetClientBounds(r); - rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult); + rv = CreatePlugin(request, host, nsRect(0, 0, r.width, r.height), aResult); } return rv; } nsresult -PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, +PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult) { nsresult rv = NS_OK; @@ -372,7 +375,9 @@ PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, nsCRT::free(spec); char* ct; - rv = mChannel->GetContentType(&ct); + + nsCOMPtr channel = do_QueryInterface(request); + channel->GetContentType(&ct); if (NS_FAILED(rv)) return rv; rv = aHost->InstantiateFullPagePlugin(ct, str, aResult, mOwner); delete[] ct; @@ -692,43 +697,45 @@ PluginListener::~PluginListener() NS_IMPL_ISUPPORTS(PluginListener, kIStreamListenerIID) NS_IMETHODIMP -PluginListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +PluginListener::OnStartRequest(nsIRequest *request, 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(channel, mNextStream); + rv = mViewer->StartLoad(request, mNextStream); if (NS_FAILED(rv)) { return rv; } if (nsnull == mNextStream) return NS_ERROR_FAILURE; - return mNextStream->OnStartRequest(channel, ctxt); + return mNextStream->OnStartRequest(request, ctxt); } NS_IMETHODIMP -PluginListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +PluginListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); + return mNextStream->OnStopRequest(request, ctxt, status, errorMsg); } NS_IMETHODIMP -PluginListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +PluginListener::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); + return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index c3c6ff579f4..21d5213a01d 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -965,7 +965,7 @@ public: private: nsresult SetUpCache(nsIURI* aURL); - nsresult SetUpStreamListener(nsIChannel *channel, nsIURI* aURL); + nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL); nsIURI *mURL; nsIPluginInstanceOwner *mOwner; @@ -1026,13 +1026,13 @@ nsPluginCacheListener::~nsPluginCacheListener() NS_IMPL_ISUPPORTS(nsPluginCacheListener, kIStreamListenerIID); NS_IMETHODIMP -nsPluginCacheListener::OnStartRequest(nsIChannel* channel, nsISupports* ctxt) +nsPluginCacheListener::OnStartRequest(nsIRequest *request, nsISupports* ctxt) { return NS_OK; } NS_IMETHODIMP -nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt, +nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt, nsIInputStream* aIStream, PRUint32 sourceOffset, PRUint32 aLength) @@ -1055,7 +1055,7 @@ nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt, } NS_IMETHODIMP -nsPluginCacheListener::OnStopRequest(nsIChannel* channel, +nsPluginCacheListener::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) @@ -1223,10 +1223,15 @@ nsresult nsPluginStreamListenerPeer::InitializeFullPage(nsIPluginInstance *aInst NS_IMETHODIMP -nsPluginStreamListenerPeer::OnStartRequest(nsIChannel* channel, nsISupports* aContext) +nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, 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; @@ -1299,14 +1304,14 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIChannel* channel, nsISupports* aCo } - rv = SetUpStreamListener(channel, aURL); + rv = SetUpStreamListener(request, aURL); if (NS_FAILED(rv)) return rv; return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) @@ -1315,7 +1320,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIChannel* channel, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) @@ -1323,7 +1328,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStatus(nsIChannel* channel, return NS_OK; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request, nsISupports* aContext, nsIInputStream *aIStream, PRUint32 sourceOffset, @@ -1331,6 +1336,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, { 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; @@ -1352,7 +1360,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, // if a plugin returns an error, the peer must kill the stream // else the stream and PluginStreamListener leak if (NS_FAILED(rv)) - channel->Cancel(rv); + request->Cancel(rv); } else { @@ -1365,13 +1373,15 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel, return rv; } -NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel, +NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, 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; @@ -1379,7 +1389,11 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel, { char* urlString; nsCOMPtr localFile; - rv = channel->GetLocalFile(getter_AddRefs(localFile)); + nsCOMPtr fileChannel = do_QueryInterface(channel); + + if (fileChannel) + rv = fileChannel->GetFile(getter_AddRefs(localFile)); + if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; @@ -1434,7 +1448,7 @@ nsresult nsPluginStreamListenerPeer::SetUpCache(nsIURI* aURL) return NS_OpenURI(cacheListener, nsnull, aURL, nsnull); } -nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, +nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request, nsIURI* aURL) { nsresult rv = NS_OK; @@ -1466,6 +1480,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, nsCOMPtr headerListener = do_QueryInterface(mPStreamListener); if (headerListener) { + + nsCOMPtr channel = do_QueryInterface(request); nsCOMPtr httpChannel = do_QueryInterface(channel); if (httpChannel) { ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener); @@ -1477,6 +1493,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel, 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; @@ -3826,8 +3844,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, } } - - rv = channel->AsyncRead(listenerPeer, nsnull); + rv = channel->AsyncOpen(listenerPeer, nsnull); } NS_RELEASE(listenerPeer); diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h index 3c84ff6194d..41f13125d9b 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h @@ -37,6 +37,7 @@ 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 48f61986459..e4bc9ddd236 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -157,14 +157,14 @@ public: virtual ~PluginViewerImpl(); - nsresult CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, + nsresult CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult); nsresult MakeWindow(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, const nsRect& aBounds); - nsresult StartLoad(nsIChannel* channel, nsIStreamListener*& aResult); + nsresult StartLoad(nsIRequest* request, nsIStreamListener*& aResult); void ForceRefresh(void); @@ -307,15 +307,18 @@ PluginViewerImpl::Init(nsIWidget* aParentWidget, } nsresult -PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult) +PluginViewerImpl::StartLoad(nsIRequest* request, 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; - mChannel->GetContentType(&contentType); + channel->GetContentType(&contentType); printf("PluginViewerImpl::StartLoad: content-type=%s\n", contentType); nsCRT::free(contentType); #endif @@ -331,14 +334,14 @@ PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult) { nsRect r; mWindow->GetClientBounds(r); - rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult); + rv = CreatePlugin(request, host, nsRect(0, 0, r.width, r.height), aResult); } return rv; } nsresult -PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, +PluginViewerImpl::CreatePlugin(nsIRequest* request, nsIPluginHost* aHost, const nsRect& aBounds, nsIStreamListener*& aResult) { nsresult rv = NS_OK; @@ -372,7 +375,9 @@ PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, nsCRT::free(spec); char* ct; - rv = mChannel->GetContentType(&ct); + + nsCOMPtr channel = do_QueryInterface(request); + channel->GetContentType(&ct); if (NS_FAILED(rv)) return rv; rv = aHost->InstantiateFullPagePlugin(ct, str, aResult, mOwner); delete[] ct; @@ -692,43 +697,45 @@ PluginListener::~PluginListener() NS_IMPL_ISUPPORTS(PluginListener, kIStreamListenerIID) NS_IMETHODIMP -PluginListener::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +PluginListener::OnStartRequest(nsIRequest *request, 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(channel, mNextStream); + rv = mViewer->StartLoad(request, mNextStream); if (NS_FAILED(rv)) { return rv; } if (nsnull == mNextStream) return NS_ERROR_FAILURE; - return mNextStream->OnStartRequest(channel, ctxt); + return mNextStream->OnStartRequest(request, ctxt); } NS_IMETHODIMP -PluginListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +PluginListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); + return mNextStream->OnStopRequest(request, ctxt, status, errorMsg); } NS_IMETHODIMP -PluginListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +PluginListener::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); + return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/netwerk/base/public/MANIFEST_IDL b/mozilla/netwerk/base/public/MANIFEST_IDL index 406c7ef9c60..5268bb05840 100644 --- a/mozilla/netwerk/base/public/MANIFEST_IDL +++ b/mozilla/netwerk/base/public/MANIFEST_IDL @@ -16,6 +16,7 @@ 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 362fa359718..6527e7b3ea8 100644 --- a/mozilla/netwerk/base/public/Makefile.in +++ b/mozilla/netwerk/base/public/Makefile.in @@ -48,6 +48,7 @@ XPIDLSRCS = \ nsIProxyAutoConfig.idl \ nsIProxyAutoConfigUtils.idl \ nsIRequest.idl \ + nsITransport.idl \ nsISocketTransport.idl \ nsISocketTransportService.idl \ nsIStreamIO.idl \ @@ -55,7 +56,6 @@ XPIDLSRCS = \ nsIStreamListener.idl \ nsIStreamProvider.idl \ nsIStreamLoader.idl \ - nsISocketTransport.idl \ nsIURI.idl \ nsIURL.idl \ nsIURLParser.idl \ diff --git a/mozilla/netwerk/base/public/makefile.win b/mozilla/netwerk/base/public/makefile.win index 460470b1066..eef3df86b7c 100644 --- a/mozilla/netwerk/base/public/makefile.win +++ b/mozilla/netwerk/base/public/makefile.win @@ -50,14 +50,17 @@ XPIDLSRCS = \ .\nsIProxyAutoConfigUtils.idl \ .\nsIProxy.idl \ .\nsIRequest.idl \ + .\nsITransprt.idl \ .\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 bf5c6e77b33..8ec8b64b3c4 100644 --- a/mozilla/netwerk/base/public/nsIChannel.idl +++ b/mozilla/netwerk/base/public/nsIChannel.idl @@ -36,35 +36,24 @@ interface nsIStreamIO; typedef unsigned long nsLoadFlags; /** - * The nsIChannel interface allows the user to construct I/O requests for + * The nsIChannel interface allows the user to construct get 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: * - * - 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. + * - AsyncOpen is used for asynchronous reading, calling back the + * user's stream listener. + * - Open is used for synchronous read 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 { @@ -91,52 +80,6 @@ interface nsIChannel : nsIRequest */ attribute nsIURI URI; - /** - * 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 unsigned long transferOffset; - - /** - * 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 long transferCount; - - /** - * Accesses the load attributes for the channel. E.g. setting the load - * attributes with the LOAD_QUIET bit set causes the loading process to - * not deliver status notifications to the program performing the load, - * and to not contribute to keeping any nsILoadGroup it may be contained - * in from firing its OnLoadComplete notification. - */ - attribute nsLoadFlags loadAttributes; - - /** - * Returns the content MIME type of the channel if available. Note that the - * content type can often be wrongly specified (wrong file extension, wrong - * MIME type, wrong document type stored on a server, etc.) and the caller - * most likely wants to verify with the actual data. - */ - attribute string contentType; - - /** - * Returns the length of the data associated with the channel if available. - * If the length is unknown then -1 is returned. - */ - attribute long contentLength; - /** * Accesses the owner corresponding to the entity that is * responsible for this channel. Used by security code to grant @@ -153,6 +96,15 @@ interface nsIChannel : nsIRequest */ attribute nsILoadGroup loadGroup; + /** + * Accesses the load attributes for the channel. E.g. setting the load + * attributes with the LOAD_QUIET bit set causes the loading process to + * not deliver status notifications to the program performing the load, + * and to not contribute to keeping any nsILoadGroup it may be contained + * in from firing its OnLoadComplete notification. + */ + 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 @@ -160,43 +112,37 @@ interface nsIChannel : nsIRequest */ 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. + * Returns the content MIME type of the channel if available. Note that the + * content type can often be wrongly specified (wrong file extension, wrong + * MIME type, wrong document type stored on a server, etc.) and the caller + * most likely wants to verify with the actual data. */ - attribute unsigned long bufferSegmentSize; + attribute string contentType; /** - * 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. + * Returns the length of the data associated with the channel if available. + * If the length is unknown then -1 is returned. */ - attribute unsigned long bufferMaxSize; + attribute long contentLength; /** - * Returns a local file to the channel's data if one exists, null otherwise. - */ - readonly attribute nsIFile localFile; + * Open is used for synchronous read on the channel. + **/ + nsIInputStream open(); - /** - * 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; + /** AsyncOpen is used for asynchronous reading, calling back the + * user's stream listener. + **/ + void asyncOpen(in nsIStreamListener listener, in nsISupports ctxt); //////////////////////////////////////////////////////////////////////////// - // Load attribute flags. These may be or'd together. + // Below are Load attribute flags which may be or'd together. //////////////////////////////////////////////////////////////////////////// /** * Note that more will follow for each protocol's implementation of a channel, @@ -287,41 +233,7 @@ 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); }; //////////////////////////////////////////////////////////////////////////////// @@ -334,8 +246,7 @@ 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 00e25528285..4698b872dec 100644 --- a/mozilla/netwerk/base/public/nsIDownloader.idl +++ b/mozilla/netwerk/base/public/nsIDownloader.idl @@ -48,9 +48,7 @@ interface nsIDownloader : nsISupports in boolean synchronous, in nsILoadGroup loadGroup, in nsIInterfaceRequestor notificationCallbacks, - in nsLoadFlags loadAttributes, - in unsigned long bufferSegmentSize, - in unsigned long bufferMaxSize); + in nsLoadFlags loadAttributes); }; %{C++ diff --git a/mozilla/netwerk/base/public/nsIFileTransportService.idl b/mozilla/netwerk/base/public/nsIFileTransportService.idl index d7b2f78cb19..5891df7fc4f 100644 --- a/mozilla/netwerk/base/public/nsIFileTransportService.idl +++ b/mozilla/netwerk/base/public/nsIFileTransportService.idl @@ -25,7 +25,7 @@ #include "nsFileSpec.h" %} -interface nsIChannel; +interface nsITransport; interface nsIEventSinkGetter; interface nsIInputStream; interface nsIRunnable; @@ -35,18 +35,18 @@ interface nsIStreamIO; [scriptable, uuid(57211a60-8c45-11d3-93ac-00104ba0fd40)] interface nsIFileTransportService : nsISupports { - nsIChannel createTransport(in nsIFile file, - in long ioFlags, - in long perm); + nsITransport 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: - nsIChannel createTransportFromStream(in string name, - in nsIInputStream fromStream, - in string contentType, - in long contentLength); + nsITransport createTransportFromStream(in string name, + in nsIInputStream fromStream, + in string contentType, + in long contentLength); - nsIChannel createTransportFromStreamIO(in nsIStreamIO io); + nsITransport 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 58498496885..2a8b6589baf 100644 --- a/mozilla/netwerk/base/public/nsIIOService.idl +++ b/mozilla/netwerk/base/public/nsIIOService.idl @@ -104,15 +104,6 @@ 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 9c16bafc9fb..0e4d69125a1 100644 --- a/mozilla/netwerk/base/public/nsILoadGroup.idl +++ b/mozilla/netwerk/base/public/nsILoadGroup.idl @@ -23,6 +23,7 @@ #include "nsIRequest.idl" interface nsIChannel; +interface nsIRequest; interface nsISimpleEnumerator; interface nsIStreamObserver; interface nsIStreamListener; @@ -52,35 +53,35 @@ interface nsILoadGroup : nsIRequest /** * Accesses the default load channel for the group. Each time a number - * 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. + * 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. */ - attribute nsIChannel defaultLoadChannel; + attribute nsIRequest defaultLoadRequest; /** - * 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 + * 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 * method is called. */ - void addChannel(in nsIChannel channel, + void addRequest(in nsIRequest request, in nsISupports ctxt); /** - * Removes a channel from the group. If the channel removed is - * the last channel in the group, the group's observer's OnStopRequest + * Removes a request from the group. If the request removed is + * the last request in the group, the group's observer's OnStopRequest * method is called. */ - void removeChannel(in nsIChannel channel, + void removeRequest(in nsIRequest request, in nsISupports ctxt, in nsresult status, in wstring statusArg); /** - * Returns the channels contained directly in this group. - * Enumerator element type: nsIChannel. + * Returns the requests contained directly in this group. + * Enumerator element type: nsIRequest. */ - readonly attribute nsISimpleEnumerator channels; + readonly attribute nsISimpleEnumerator requests; attribute nsIStreamObserver groupObserver; diff --git a/mozilla/netwerk/base/public/nsIProgressEventSink.idl b/mozilla/netwerk/base/public/nsIProgressEventSink.idl index 1260b37d7e5..50ec3c925e9 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 nsIChannel; +interface nsIRequest; /** * An instance of nsIFfpEventSink should be passed as the eventSink @@ -34,9 +34,9 @@ interface nsIChannel; interface nsIProgressEventSink : nsISupports { /** - * Notify the EventSink that progress as occurred for the URL load.
+ * Notify the EventSink that progress has occurred for the URL load.
*/ - void onProgress(in nsIChannel channel, + void onProgress(in nsIRequest request, 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 nsIChannel channel, + void onStatus(in nsIRequest request, 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 54feb3dbc34..d4455b83225 100644 --- a/mozilla/netwerk/base/public/nsISocketTransport.idl +++ b/mozilla/netwerk/base/public/nsISocketTransport.idl @@ -20,11 +20,14 @@ * Contributor(s): */ -#include "nsISupports.idl" +#include "nsITransport.idl" [scriptable, uuid(785CA0F0-C39E-11d3-9ED6-0010A4053FD0)] -interface nsISocketTransport : nsISupports +interface nsISocketTransport : nsITransport { + 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 04894ac19de..012810223a3 100644 --- a/mozilla/netwerk/base/public/nsISocketTransportService.idl +++ b/mozilla/netwerk/base/public/nsISocketTransportService.idl @@ -22,8 +22,9 @@ #include "nsISupports.idl" -interface nsIChannel; +interface nsITransport; interface nsIEventSinkGetter; +interface nsIChannel; [scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)] interface nsISocketTransportService : nsISupports @@ -36,29 +37,29 @@ interface nsISocketTransportService : nsISupports * etc. The printHost contains the actual hostname (and not the * proxy) for displaying in status messages. */ - nsIChannel createTransport(in string host, - in long port, - in string proxyHost, - in long proxyPort, - in unsigned long bufferSegmentSize, - in unsigned long bufferMaxSize); + nsITransport createTransport(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 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 createTransportOfTypes(in unsigned long typeCount, + nsITransport 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 @@ -66,11 +67,11 @@ interface nsISocketTransportService : nsISupports * include- an error including server resets, an explicit * Connection: close header (for HTTP) and timeouts! */ - boolean reuseTransport(in nsIChannel i_Transport); + boolean reuseTransport(in nsITransport i_Transport); void init (); void shutdown(); - void wakeup (in nsIChannel i_Transport); + void wakeup (in nsITransport 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 306941161d0..fae64da5c9d 100644 --- a/mozilla/netwerk/base/public/nsIStreamListener.idl +++ b/mozilla/netwerk/base/public/nsIStreamListener.idl @@ -22,7 +22,7 @@ #include "nsIStreamObserver.idl" -interface nsIChannel; +interface nsIRequest; 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 channel - the channel being read + * @param request - the request returned by AsyncRead * @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 nsIChannel channel, + void onDataAvailable(in nsIRequest request, 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 61749c813be..7b5a6aedb43 100644 --- a/mozilla/netwerk/base/public/nsIStreamLoader.idl +++ b/mozilla/netwerk/base/public/nsIStreamLoader.idl @@ -23,6 +23,7 @@ #include "nsISupports.idl" #include "nsIChannel.idl" +interface nsIRequest; interface nsIURI; interface nsILoadGroup; interface nsIStreamObserver; @@ -47,9 +48,7 @@ interface nsIStreamLoader : nsISupports in nsISupports ctxt, in nsILoadGroup loadGroup, in nsIInterfaceRequestor notificationCallbacks, - in nsLoadFlags loadAttributes, - in unsigned long bufferSegmentSize, - in unsigned long bufferMaxSize); + in nsLoadFlags loadAttributes); /** * Gets the number of bytes read so far. @@ -57,9 +56,9 @@ interface nsIStreamLoader : nsISupports readonly attribute unsigned long numBytesRead; /** - * Gets the channel that loaded this file + * Gets the request that loaded this file */ - readonly attribute nsIChannel channel; + readonly attribute nsIRequest request; }; diff --git a/mozilla/netwerk/base/public/nsIStreamObserver.idl b/mozilla/netwerk/base/public/nsIStreamObserver.idl index f20f5365402..0edb6a86b5e 100644 --- a/mozilla/netwerk/base/public/nsIStreamObserver.idl +++ b/mozilla/netwerk/base/public/nsIStreamObserver.idl @@ -22,7 +22,7 @@ #include "nsISupports.idl" -interface nsIChannel; +interface nsIRequest; 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 channel - channel being observed + * @param request - request being observed * @param ctxt - user specified data passed to AsyncRead/Write */ - void onStartRequest(in nsIChannel channel, + void onStartRequest(in nsIRequest request, in nsISupports ctxt); /** * Called to signify the end of an asynchronous request. This * call is always preceded by a call to onStartRequest. * - * @param channel - channel being observed + * @param request - request 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 nsIChannel channel, + void onStopRequest(in nsIRequest request, 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 41c3008ea7b..9f76787edea 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 channel - the channel being written to + * @param request - the request returned by AsyncWrite * @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 nsIChannel channel, + void onDataWritable(in nsIRequest request, 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 e69de29bb2d..1ef4c27c6e8 100644 --- a/mozilla/netwerk/base/public/nsITransport.idl +++ b/mozilla/netwerk/base/public/nsITransport.idl @@ -0,0 +1,105 @@ +/* -*- 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 19ef0a78e8c..d9c837b2c50 100644 --- a/mozilla/netwerk/base/public/nsNetUtil.h +++ b/mozilla/netwerk/base/public/nsNetUtil.h @@ -36,6 +36,7 @@ #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsIChannel.h" +#include "nsITransport.h" #include "nsMemory.h" #include "nsCOMPtr.h" #include "nsIHTTPProtocolHandler.h" @@ -94,9 +95,7 @@ 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), - PRUint32 bufferSegmentSize = 0, - PRUint32 bufferMaxSize = 0) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) { nsresult rv; @@ -123,14 +122,6 @@ 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; @@ -148,20 +139,17 @@ 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), - PRUint32 bufferSegmentSize = 0, - PRUint32 bufferMaxSize = 0) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) { nsresult rv; nsCOMPtr channel; rv = NS_OpenURI(getter_AddRefs(channel), uri, ioService, - loadGroup, notificationCallbacks, loadAttributes, - bufferSegmentSize, bufferMaxSize); + loadGroup, notificationCallbacks, loadAttributes); if (NS_FAILED(rv)) return rv; nsIInputStream* inStr; - rv = channel->OpenInputStream(&inStr); + rv = channel->Open(&inStr); if (NS_FAILED(rv)) return rv; *result = inStr; @@ -175,19 +163,16 @@ 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), - PRUint32 bufferSegmentSize = 0, - PRUint32 bufferMaxSize = 0) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) { nsresult rv; nsCOMPtr channel; rv = NS_OpenURI(getter_AddRefs(channel), uri, ioService, - loadGroup, notificationCallbacks, loadAttributes, - bufferSegmentSize, bufferMaxSize); + loadGroup, notificationCallbacks, loadAttributes); if (NS_FAILED(rv)) return rv; - rv = channel->AsyncRead(aConsumer, context); + rv = channel->AsyncOpen(aConsumer, context); return rv; } @@ -326,9 +311,7 @@ NS_NewDownloader(nsIDownloader* *result, PRBool synchronous = PR_FALSE, nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), - PRUint32 bufferSegmentSize = 0, - PRUint32 bufferMaxSize = 0) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) { nsresult rv; nsCOMPtr downloader; @@ -338,8 +321,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, bufferSegmentSize, bufferMaxSize); + rv = downloader->Init(uri, observer, context, synchronous, loadGroup, + notificationCallbacks, loadAttributes); if (NS_FAILED(rv)) return rv; *result = downloader; NS_ADDREF(*result); @@ -353,9 +336,7 @@ NS_NewStreamLoader(nsIStreamLoader* *result, nsISupports* context = nsnull, nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, - nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL), - PRUint32 bufferSegmentSize = 0, - PRUint32 bufferMaxSize = 0) + nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL)) { nsresult rv; nsCOMPtr loader; @@ -365,8 +346,9 @@ 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, - bufferSegmentSize, bufferMaxSize); + rv = loader->Init(uri, observer, context, loadGroup, + notificationCallbacks, loadAttributes); + if (NS_FAILED(rv)) return rv; *result = loader; NS_ADDREF(*result); @@ -393,9 +375,7 @@ NS_NewStreamObserverProxy(nsIStreamObserver **aResult, rv = proxy->Init(aObserver, aEventQ); if (NS_FAILED(rv)) return rv; - *aResult = proxy; - NS_ADDREF(*aResult); - + NS_ADDREF(*aResult = proxy); return NS_OK; } @@ -421,9 +401,7 @@ NS_NewStreamListenerProxy(nsIStreamListener **aResult, rv = proxy->Init(aListener, aEventQ, aBufferSegmentSize, aBufferMaxSize); if (NS_FAILED(rv)) return rv; - *aResult = proxy; - NS_ADDREF(*aResult); - + NS_ADDREF(*aResult = proxy); return NS_OK; } @@ -449,9 +427,7 @@ NS_NewStreamProviderProxy(nsIStreamProvider **aResult, rv = proxy->Init(aProvider, aEventQ, aBufferSegmentSize, aBufferMaxSize); if (NS_FAILED(rv)) return rv; - *aResult = proxy; - NS_ADDREF(*aResult); - + NS_ADDREF(*aResult = proxy); return NS_OK; } @@ -474,9 +450,7 @@ NS_NewSimpleStreamListener(nsIStreamListener **aResult, rv = listener->Init(aSink, aObserver); if (NS_FAILED(rv)) return rv; - *aResult = listener.get(); - NS_ADDREF(*aResult); - + NS_ADDREF(*aResult = listener); return NS_OK; } @@ -499,9 +473,7 @@ NS_NewSimpleStreamProvider(nsIStreamProvider **aResult, rv = provider->Init(aSource, aObserver); if (NS_FAILED(rv)) return rv; - *aResult = provider.get(); - NS_ADDREF(*aResult); - + NS_ADDREF(*aResult = provider); return NS_OK; } @@ -522,8 +494,7 @@ NS_NewAsyncStreamObserver(nsIStreamObserver **result, rv = obs->Init(receiver, eventQueue); if (NS_FAILED(rv)) return rv; - *result = obs; - NS_ADDREF(*result); + NS_ADDREF(*result = obs); return NS_OK; } @@ -544,8 +515,7 @@ NS_NewAsyncStreamListener(nsIStreamListener **result, rv = lsnr->Init(receiver, eventQueue); if (NS_FAILED(rv)) return rv; - *result = lsnr; - NS_ADDREF(*result); + NS_ADDREF(*result = lsnr); return NS_OK; } @@ -572,25 +542,26 @@ NS_NewSyncStreamListener(nsIInputStream **aInStream, rv = NS_NewSimpleStreamListener(aResult, pipeOut); if (NS_FAILED(rv)) return rv; - *aInStream = pipeIn; - NS_ADDREF(*aInStream); - *aOutStream = pipeOut; - NS_ADDREF(*aOutStream); - + NS_ADDREF(*aInStream = pipeIn); + NS_ADDREF(*aOutStream = pipeOut); return NS_OK; } // -// Calls AsyncWrite on the specified channel, with a stream provider that +// Calls AsyncWrite on the specified transport, with a stream provider that // reads data from the specified input stream. // inline nsresult -NS_AsyncWriteFromStream(nsIChannel *aChannel, +NS_AsyncWriteFromStream(nsIRequest **aRequest, + nsITransport *aTransport, nsIInputStream *aSource, + PRUint32 aOffset=0, + PRUint32 aCount=0, + PRUint32 aFlags=0, nsIStreamObserver *aObserver=NULL, nsISupports *aContext=NULL) { - NS_ENSURE_ARG_POINTER(aChannel); + NS_ENSURE_ARG_POINTER(aTransport); nsresult rv; nsCOMPtr provider; @@ -599,20 +570,28 @@ NS_AsyncWriteFromStream(nsIChannel *aChannel, aObserver); if (NS_FAILED(rv)) return rv; - return aChannel->AsyncWrite(provider, aContext); + return aTransport->AsyncWrite(provider, aContext, + aOffset, + aCount, + aFlags, + getter_AddRefs(aRequest)); } // -// Calls AsyncRead on the specified channel, with a stream listener that +// Calls AsyncRead on the specified transport, with a stream listener that // writes data to the specified output stream. // inline nsresult -NS_AsyncReadToStream(nsIChannel *aChannel, +NS_AsyncReadToStream(nsIRequest **aRequest, + nsITransport *aTransport, nsIOutputStream *aSink, + PRUint32 aOffset=0, + PRUint32 aCount=0, + PRUint32 aFlags=0, nsIStreamObserver *aObserver=NULL, nsISupports *aContext=NULL) { - NS_ENSURE_ARG_POINTER(aChannel); + NS_ENSURE_ARG_POINTER(aTransport); nsresult rv; nsCOMPtr listener; @@ -621,7 +600,11 @@ NS_AsyncReadToStream(nsIChannel *aChannel, aObserver); if (NS_FAILED(rv)) return rv; - return aChannel->AsyncRead(listener, aContext); + return aTransport->AsyncRead(listener, aContext, + aOffset, + aCount, + aFlags, + getter_AddRefs(aRequest)); } #endif // nsNetUtil_h__ diff --git a/mozilla/netwerk/base/public/security-prefs.js b/mozilla/netwerk/base/public/security-prefs.js index 7b97b561eb9..59c8dee10dc 100644 --- a/mozilla/netwerk/base/public/security-prefs.js +++ b/mozilla/netwerk/base/public/security-prefs.js @@ -9,3 +9,7 @@ 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 f5f08f4a532..a7f3209a292 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, - nsIChannel* channel, nsISupports* context); + nsIRequest* request, nsISupports* context); virtual ~nsStreamListenerEvent(); nsresult Fire(nsIEventQueue* aEventQ); @@ -60,7 +60,7 @@ protected: static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent); nsAsyncStreamObserver* mListener; - nsIChannel* mChannel; + nsIRequest* mRequest; nsISupports* mContext; PLEvent mEvent; }; @@ -71,13 +71,13 @@ protected: //////////////////////////////////////////////////////////////////////////////// nsStreamListenerEvent::nsStreamListenerEvent(nsAsyncStreamObserver* listener, - nsIChannel* channel, nsISupports* context) - : mListener(listener), mChannel(channel), mContext(context) + nsIRequest* request, nsISupports* context) + : mListener(listener), mRequest(request), mContext(context) { MOZ_COUNT_CTOR(nsStreamListenerEvent); NS_IF_ADDREF(mListener); - NS_IF_ADDREF(mChannel); + NS_IF_ADDREF(mRequest); NS_IF_ADDREF(mContext); } @@ -86,7 +86,7 @@ nsStreamListenerEvent::~nsStreamListenerEvent() MOZ_COUNT_DTOR(nsStreamListenerEvent); NS_IF_RELEASE(mListener); - NS_IF_RELEASE(mChannel); + NS_IF_RELEASE(mRequest); 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->mChannel->Cancel(rv); + nsresult cancelRv = ev->mRequest->Cancel(rv); NS_ASSERTION(NS_SUCCEEDED(cancelRv), "Cancel failed"); } } @@ -182,8 +182,8 @@ class nsOnStartRequestEvent : public nsStreamListenerEvent { public: nsOnStartRequestEvent(nsAsyncStreamObserver* listener, - nsIChannel* channel, nsISupports* context) - : nsStreamListenerEvent(listener, channel, context) {} + nsIRequest* request, nsISupports* context) + : nsStreamListenerEvent(listener, request, context) {} virtual ~nsOnStartRequestEvent() {} NS_IMETHOD HandleEvent(); @@ -205,19 +205,19 @@ nsOnStartRequestEvent::HandleEvent() } nsresult status; - nsresult rv = mChannel->GetStatus(&status); + nsresult rv = mRequest->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); - rv = receiver->OnStartRequest(mChannel, mContext); + rv = receiver->OnStartRequest(mRequest, mContext); return rv; } NS_IMETHODIMP -nsAsyncStreamObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) +nsAsyncStreamObserver::OnStartRequest(nsIRequest *request, nsISupports* context) { nsresult rv; nsOnStartRequestEvent* event = - new nsOnStartRequestEvent(this, channel, context); + new nsOnStartRequestEvent(this, request, context); if (event == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -252,8 +252,8 @@ class nsOnStopRequestEvent : public nsStreamListenerEvent { public: nsOnStopRequestEvent(nsAsyncStreamObserver* listener, - nsISupports* context, nsIChannel* channel) - : nsStreamListenerEvent(listener, channel, context), + nsISupports* context, nsIRequest* request) + : nsStreamListenerEvent(listener, request, context), mStatus(NS_OK) {} virtual ~nsOnStopRequestEvent(); @@ -293,7 +293,7 @@ nsOnStopRequestEvent::HandleEvent() } nsresult status = NS_OK; - nsresult rv = mChannel->GetStatus(&status); + nsresult rv = mRequest->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(mChannel, mContext, mStatus, mStatusArg.GetUnicode()); + rv = receiver->OnStopRequest(mRequest, 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(nsIChannel* channel, nsISupports* context, +nsAsyncStreamObserver::OnStopRequest(nsIRequest* request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -320,7 +320,7 @@ nsAsyncStreamObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, // Status is... // nsOnStopRequestEvent* event = - new nsOnStopRequestEvent(this, context, channel); + new nsOnStopRequestEvent(this, context, request); if (event == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -354,8 +354,8 @@ class nsOnDataAvailableEvent : public nsStreamListenerEvent { public: nsOnDataAvailableEvent(nsAsyncStreamObserver* listener, - nsIChannel* channel, nsISupports* context) - : nsStreamListenerEvent(listener, channel, context), + nsIRequest* request, nsISupports* context) + : nsStreamListenerEvent(listener, request, context), mIStream(nsnull), mLength(0) {} virtual ~nsOnDataAvailableEvent(); @@ -401,7 +401,7 @@ nsOnDataAvailableEvent::HandleEvent() } nsresult status; - nsresult rv = mChannel->GetStatus(&status); + nsresult rv = mRequest->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(mChannel, mContext, + rv = receiver->OnDataAvailable(mRequest, mContext, mIStream, mSourceOffset, mLength); } else { @@ -419,14 +419,14 @@ nsOnDataAvailableEvent::HandleEvent() } NS_IMETHODIMP -nsAsyncStreamListener::OnDataAvailable(nsIChannel* channel, nsISupports* context, +nsAsyncStreamListener::OnDataAvailable(nsIRequest* request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { nsresult rv; nsOnDataAvailableEvent* event = - new nsOnDataAvailableEvent(this, channel, context); + new nsOnDataAvailableEvent(this, request, 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 7eac3aa6355..c1e3b11b02d 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(nsIChannel* channel, + NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports* context) { - return nsAsyncStreamObserver::OnStartRequest(channel, context); + return nsAsyncStreamObserver::OnStartRequest(request, context); } - NS_IMETHOD OnStopRequest(nsIChannel* channel, + NS_IMETHOD OnStopRequest(nsIRequest* request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { - return nsAsyncStreamObserver::OnStopRequest(channel, context, aStatus, aStatusArg); + return nsAsyncStreamObserver::OnStopRequest(request, context, aStatus, aStatusArg); } - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, + NS_IMETHOD OnDataAvailable(nsIRequest* request, 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 795579065d5..a23febb948b 100644 --- a/mozilla/netwerk/base/src/nsDownloader.cpp +++ b/mozilla/netwerk/base/src/nsDownloader.cpp @@ -43,9 +43,7 @@ nsDownloader::Init(nsIURI* aURL, PRBool aIsSynchronous, nsILoadGroup* aGroup, nsIInterfaceRequestor* aNotificationCallbacks, - nsLoadFlags aLoadAttributes, - PRUint32 aBufferSegmentSize, - PRUint32 aBufferMaxSize) + nsLoadFlags aLoadAttributes) { nsresult rv; mObserver = aObserver; @@ -55,10 +53,13 @@ nsDownloader::Init(nsIURI* aURL, aLoadAttributes |= nsIChannel::CACHE_AS_FILE; rv = NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, aGroup, aNotificationCallbacks, - aLoadAttributes, aBufferSegmentSize, aBufferMaxSize); + aLoadAttributes); if (NS_SUCCEEDED(rv) && channel) - rv = channel->GetLocalFile(getter_AddRefs(localFile)); - + { + nsCOMPtr fc = do_QueryInterface(channel); + if (fc) + rv = fc->GetFile(getter_AddRefs(localFile)); + } if (mObserver && (NS_FAILED(rv) || localFile)) { if (aIsSynchronous) @@ -81,8 +82,7 @@ nsDownloader::Init(nsIURI* aURL, return pObserver->OnDownloadComplete(this, mContext, rv, localFile); } } - - return channel->AsyncRead(this, aContext); + return channel->AsyncOpen(this, aContext); } NS_METHOD @@ -103,13 +103,13 @@ NS_IMPL_ISUPPORTS3(nsDownloader, nsIDownloader, nsIStreamObserver, nsIStreamListener) NS_IMETHODIMP -nsDownloader::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +nsDownloader::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { return NS_OK; } NS_IMETHODIMP -nsDownloader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +nsDownloader::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsCOMPtr file; @@ -117,6 +117,10 @@ nsDownloader::OnStopRequest(nsIChannel* channel, 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; @@ -147,7 +151,7 @@ nsDownloader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, #define BUF_SIZE 1024 NS_IMETHODIMP -nsDownloader::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +nsDownloader::OnDataAvailable(nsIRequest *request, 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 e54be33e277..50e8dbb9f8c 100644 --- a/mozilla/netwerk/base/src/nsFileTransport.cpp +++ b/mozilla/netwerk/base/src/nsFileTransport.cpp @@ -208,7 +208,6 @@ nsFileTransport::nsFileTransport() mOffset(0), mTotalAmount(-1), mTransferAmount(-1), - mLoadAttributes(LOAD_NORMAL), mSourceWrapper(nsnull), mSinkWrapper(nsnull), mService(nsnull) @@ -259,7 +258,7 @@ nsFileTransport::Init(nsFileTransportService *aService, nsIStreamIO* io) mStreamName = NS_STATIC_CAST(const char*, name); NS_ASSERTION(NS_SUCCEEDED(rv), "GetName failed"); - mService = aService; + NS_ADDREF(mService = aService); PR_AtomicIncrement(&mService->mTotalTransports); return rv; @@ -270,23 +269,27 @@ nsFileTransport::~nsFileTransport() if (mXferState != CLOSED) DoClose(); - NS_ASSERTION(mSource == nsnull, "transport not closed"); NS_ASSERTION(mSourceWrapper == nsnull, "transport not closed"); NS_ASSERTION(mSink == nsnull, "transport not closed"); NS_ASSERTION(mSinkWrapper == nsnull, "transport not closed"); - if (mLock) + if (mLock) { PR_DestroyLock(mLock); - if (mContentType) + mLock = nsnull; + } + if (mContentType) { nsCRT::free(mContentType); + mContentType = nsnull; + } - PR_AtomicDecrement(&mService->mTotalTransports); + NS_IF_RELEASE(mService); } -NS_IMPL_THREADSAFE_ISUPPORTS3(nsFileTransport, - nsIChannel, - nsIRequest, - nsIRunnable) +NS_IMPL_THREADSAFE_ISUPPORTS4(nsFileTransport, + nsITransport, + nsITransportRequest, + nsIRequest, + nsIRunnable) NS_METHOD nsFileTransport::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) @@ -356,6 +359,7 @@ nsFileTransport::Suspend() if (mRunState != CANCELED) { LOG(("nsFileTransport: Suspend [this=%x %s]\n", this, mStreamName.GetBuffer())); PR_AtomicIncrement(&mSuspendCount); + mService->AddSuspendedTransport(this); } return NS_OK; } @@ -368,7 +372,7 @@ nsFileTransport::Resume() LOG(("nsFileTransport: Resume [this=%x %s]\n", this, mStreamName.GetBuffer())); // Allow negative suspend count PR_AtomicDecrement(&mSuspendCount); - + mService->RemoveSuspendedTransport(this); // Only dispatch a new thread, if there isn't one currently active. if (!mActive && (mSuspendCount == 0)) { mRunState = RUNNING; @@ -384,52 +388,80 @@ 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(nsIInputStream **result) +nsFileTransport::OpenInputStream(PRUint32 aTransferOffset, + PRUint32 aTransferCount, + PRUint32 aFlags, + nsIInputStream **aResult) { + NS_ENSURE_ARG_POINTER(aResult); nsresult rv; nsCOMPtr in; rv = mStreamIO->GetInputStream(getter_AddRefs(in)); if (NS_FAILED(rv)) return rv; - NS_ASSERTION(mTransferAmount == -1, "need to wrap input stream in one that truncates"); - if (mOffset > 0) { + NS_ASSERTION(aTransferCount == (PRUint32) -1, "need to wrap input stream in one that truncates"); + if (aTransferOffset > 0) { nsCOMPtr seekable = do_QueryInterface(in, &rv); if (NS_FAILED(rv)) return rv; - rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset); + rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, aTransferOffset); if (NS_FAILED(rv)) return rv; } - *result = in; - NS_ADDREF(*result); + NS_ADDREF(*aResult = in); return rv; } NS_IMETHODIMP -nsFileTransport::OpenOutputStream(nsIOutputStream **result) +nsFileTransport::OpenOutputStream(PRUint32 aTransferOffset, + PRUint32 aTransferCount, + PRUint32 aFlags, + nsIOutputStream **aResult) { - return mStreamIO->GetOutputStream(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); } NS_IMETHODIMP -nsFileTransport::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +nsFileTransport::AsyncRead(nsIStreamListener *aListener, + nsISupports *aContext, + PRUint32 aTransferOffset, + PRUint32 aTransferCount, + PRUint32 aFlags, + nsIRequest **aResult) { + NS_ENSURE_ARG_POINTER(aResult); nsresult rv = NS_OK; if (mXferState != CLOSED) return NS_ERROR_IN_PROGRESS; - NS_ASSERTION(listener, "need to supply an nsIStreamListener"); + NS_ASSERTION(aListener, "need to supply an nsIStreamListener"); rv = NS_NewStreamListenerProxy(getter_AddRefs(mListener), - listener, nsnull, + aListener, nsnull, mBufferSegmentSize, mBufferMaxSize); if (NS_FAILED(rv)) return rv; NS_ASSERTION(mContext == nsnull, "context not released"); - mContext = ctxt; + mContext = aContext; + mOffset = aTransferOffset; + mTransferAmount = aTransferCount; mXferState = OPEN_FOR_READ; LOG(("nsFileTransport: AsyncRead [this=%x %s] mOffset=%d mTransferAmount=%d\n", @@ -441,27 +473,38 @@ nsFileTransport::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) rv = mService->DispatchRequest(this); if (NS_FAILED(rv)) return rv; + NS_ADDREF(*aResult = this); return NS_OK; } NS_IMETHODIMP -nsFileTransport::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt) +nsFileTransport::AsyncWrite(nsIStreamProvider *aProvider, + nsISupports *aContext, + PRUint32 aTransferOffset, + PRUint32 aTransferCount, + PRUint32 aFlags, + nsIRequest **aResult) { + NS_ENSURE_ARG_POINTER(aResult); nsresult rv = NS_OK; LOG(("nsFileTransport: AsyncWrite [this=%x, provider=%x]\n", - this, provider)); + this, aProvider)); if (mXferState != CLOSED) return NS_ERROR_IN_PROGRESS; - NS_ASSERTION(provider, "need to supply an nsIStreamProvider"); - rv = NS_NewStreamProviderProxy(getter_AddRefs(mProvider), provider); + NS_ASSERTION(aProvider, "need to supply an nsIStreamProvider"); + rv = NS_NewStreamProviderProxy(getter_AddRefs(mProvider), + aProvider, nsnull, + mBufferSegmentSize, + mBufferMaxSize); if (NS_FAILED(rv)) return rv; NS_ASSERTION(mContext == nsnull, "context not released"); - mContext = ctxt; + mContext = aContext; + mOffset = aTransferOffset; + mTransferAmount = aTransferCount; mXferState = OPEN_FOR_WRITE; LOG(("nsFileTransport: AsyncWrite [this=%x %s] mOffset=%d mTransferAmount=%d\n", @@ -473,9 +516,10 @@ nsFileTransport::AsyncWrite(nsIStreamProvider *provider, rv = mService->DispatchRequest(this); if (NS_FAILED(rv)) return rv; + NS_ADDREF(*aResult = this); return NS_OK; } - + //////////////////////////////////////////////////////////////////////////////// // nsIRunnable methods: //////////////////////////////////////////////////////////////////////////////// @@ -492,6 +536,9 @@ nsFileTransport::Run(void) PRIntervalTime now = PR_IntervalNow(); printf("nsFileTransport: latency=%u ticks\n", now - mStartTime); #endif + + if (mRunState == SUSPENDED && NS_FAILED(mCancelStatus)) + mRunState = CANCELED; while (mXferState != CLOSED && mRunState != SUSPENDED) { // @@ -521,8 +568,10 @@ nsFileTransport::Run(void) // // Were we suspended ? // - else if (mSuspendCount > 0) + else if (mSuspendCount > 0) { mRunState = SUSPENDED; + mService->AddSuspendedTransport(this); + } } LOG(("nsFileTransport: Leaving Run [xferState=%d runState=%d]\n", @@ -538,10 +587,9 @@ nsFileTransport::Process(void) { LOG(("nsFileTransport: Inside Process [this=%x state=%x status=%x]\n", this, mXferState, mStatus)); - + switch (mXferState) { case OPEN_FOR_READ: { - LOG(("nsFileTransport: OPEN_FOR_READ [this=%x %s]\n", this, mStreamName.GetBuffer())); mStatus = mStreamIO->Open(&mContentType, &mTotalAmount); LOG(("nsFileTransport: OPEN_FOR_READ [this=%x %s] status=%x\n", this, mStreamName.GetBuffer(), mStatus)); if (mListener) { @@ -558,8 +606,9 @@ nsFileTransport::Process(void) LOG(("nsFileTransport: START_READ [this=%x %s]\n", this, mStreamName.GetBuffer())); PR_AtomicIncrement(&mService->mInUseTransports); - - mStatus = mStreamIO->GetInputStream(getter_AddRefs(mSource)); + + nsCOMPtr source; + mStatus = mStreamIO->GetInputStream(getter_AddRefs(source)); if (NS_FAILED(mStatus)) { LOG(("nsFileTransport: mStreamIO->GetInputStream() failed [this=%x rv=%x]\n", this, mStatus)); @@ -570,7 +619,7 @@ nsFileTransport::Process(void) if (mOffset > 0) { // if we need to set a starting offset, QI for the nsISeekableStream // and set it - nsCOMPtr ras = do_QueryInterface(mSource, &mStatus); + nsCOMPtr ras = do_QueryInterface(source, &mStatus); if (NS_FAILED(mStatus)) { mXferState = END_READ; return; @@ -587,7 +636,7 @@ nsFileTransport::Process(void) if (!mSourceWrapper) { // // Allocate an input stream wrapper to capture the number of bytes - // read from mSource. + // read from source. // NS_NEWXPCOM(mSourceWrapper, nsFileTransportSourceWrapper); if (!mSourceWrapper) { @@ -596,7 +645,7 @@ nsFileTransport::Process(void) return; } NS_ADDREF(mSourceWrapper); - mSourceWrapper->SetSource(mSource); + mSourceWrapper->SetSource(source); } // capture the total amount for progress information @@ -671,8 +720,8 @@ nsFileTransport::Process(void) LOG(("nsFileTransport: READING [this=%x %s] read %u bytes [offset=%u]\n", this, mStreamName.GetBuffer(), total, mOffset)); - if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND) - && (mTransferAmount >= 0)) { +// what about check for background flags! dougt + if (mProgress && (mTransferAmount >= 0)) { mProgress->OnProgress(this, mContext, mTotalAmount - mTransferAmount, mTotalAmount); @@ -704,7 +753,8 @@ nsFileTransport::Process(void) mListener->OnStopRequest(this, mContext, mStatus, nsnull); mListener = 0; } - if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND)) { +// what about check for background flag! dougt + if (mProgress) { nsAutoString fileName; fileName.AssignWithConversion(mStreamName); mProgress->OnStatus(this, mContext, @@ -714,10 +764,8 @@ nsFileTransport::Process(void) mContext = 0; // close the data source - mSource = 0; NS_IF_RELEASE(mSourceWrapper); mSourceWrapper = nsnull; - mXferState = CLOSING; break; } @@ -843,9 +891,8 @@ nsFileTransport::Process(void) else LOG(("nsFileTransport: WRITING [this=%x %s] wrote %u bytes [offset=%u]\n", this, mStreamName.GetBuffer(), total, mOffset)); - - if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND) - && (mTransferAmount >= 0)) +// what about check for background flag dougt! + if (mProgress && (mTransferAmount >= 0)) mProgress->OnProgress(this, mContext, mTotalAmount - mTransferAmount, mTotalAmount); @@ -875,16 +922,15 @@ nsFileTransport::Process(void) NS_IF_RELEASE(mSinkWrapper); mSinkWrapper = nsnull; - nsresult rv; if (mProvider) { mProvider->OnStopRequest(this, mContext, mStatus, nsnull); mProvider = 0; } - if (mProgress && !(mLoadAttributes & LOAD_BACKGROUND)) { + if (mProgress) { nsAutoString fileName; fileName.AssignWithConversion(mStreamName); - rv = mProgress->OnStatus(this, mContext, - NS_NET_STATUS_WROTE_TO, - fileName.GetUnicode()); + nsresult rv = mProgress->OnStatus(this, mContext, + NS_NET_STATUS_WROTE_TO, + fileName.GetUnicode()); NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnStatus failure"); } mContext = 0; @@ -924,234 +970,6 @@ nsFileTransport::DoClose(void) PR_AtomicDecrement(&mService->mConnectedTransports); } -//////////////////////////////////////////////////////////////////////////////// -// other nsIChannel methods: -//////////////////////////////////////////////////////////////////////////////// - -NS_IMETHODIMP -nsFileTransport::GetOriginalURI(nsIURI* *aURI) -{ - NS_NOTREACHED("GetOriginalURI"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::SetOriginalURI(nsIURI* aURI) -{ - NS_NOTREACHED("SetOriginalURI"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::GetURI(nsIURI* *aURI) -{ -// NS_NOTREACHED("GetURI"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::SetURI(nsIURI* aURI) -{ - NS_NOTREACHED("SetURI"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::GetLoadAttributes(nsLoadFlags *aLoadAttributes) -{ - *aLoadAttributes = mLoadAttributes; - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::SetLoadAttributes(nsLoadFlags aLoadAttributes) -{ - mLoadAttributes = aLoadAttributes; - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::GetContentType(char * *aContentType) -{ - *aContentType = nsCRT::strdup(mContentType); - if (*aContentType == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::SetContentType(const char *aContentType) -{ - if (mContentType) { - nsCRT::free(mContentType); - } - mContentType = nsCRT::strdup(aContentType); - if (!mContentType) return NS_ERROR_OUT_OF_MEMORY; - - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::GetContentLength(PRInt32 *aContentLength) -{ - *aContentLength = mTotalAmount; - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::SetContentLength(PRInt32 aContentLength) -{ - NS_NOTREACHED("SetContentLength"); - 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) -{ - NS_NOTREACHED("GetOwner"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::SetOwner(nsISupports * aOwner) -{ - NS_NOTREACHED("SetOwner"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup) -{ - NS_NOTREACHED("GetLoadGroup"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::SetLoadGroup(nsILoadGroup* aLoadGroup) -{ - NS_NOTREACHED("SetLoadGroup"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFileTransport::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) -{ - *aNotificationCallbacks = mCallbacks.get(); - NS_IF_ADDREF(*aNotificationCallbacks); - return NS_OK; -} - -NS_IMETHODIMP -nsFileTransport::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) -{ - mCallbacks = aNotificationCallbacks; - - // 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_FAILED(rv)) return NS_OK; // don't need a progress event sink - - // Now generate a proxied event sink - 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), - sink, - PROXY_ASYNC | PROXY_ALWAYS, - getter_AddRefs(mProgress)); - } - return NS_OK; -} - - NS_IMETHODIMP nsFileTransport::GetSecurityInfo(nsISupports * *aSecurityInfo) { @@ -1159,4 +977,34 @@ 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 2379cc97a3e..e7bc8e7decb 100644 --- a/mozilla/netwerk/base/src/nsFileTransport.h +++ b/mozilla/netwerk/base/src/nsFileTransport.h @@ -23,7 +23,8 @@ #ifndef nsFileTransport_h__ #define nsFileTransport_h__ -#include "nsIChannel.h" +#include "nsITransport.h" +#include "nsIRequest.h" #include "nsIRunnable.h" #include "nsFileSpec.h" #include "prlock.h" @@ -49,13 +50,15 @@ class nsIInterfaceRequestor; class nsFileTransportSourceWrapper; class nsFileTransportSinkWrapper; -class nsFileTransport : public nsIChannel, +class nsFileTransport : public nsITransport, + public nsITransportRequest, public nsIRunnable { public: NS_DECL_ISUPPORTS + NS_DECL_NSITRANSPORT NS_DECL_NSIREQUEST - NS_DECL_NSICHANNEL + NS_DECL_NSITRANSPORTREQUEST NS_DECL_NSIRUNNABLE nsFileTransport(); @@ -98,7 +101,6 @@ public: }; protected: - nsCOMPtr mCallbacks; nsCOMPtr mProgress; nsCOMPtr mStreamIO; char *mContentType; @@ -125,11 +127,9 @@ protected: PRUint32 mOffset; PRInt32 mTotalAmount; PRInt32 mTransferAmount; - nsLoadFlags mLoadAttributes; // reading state variables: nsCOMPtr mListener; - nsCOMPtr mSource; nsFileTransportSourceWrapper *mSourceWrapper; // writing state variables: diff --git a/mozilla/netwerk/base/src/nsFileTransportService.cpp b/mozilla/netwerk/base/src/nsFileTransportService.cpp index d2cfb5085b8..900b74fe645 100644 --- a/mozilla/netwerk/base/src/nsFileTransportService.cpp +++ b/mozilla/netwerk/base/src/nsFileTransportService.cpp @@ -59,7 +59,6 @@ nsFileTransportService::Init() nsFileTransportService::~nsFileTransportService() { - mPool->Shutdown(); } NS_IMPL_THREADSAFE_ISUPPORTS1(nsFileTransportService, nsFileTransportService); @@ -88,7 +87,7 @@ NS_IMETHODIMP nsFileTransportService::CreateTransport(nsIFile* file, PRInt32 ioFlags, PRInt32 perm, - nsIChannel** result) + nsITransport** result) { nsresult rv; nsFileTransport* trans = new nsFileTransport(); @@ -109,7 +108,7 @@ nsFileTransportService::CreateTransportFromStream(const char* name, nsIInputStream *fromStream, const char* contentType, PRInt32 contentLength, - nsIChannel** result) + nsITransport** result) { nsresult rv; nsFileTransport* trans = new nsFileTransport(); @@ -127,7 +126,7 @@ nsFileTransportService::CreateTransportFromStream(const char* name, NS_IMETHODIMP nsFileTransportService::CreateTransportFromStreamIO(nsIStreamIO *io, - nsIChannel **result) + nsITransport **result) { nsresult rv; nsFileTransport* trans = new nsFileTransport(); @@ -152,6 +151,17 @@ nsFileTransportService::ProcessPendingRequests(void) nsresult nsFileTransportService::Shutdown(void) { + PRUint32 count; + mSuspendedTransportList.Count(&count); + + for (PRUint32 i=0; i supports; + mSuspendedTransportList.GetElementAt(i, getter_AddRefs(supports)); + nsCOMPtr trans = do_QueryInterface(supports); + trans->Cancel(NS_BINDING_ABORTED); + } + + mSuspendedTransportList.Clear(); return mPool->Shutdown(); } @@ -162,6 +172,19 @@ nsFileTransportService::DispatchRequest(nsIRunnable* runnable) } //////////////////////////////////////////////////////////////////////////////// +nsresult +nsFileTransportService::AddSuspendedTransport(nsITransport* trans) +{ + mSuspendedTransportList.AppendElement(trans); + return NS_OK; +} + +nsresult +nsFileTransportService::RemoveSuspendedTransport(nsITransport* trans) +{ + mSuspendedTransportList.RemoveElement(trans); + return NS_OK; +} NS_IMETHODIMP nsFileTransportService::GetTotalTransportCount (PRUint32 * o_TransCount) diff --git a/mozilla/netwerk/base/src/nsFileTransportService.h b/mozilla/netwerk/base/src/nsFileTransportService.h index c1dedadb3f6..d74d4006f55 100644 --- a/mozilla/netwerk/base/src/nsFileTransportService.h +++ b/mozilla/netwerk/base/src/nsFileTransportService.h @@ -25,7 +25,7 @@ #include "nsIFileTransportService.h" #include "nsIThreadPool.h" -#include "nsISupportsArray.h" +#include "nsSupportsArray.h" #define NS_FILE_TRANSPORT_WORKER_COUNT_MIN 1 #define NS_FILE_TRANSPORT_WORKER_COUNT_MAX 4//16 @@ -49,6 +49,11 @@ public: PRInt32 mTotalTransports; PRInt32 mInUseTransports; + nsresult AddSuspendedTransport(nsITransport* trans); + nsresult RemoveSuspendedTransport(nsITransport* trans); + + nsSupportsArray mSuspendedTransportList; + protected: nsCOMPtr mPool; }; diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index e5c5c8aba94..22262939c5a 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -54,6 +54,14 @@ nsresult nsIOService::Init() { nsresult rv = NS_OK; + + // Hold onto the eventQueue service. We do not want any eventqueues to go away + // when we shutdown until we process all remaining transports + + if (NS_SUCCEEDED(rv)) + mEventQueueService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv); + + // We need to get references to these services so that we can shut them // down later. If we wait until the nsIOService is being shut down, // GetService will fail at that point. @@ -98,7 +106,9 @@ nsIOService::Init() nsIOService::~nsIOService() { (void)SetOffline(PR_TRUE); -} + if (mFileTransportService) + (void)mFileTransportService->Shutdown(); +} NS_METHOD nsIOService::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) @@ -368,40 +378,6 @@ 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/nsIOService.h b/mozilla/netwerk/base/src/nsIOService.h index d117df8d75a..6bca79c2254 100644 --- a/mozilla/netwerk/base/src/nsIOService.h +++ b/mozilla/netwerk/base/src/nsIOService.h @@ -31,6 +31,7 @@ #include "nsCOMPtr.h" #include "nsURLHelper.h" #include "nsWeakPtr.h" +#include "nsIEventQueueService.h" #define NS_N(x) (sizeof(x)/sizeof(*x)) @@ -66,6 +67,7 @@ protected: nsCOMPtr mSocketTransportService; nsCOMPtr mFileTransportService; nsCOMPtr mDNSService; + nsCOMPtr mEventQueueService; // Cached protocol handlers nsWeakPtr mWeakHandler[NS_N(gScheme)]; diff --git a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp index c8ddef50f25..591fece8403 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp @@ -170,9 +170,6 @@ 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) @@ -183,8 +180,8 @@ NS_INTERFACE_MAP_BEGIN(nsStreamIOChannel) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener) NS_INTERFACE_MAP_END_THREADSAFE -//////////////////////////////////////////////////////////////////////////////// -// nsIRequest methods: +NS_IMPL_THREADSAFE_ADDREF(nsStreamIOChannel) +NS_IMPL_THREADSAFE_RELEASE(nsStreamIOChannel) NS_IMETHODIMP nsStreamIOChannel::GetName(PRUnichar* *result) @@ -202,8 +199,8 @@ nsStreamIOChannel::GetName(PRUnichar* *result) NS_IMETHODIMP nsStreamIOChannel::IsPending(PRBool *result) { - if (mFileTransport) - return mFileTransport->IsPending(result); + if (mRequest) + return mRequest->IsPending(result); *result = PR_FALSE; return NS_OK; } @@ -215,8 +212,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) && mFileTransport) - mFileTransport->GetStatus(status); + if (NS_SUCCEEDED(mStatus) && mRequest) + mRequest->GetStatus(status); return NS_OK; } @@ -226,29 +223,30 @@ nsStreamIOChannel::Cancel(nsresult status) { NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code"); mStatus = status; - if (mFileTransport) - return mFileTransport->Cancel(status); + if (mRequest) + return mRequest->Cancel(status); return NS_OK; } NS_IMETHODIMP nsStreamIOChannel::Suspend(void) { - if (mFileTransport) - return mFileTransport->Suspend(); + if (mRequest) + return mRequest->Suspend(); return NS_OK; } NS_IMETHODIMP nsStreamIOChannel::Resume(void) { - if (mFileTransport) - return mFileTransport->Resume(); + if (mRequest) + return mRequest->Resume(); return NS_OK; } //////////////////////////////////////////////////////////////////////////////// -// nsIChannel methods: +// nsIChannel implementation: +//////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsStreamIOChannel::GetOriginalURI(nsIURI* *aURI) @@ -281,19 +279,13 @@ nsStreamIOChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsStreamIOChannel::OpenInputStream(nsIInputStream **result) +nsStreamIOChannel::Open(nsIInputStream **result) { return mStreamIO->GetInputStream(result); } NS_IMETHODIMP -nsStreamIOChannel::OpenOutputStream(nsIOutputStream **result) -{ - return mStreamIO->GetOutputStream(result); -} - -NS_IMETHODIMP -nsStreamIOChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +nsStreamIOChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; @@ -315,7 +307,7 @@ nsStreamIOChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) } } - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -325,14 +317,6 @@ nsStreamIOChannel::AsyncRead(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 @@ -341,78 +325,13 @@ nsStreamIOChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) if (NS_FAILED(rv)) goto done; } #endif - rv = mFileTransport->AsyncRead(this, ctxt); + rv = mFileTransport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(mRequest)); 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; - } - 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"); + rv2 = mLoadGroup->RemoveRequest(this, ctxt, rv, nsnull); + NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveRequest failed"); // release the transport so that we don't think we're in progress mFileTransport = nsnull; } @@ -433,127 +352,6 @@ nsStreamIOChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes) return NS_OK; } -NS_IMETHODIMP -nsStreamIOChannel::GetContentType(char * *aContentType) -{ - nsresult rv; - if (mContentType == nsnull) { - rv = mStreamIO->Open(&mContentType, &mContentLength); - if (NS_FAILED(rv)) return rv; - } - *aContentType = nsCRT::strdup(mContentType); - if (*aContentType == nsnull) { - return NS_ERROR_OUT_OF_MEMORY; - } - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::SetContentType(const char *aContentType) -{ - mContentType = nsCRT::strdup(aContentType); - if (*aContentType == nsnull) { - return NS_ERROR_OUT_OF_MEMORY; - } - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::GetContentLength(PRInt32 *aContentLength) -{ - nsresult rv; - if (mContentType == nsnull) { - rv = mStreamIO->Open(&mContentType, &mContentLength); - if (NS_FAILED(rv)) return rv; - } - *aContentLength = mContentLength; - return NS_OK; -} - -NS_IMETHODIMP -nsStreamIOChannel::SetContentLength(PRInt32 aContentLength) -{ - mContentLength = 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) { @@ -599,7 +397,6 @@ nsStreamIOChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification return NS_OK; } - NS_IMETHODIMP nsStreamIOChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { @@ -607,19 +404,63 @@ nsStreamIOChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) return NS_OK; } +NS_IMETHODIMP +nsStreamIOChannel::GetContentType(char * *aContentType) +{ + nsresult rv; + if (mContentType == nsnull) { + rv = mStreamIO->Open(&mContentType, &mContentLength); + if (NS_FAILED(rv)) return rv; + } + *aContentType = nsCRT::strdup(mContentType); + if (*aContentType == nsnull) { + return NS_ERROR_OUT_OF_MEMORY; + } + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetContentType(const char *aContentType) +{ + mContentType = nsCRT::strdup(aContentType); + if (*aContentType == nsnull) { + return NS_ERROR_OUT_OF_MEMORY; + } + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::GetContentLength(PRInt32 *aContentLength) +{ + nsresult rv; + if (mContentType == nsnull) { + rv = mStreamIO->Open(&mContentType, &mContentLength); + if (NS_FAILED(rv)) return rv; + } + *aContentLength = mContentLength; + return NS_OK; +} + +NS_IMETHODIMP +nsStreamIOChannel::SetContentLength(PRInt32 aContentLength) +{ + mContentLength = aContentLength; + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // nsIStreamObserver implementation: //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsStreamIOChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) +nsStreamIOChannel::OnStartRequest(nsIRequest *request, nsISupports* context) { NS_ASSERTION(mUserObserver, "No listener..."); return mUserObserver->OnStartRequest(this, context); } NS_IMETHODIMP -nsStreamIOChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, +nsStreamIOChannel::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -631,7 +472,7 @@ nsStreamIOChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* cont if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - rv = mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); + rv = mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } } @@ -648,7 +489,7 @@ nsStreamIOChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* cont //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsStreamIOChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, +nsStreamIOChannel::OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -661,9 +502,9 @@ nsStreamIOChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* co //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsStreamIOChannel::OnDataWritable(nsIChannel* transportChannel, nsISupports* context, - nsIOutputStream *aOStream, PRUint32 aOffset, - PRUint32 aLength) +nsStreamIOChannel::OnDataWritable(nsIRequest *request, 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 8b1c5ec4c64..d94d375dd8b 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.h +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.h @@ -32,6 +32,7 @@ #include "nsIStreamProvider.h" #include "nsIInterfaceRequestor.h" #include "nsIStreamIO.h" +#include "nsITransport.h" class nsInputStreamIO : public nsIInputStreamIO { @@ -90,7 +91,8 @@ protected: nsCOMPtr mStreamIO; nsCOMPtr mLoadGroup; nsCOMPtr mOwner; - nsCOMPtr mFileTransport; + nsCOMPtr mFileTransport; + nsCOMPtr mRequest; nsCOMPtr mUserObserver; PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; diff --git a/mozilla/netwerk/base/src/nsLoadGroup.cpp b/mozilla/netwerk/base/src/nsLoadGroup.cpp index 6495691439e..f300db78719 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), - mChannels(nsnull), + mRequests(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(mChannels); - mDefaultLoadChannel = null_nsCOMPtr(); + NS_IF_RELEASE(mRequests); + mDefaultLoadRequest = 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(&mChannels); + return NS_NewISupportsArray(&mRequests); } @@ -157,19 +157,20 @@ NS_IMETHODIMP nsLoadGroup::GetName(PRUnichar* *result) { // XXX is this the right "name" for a load group? - 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; + *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; + } } - nsString name; - name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); - return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + + return NS_OK; } NS_IMETHODIMP @@ -187,9 +188,9 @@ nsLoadGroup::IsPending(PRBool *aResult) NS_IMETHODIMP nsLoadGroup::GetStatus(nsresult *status) { - if (NS_SUCCEEDED(mStatus) && mDefaultLoadChannel) - return mDefaultLoadChannel->GetStatus(status); - + if (NS_SUCCEEDED(mStatus) && mDefaultLoadRequest) + return mDefaultLoadRequest->GetStatus(status); + *status = mStatus; return NS_OK; } @@ -206,67 +207,57 @@ nsLoadGroup::Cancel(nsresult status) mStatus = status; - rv = mChannels->Count(&count); + rv = mRequests->Count(&count); if (NS_FAILED(rv)) return rv; firstError = NS_OK; if (count) { - nsIChannel* channel; + nsIRequest* request; // // 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) { - channel = NS_STATIC_CAST(nsIChannel*, mChannels->ElementAt(--count)); + request = NS_STATIC_CAST(nsIRequest*, mRequests->ElementAt(--count)); - NS_ASSERTION(channel, "NULL channel found in list."); - if (!channel) { + NS_ASSERTION(request, "NULL request found in list."); + if (!request) { continue; } #if defined(PR_LOGGING) - 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("?"); - } - + nsXPIDLString nameStr; + request->GetName(getter_Copies(nameStr)); PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Canceling channel %x %s.\n", - this, channel, uriStr)); - nsCRT::free(uriStr); + ("LOADGROUP [%x]: Canceling request %x %s.\n", + this, request, NS_ConvertUCS2toUTF8(nameStr).get())); #endif /* PR_LOGGING */ // - // Remove the channel from the load group... This may cause + // Remove the request from the load group... This may cause // the OnStopRequest notification to fire... // // XXX: What should the context and error message be? // - (void)RemoveChannel(channel, nsnull, status, nsnull); + (void)RemoveRequest(request, nsnull, status, nsnull); - // Cancel the channel... - rv = channel->Cancel(status); + // Cancel the request... + rv = request->Cancel(status); // Remember the first failure and return it... if (NS_FAILED(rv) && NS_SUCCEEDED(firstError)) { firstError = rv; } - NS_RELEASE(channel); + NS_RELEASE(request); } #if defined(DEBUG) - (void)mChannels->Count(&count); + (void)mRequests->Count(&count); - NS_ASSERTION(count == 0, "Channel list is not empty."); + NS_ASSERTION(count == 0, "Request list is not empty."); NS_ASSERTION(mForegroundCount == 0, "Foreground URLs are active."); #endif /* DEBUG */ } @@ -282,7 +273,7 @@ nsLoadGroup::Suspend() nsresult rv, firstError; PRUint32 count; - rv = mChannels->Count(&count); + rv = mRequests->Count(&count); if (NS_FAILED(rv)) return rv; firstError = NS_OK; @@ -291,42 +282,30 @@ nsLoadGroup::Suspend() // get removed from the list it won't affect our iteration // while (count > 0) { - nsIChannel* channel; + nsIRequest* request = NS_STATIC_CAST(nsIRequest*, mRequests->ElementAt(--count)); - channel = NS_STATIC_CAST(nsIChannel*, mChannels->ElementAt(--count)); - - NS_ASSERTION(channel, "NULL channel found in list."); - if (!channel) { + NS_ASSERTION(request, "NULL request found in list."); + if (!request) { continue; } #if defined(PR_LOGGING) - 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); + 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())); #endif /* PR_LOGGING */ - // Suspend the channel... - rv = channel->Suspend(); + // Suspend the request... + rv = request->Suspend(); // Remember the first failure and return it... if (NS_FAILED(rv) && NS_SUCCEEDED(firstError)) { firstError = rv; } - NS_RELEASE(channel); + NS_RELEASE(request); } return firstError; @@ -339,7 +318,7 @@ nsLoadGroup::Resume() nsresult rv, firstError; PRUint32 count; - rv = mChannels->Count(&count); + rv = mRequests->Count(&count); if (NS_FAILED(rv)) return rv; firstError = NS_OK; @@ -348,42 +327,30 @@ nsLoadGroup::Resume() // get removed from the list it won't affect our iteration // while (count > 0) { - nsIChannel* channel; + nsIRequest* request = NS_STATIC_CAST(nsIRequest*, mRequests->ElementAt(--count)); - channel = NS_STATIC_CAST(nsIChannel*, mChannels->ElementAt(--count)); - - NS_ASSERTION(channel, "NULL channel found in list."); - if (!channel) { + NS_ASSERTION(request, "NULL request found in list."); + if (!request) { continue; } #if defined(PR_LOGGING) - 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("?"); - } - + nsXPIDLString nameStr; + request->GetName(getter_Copies(nameStr)); PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Resuming channel %x %s.\n", - this, channel, uriStr)); - nsCRT::free(uriStr); + ("LOADGROUP [%x]: Resuming request %x %s.\n", + this, request, NS_ConvertUCS2toUTF8(nameStr).get())); #endif /* PR_LOGGING */ - // Resume the channel... - rv = channel->Resume(); + // Resume the request... + rv = request->Resume(); // Remember the first failure and return it... if (NS_FAILED(rv) && NS_SUCCEEDED(firstError)) { firstError = rv; } - NS_RELEASE(channel); + NS_RELEASE(request); } return firstError; @@ -417,58 +384,46 @@ nsLoadGroup::SetDefaultLoadAttributes(PRUint32 aDefaultLoadAttributes) } NS_IMETHODIMP -nsLoadGroup::GetDefaultLoadChannel(nsIChannel * *aChannel) +nsLoadGroup::GetDefaultLoadRequest(nsIRequest * *aRequest) { - *aChannel = mDefaultLoadChannel; - NS_IF_ADDREF(*aChannel); + *aRequest = mDefaultLoadRequest; + NS_IF_ADDREF(*aRequest); return NS_OK; } NS_IMETHODIMP -nsLoadGroup::SetDefaultLoadChannel(nsIChannel *aChannel) +nsLoadGroup::SetDefaultLoadRequest(nsIRequest *aRequest) { - mDefaultLoadChannel = aChannel; + mDefaultLoadRequest = aRequest; return NS_OK; } NS_IMETHODIMP -nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt) +nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) { nsresult rv; #if defined(PR_LOGGING) - { - 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); + PRUint32 count = 0; + (void)mRequests->Count(&count); + nsXPIDLString nameStr; + request->GetName(getter_Copies(nameStr)); PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Adding channel %x %s (count=%d).\n", - this, channel, uriStr, count)); - nsCRT::free(uriStr); - } + ("LOADGROUP [%x]: Adding request %x %s (count=%d).\n", + this, request, NS_ConvertUCS2toUTF8(nameStr).get(), count)); #endif /* PR_LOGGING */ nsLoadFlags flags; - - MergeLoadAttributes(channel); - - rv = channel->GetLoadAttributes(&flags); + rv = MergeLoadAttributes(request, flags); if (NS_FAILED(rv)) return rv; - + // - // Add the channel to the list of active channels... + // Add the request to the list of active requests... // // XXX this method incorrectly returns a bool // - rv = mChannels->AppendElement(channel) ? NS_OK : NS_ERROR_FAILURE; + rv = mRequests->AppendElement(request) ? NS_OK : NS_ERROR_FAILURE; if (NS_FAILED(rv)) return rv; if (!(flags & nsIChannel::LOAD_BACKGROUND)) { @@ -478,28 +433,28 @@ nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt) // // Fire the OnStartRequest notification out to the observer... // - // If the notification fails then DO NOT add the channel to + // If the notification fails then DO NOT add the request to // the load group. // nsCOMPtr observer (do_QueryReferent(mObserver)); if (observer) { PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Firing OnStartRequest for channel %x." + ("LOADGROUP [%x]: Firing OnStartRequest for request %x." "(foreground count=%d).\n", - this, channel, mForegroundCount)); + this, request, mForegroundCount)); - rv = observer->OnStartRequest(channel, ctxt); + rv = observer->OnStartRequest(request, ctxt); if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, - ("LOADGROUP [%x]: OnStartRequest for channel %x FAILED.\n", - this, channel)); + ("LOADGROUP [%x]: OnStartRequest for request %x FAILED.\n", + this, request)); // // The URI load has been canceled by the observer. Clean up // the damage... // // XXX this method incorrectly returns a bool // - rv = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; + rv = mRequests->RemoveElement(request) ? NS_OK : NS_ERROR_FAILURE; mForegroundCount -= 1; } } @@ -509,56 +464,43 @@ nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt) } NS_IMETHODIMP -nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, +nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; #if defined(PR_LOGGING) - { - 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); - } + 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)); #endif /* PR_LOGGING */ // - // 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 + // 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 // count or it will get messed up... // // // XXX this method incorrectly returns a bool // - rv = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; + rv = mRequests->RemoveElement(request) ? NS_OK : NS_ERROR_FAILURE; if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, - ("LOADGROUP [%x]: Unable to remove channel %x. Not in group!\n", - this, channel)); + ("LOADGROUP [%x]: Unable to remove request %x. Not in group!\n", + this, request)); return rv; } nsLoadFlags flags; - rv = channel->GetLoadAttributes(&flags); + nsCOMPtr aChannel = do_QueryInterface(request, &rv); + if (NS_FAILED(rv)) + return NS_ERROR_FAILURE; + + rv = aChannel->GetLoadAttributes(&flags); if (NS_FAILED(rv)) return rv; if (!(flags & nsIChannel::LOAD_BACKGROUND)) { @@ -569,15 +511,15 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, nsCOMPtr observer (do_QueryReferent(mObserver)); if (observer) { PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, - ("LOADGROUP [%x]: Firing OnStopRequest for channel %x." + ("LOADGROUP [%x]: Firing OnStopRequest for request %x." "(foreground count=%d).\n", - this, channel, mForegroundCount)); + this, request, mForegroundCount)); - rv = observer->OnStopRequest(channel, ctxt, aStatus, aStatusArg); + rv = observer->OnStopRequest(request, ctxt, aStatus, aStatusArg); if (NS_FAILED(rv)) { PR_LOG(gLoadGroupLog, PR_LOG_ERROR, - ("LOADGROUP [%x]: OnStopRequest for channel %x FAILED.\n", - this, channel)); + ("LOADGROUP [%x]: OnStopRequest for request %x FAILED.\n", + this, request)); } } } @@ -588,9 +530,9 @@ nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt, NS_IMETHODIMP -nsLoadGroup::GetChannels(nsISimpleEnumerator * *aChannels) +nsLoadGroup::GetRequests(nsISimpleEnumerator * *aRequests) { - return NS_NewArrayEnumerator(aChannels, mChannels); + return NS_NewArrayEnumerator(aRequests, mRequests); } @@ -659,13 +601,18 @@ nsLoadGroup::GetActiveCount(PRUint32* aResult) //////////////////////////////////////////////////////////////////////////////// -nsresult nsLoadGroup::MergeLoadAttributes(nsIChannel *aChannel) +nsresult nsLoadGroup::MergeLoadAttributes(nsIRequest *aRequest, nsLoadFlags& outFlags) { 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; // @@ -707,6 +654,7 @@ nsresult nsLoadGroup::MergeLoadAttributes(nsIChannel *aChannel) 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 94adcc8e0a1..5c505c9de26 100644 --- a/mozilla/netwerk/base/src/nsLoadGroup.h +++ b/mozilla/netwerk/base/src/nsLoadGroup.h @@ -59,21 +59,20 @@ protected: virtual ~nsLoadGroup(); nsresult Init(); - nsresult MergeLoadAttributes(nsIChannel *aChannel); + nsresult MergeLoadAttributes(nsIRequest *aRequest, nsLoadFlags& flags); protected: PRUint32 mDefaultLoadAttributes; PRUint32 mForegroundCount; - nsISupportsArray* mChannels; + nsCOMPtr mDefaultLoadRequest; + nsISupportsArray* mRequests; - 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 e3a184edef2..2023970875f 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(nsIChannel *aChannel, +nsSimpleStreamListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { return mObserver ? - mObserver->OnStartRequest(aChannel, aContext) : NS_OK; + mObserver->OnStartRequest(aRequest, aContext) : NS_OK; } NS_IMETHODIMP -nsSimpleStreamListener::OnStopRequest(nsIChannel *aChannel, +nsSimpleStreamListener::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { return mObserver ? - mObserver->OnStopRequest(aChannel, aContext, aStatus, aStatusText) : NS_OK; + mObserver->OnStopRequest(request, aContext, aStatus, aStatusText) : NS_OK; } // @@ -61,7 +61,7 @@ nsSimpleStreamListener::OnStopRequest(nsIChannel *aChannel, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsSimpleStreamListener::OnDataAvailable(nsIChannel *aChannel, +nsSimpleStreamListener::OnDataAvailable(nsIRequest* request, nsISupports *aContext, nsIInputStream *aSource, PRUint32 aOffset, diff --git a/mozilla/netwerk/base/src/nsSimpleStreamProvider.cpp b/mozilla/netwerk/base/src/nsSimpleStreamProvider.cpp index 90c04f42076..f6d70794afd 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(nsIChannel *aChannel, +nsSimpleStreamProvider::OnStartRequest(nsIRequest *request, nsISupports *aContext) { return mObserver ? - mObserver->OnStartRequest(aChannel, aContext) : NS_OK; + mObserver->OnStartRequest(request, aContext) : NS_OK; } NS_IMETHODIMP -nsSimpleStreamProvider::OnStopRequest(nsIChannel *aChannel, +nsSimpleStreamProvider::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { return mObserver ? - mObserver->OnStopRequest(aChannel, aContext, aStatus, aStatusText) : NS_OK; + mObserver->OnStopRequest(request, aContext, aStatus, aStatusText) : NS_OK; } // @@ -62,7 +62,7 @@ nsSimpleStreamProvider::OnStopRequest(nsIChannel *aChannel, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsSimpleStreamProvider::OnDataWritable(nsIChannel *aChannel, +nsSimpleStreamProvider::OnDataWritable(nsIRequest *request, nsISupports *aContext, nsIOutputStream *aOutput, PRUint32 aOffset, diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index 93324c465ab..39cae589421 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -54,193 +54,6 @@ 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 @@ -310,14 +123,9 @@ 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), @@ -328,22 +136,21 @@ 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), - mWasConnected (PR_FALSE) + mBIS(nsnull), + mBOS(nsnull), + mReadRequest(nsnull), + mWriteRequest(nsnull), + mCloseConnectionOnceDone(PR_FALSE), + mWasConnected(PR_FALSE) { NS_INIT_REFCNT(); @@ -381,20 +188,6 @@ 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... // @@ -404,8 +197,11 @@ nsSocketTransport::~nsSocketTransport() } CloseConnection(); - - NS_IF_RELEASE(mService); + + if (mService) { + PR_AtomicDecrement(&mService->mTotalTransports); + NS_RELEASE(mService); + } CRTFREEIF(mProxyHost); CRTFREEIF(mHostName); @@ -420,9 +216,6 @@ nsSocketTransport::~nsSocketTransport() nsAutoMonitor::DestroyMonitor(mMonitor); mMonitor = nsnull; } - - if (mService) - PR_AtomicDecrement(&mService->mTotalTransports); } @@ -463,10 +256,6 @@ 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) @@ -480,15 +269,6 @@ 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; @@ -529,7 +309,7 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, } -nsresult nsSocketTransport::CheckForTimeout (PRIntervalTime aCurrentTime) +nsresult nsSocketTransport::CheckForTimeout(PRIntervalTime aCurrentTime) { nsresult rv = NS_OK; PRIntervalTime idleInterval; @@ -537,26 +317,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; } @@ -578,53 +358,7 @@ 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... // @@ -644,35 +378,18 @@ 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 (GetReadType() != eSocketRead_None) { - // Set the select flags for non-blocking reads... - mSelectFlags |= PR_POLL_READ; - - // Fire a notification that the read has started... - if (mReadListener && !mOnStartReadFired) { - mOnStartReadFired = PR_TRUE; - mReadListener->OnStartRequest(this, mReadContext); - } - } - - if (GetWriteType() != eSocketWrite_None) { - // Set the select flags for non-blocking writes... - mSelectFlags |= PR_POLL_WRITE; - - // Fire a notification that the write has started... - if (mWriteProvider && !mOnStartWriteFired) { - mOnStartWriteFired = PR_TRUE; - mWriteProvider->OnStartRequest(this, mWriteContext); - } - } break; case eSocketState_Error: @@ -685,11 +402,13 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) mDNSRequest = 0; } - // Cancel any read and/or write requests... - SetFlag(eSocketRead_Done); - SetFlag(eSocketWrite_Done); + // Set the error status on the request(s) + if (mReadRequest) + mReadRequest->SetStatus(mStatus); + if (mWriteRequest) + mWriteRequest->SetStatus(mStatus); - CloseConnection(); + mCloseConnectionOnceDone = PR_TRUE; // // Fall into the Done state... @@ -698,136 +417,45 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) LOG(("nsSocketTransport: Transport [host=%s:%d this=%x] is in Done state.\n", mHostName, mPort, this)); - mBytesExpected = -1; + if (mReadRequest) + CompleteAsyncRead(); - 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; - } + if (mWriteRequest) + CompleteAsyncWrite(); - if (mSocketInputStream) { - NS_RELEASE(mSocketInputStream); - mSocketInputStream = 0; - } + // Close connection if expected to do so... + if (mCloseConnectionOnceDone) + CloseConnection(); - // 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; - } + mCurrentState = gStateTable[mOperation][mCurrentState]; + mOperation = eSocketOperation_None; + mStatus = NS_OK; + done = PR_TRUE; 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)); - // 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); - } + mStatus = doReadWrite(aSelectFlags); break; case eSocketState_Timeout: @@ -842,10 +470,6 @@ 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... @@ -865,13 +489,60 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags) mLastActiveTime = PR_IntervalNow(); LOG(("nsSocketTransport: Leaving Process() [host=%s:%d this=%x], mStatus = %x, " - "CurrentState=%d\n\n", - mHostName, mPort, this, mStatus, mCurrentState)); + "CurrentState=%d, mSelectFlags=%x\n\n", + mHostName, mPort, this, mStatus, mCurrentState, mSelectFlags)); 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; +} //----- // @@ -1035,21 +706,16 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags) if (!NS_SUCCEEDED(rv) || !mSocketFD) break; - // if the service was ssl, we want to hold onto the socket info + // if the service was ssl or tls, 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 @@ -1133,7 +799,11 @@ 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; } // @@ -1163,492 +833,189 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags) return rv; } - -typedef struct { - PRFileDesc *fd; - PRBool bEOF; -} nsReadFromSocketClosure; - - -static NS_METHOD -nsReadFromSocket(nsIOutputStream* out, - void* closure, - char* toRawSegment, - PRUint32 offset, - PRUint32 count, - PRUint32 *readCount) +nsresult +nsSocketTransport::doBlockingConnection() { nsresult rv = NS_OK; - PRInt32 len; - nsReadFromSocketClosure *info = (nsReadFromSocketClosure*)closure; - 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; - } + // + // 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))); } - LOG(("nsSocketTransport: nsReadFromSocket [fd=%x]. rv = %x. Buffer space = %d. Bytes read =%d\n", - info->fd, rv, count, *readCount)); + // + // 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; + } + } + while (rv == NS_BASE_STREAM_WOULD_BLOCK); + } + mCurrentState = eSocketState_Connected; + } return rv; } -static NS_METHOD -nsWriteToSocket(nsIInputStream* in, - void* closure, - const char* fromRawSegment, - PRUint32 toOffset, - PRUint32 count, - PRUint32 *writeCount) +nsresult +nsSocketTransport::doReadWrite(PRInt16 aSelectFlags) { - nsresult rv = NS_OK; - PRInt32 len; - PRFileDesc* fd = (PRFileDesc*)closure; + nsresult readStatus = NS_OK, writeStatus = NS_OK; - *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; - } - } + 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; } - - LOG(("nsSocketTransport: nsWriteToSocket [fd=%x]. rv = %x. Buffer space = %d. Bytes written =%d\n", - fd, rv, count, *writeCount)); - - 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; + if (PR_POLL_ERR & aSelectFlags) { + LOG(("nsSocketTransport: [this=%x] received PR_POLL_ERR\n", this)); + return NS_BINDING_FAILED; } - - if (!mSocketInputStream) { - NS_NEWXPCOM(mSocketInputStream, nsSocketInputStream); - if (!mSocketInputStream) - return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(mSocketInputStream); - mSocketInputStream->SetSocketFD(mSocketFD); + if (PR_POLL_HUP & aSelectFlags) { + LOG(("nsSocketTransport: [this=%x] received PR_POLL_HUP\n", this)); + return NS_OK; } - 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); - // - // Handle the error conditions + // Process the read request... // - 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; - - if ((0 == total) && !mSocketInputStream->GotWouldBlock()) { - LOG(("nsSocketTransport: READING [this=%x] done reading socket.\n", this)); + if (mReadRequest) { + if (mReadRequest->IsCanceled() || (mBytesExpected == 0)) { + LOG(("nsSocketTransport: [this=%x] completing read request due to cancelation\n", this)); mSelectFlags &= ~PR_POLL_READ; + CompleteAsyncRead(); } - else { - LOG(("nsSocketTransport: READING [this=%x] read %u bytes [offset=%u]\n", - this, total, mReadOffset)); + else if (mSelectFlags & PR_POLL_READ) { // - // Stay in the read state + // Read data if available // - rv = NS_BASE_STREAM_WOULD_BLOCK; + if (aSelectFlags & PR_POLL_READ) { + readStatus = mReadRequest->OnRead(); + if (mReadRequest->IsSuspended()) { + mSelectFlags &= ~PR_POLL_READ; + readStatus = NS_BASE_STREAM_WOULD_BLOCK; + } + else if (NS_SUCCEEDED(readStatus)) + CompleteAsyncRead(); + else if (NS_FAILED(readStatus) && (readStatus != NS_BASE_STREAM_WOULD_BLOCK)) + return readStatus; // this must be a socket error, so bail! + } + else + readStatus = 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 (!mReadRequest->IsInitialized()) { + mSelectFlags |= PR_POLL_READ; + mReadRequest->OnStart(); + mReadRequest->SetSocket(mSocketFD); + readStatus = NS_BASE_STREAM_WOULD_BLOCK; } } - 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)); + // + // Process the write request... + // + if (mWriteRequest) { + if (mWriteRequest->IsCanceled()) { + LOG(("nsSocketTransport: [this=%x] completing write request due to cancelation\n", this)); mSelectFlags &= ~PR_POLL_WRITE; + CompleteAsyncWrite(); } - else { - LOG(("nsSocketTransport: WRITING [this=%x] wrote %u bytes [offset=%u]\n", - this, total, mWriteOffset)); + else if (mSelectFlags & PR_POLL_WRITE) { // - // Stay in the write state + // Write data if possible // - rv = NS_BASE_STREAM_WOULD_BLOCK; + if (aSelectFlags & PR_POLL_WRITE) { + writeStatus = mWriteRequest->OnWrite(); + 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; // this must be a socket error, so bail! + } + else + writeStatus = 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; + else if (!mWriteRequest->IsInitialized()) { + mSelectFlags |= PR_POLL_WRITE; + mWriteRequest->OnStart(); + mWriteRequest->SetSocket(mSocketFD); + writeStatus = NS_BASE_STREAM_WOULD_BLOCK; } - 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)); + 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 (!(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); + // If both requests successfully completed then move to the "done" state. + if (NS_SUCCEEDED(readStatus) && NS_SUCCEEDED(writeStatus)) + return NS_OK; - 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; + // Else remain in the same state + return NS_BASE_STREAM_WOULD_BLOCK; } nsresult nsSocketTransport::CloseConnection(PRBool bNow) @@ -1666,7 +1033,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; @@ -1691,12 +1058,9 @@ nsresult nsSocketTransport::CloseConnection(PRBool bNow) // -------------------------------------------------------------------------- // -NS_IMPL_THREADSAFE_ISUPPORTS6(nsSocketTransport, - nsIChannel, - nsIRequest, +NS_IMPL_THREADSAFE_ISUPPORTS3(nsSocketTransport, + nsITransport, nsIDNSListener, - nsIInputStreamObserver, - nsIOutputStreamObserver, nsISocketTransport); // @@ -1704,6 +1068,25 @@ NS_IMPL_THREADSAFE_ISUPPORTS6(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) { @@ -1773,15 +1156,43 @@ nsSocketTransport::GetSecurityInfo(nsISupports **info) return NS_OK; } - -// -// -------------------------------------------------------------------------- -// nsIRequest implementation... -// -------------------------------------------------------------------------- -// +NS_IMETHODIMP +nsSocketTransport::GetProgressEventSink(nsIProgressEventSink **aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + NS_ADDREF(*aResult = mEventSink); + return NS_OK; +} NS_IMETHODIMP -nsSocketTransport::GetName(PRUnichar* *result) +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... +// -------------------------------------------------------------------------- +// + +nsresult +nsSocketTransport::GetName(PRUnichar **result) { nsString name; name.AppendWithConversion(mHostName); @@ -1791,218 +1202,39 @@ nsSocketTransport::GetName(PRUnichar* *result) return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } -NS_IMETHODIMP -nsSocketTransport::IsPending(PRBool *result) +nsresult +nsSocketTransport::Dispatch(nsSocketRequest *req) { - *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); - mCancelStatus = status; - - // A cancelled transport cannot be suspended. - mSuspendCount = 0; + if (req == mReadRequest) + mSelectFlags |= PR_POLL_READ; + else + mSelectFlags |= PR_POLL_WRITE; // // Wake up the transport on the socket transport thread so it can - // be removed from the select list... + // be resumed... // - mLastActiveTime = PR_IntervalNow (); + mLastActiveTime = PR_IntervalNow(); rv = mService->AddToWorkQ(this); - LOG(("nsSocketTransport: Canceling [%s:%d %x]. rv = %x\n", + LOG(("nsSocketTransport: Resuming [%s:%d %x]. rv = %x\t", mHostName, mPort, this, rv)); return rv; } -NS_IMETHODIMP -nsSocketTransport::Suspend(void) +nsresult +nsSocketTransport::OnProgress(nsSocketRequest *req, nsISupports *ctx, PRUint32 offset) { - // 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) -{ + if (mEventSink) + // we don't have content length info at the socket level + // just pass 0 through. + mEventSink->OnProgress(req, ctx, offset, 0); return NS_OK; } @@ -2028,9 +1260,6 @@ 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) @@ -2038,6 +1267,7 @@ 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", @@ -2091,55 +1321,19 @@ nsSocketTransport::OnStopLookup(nsISupports *aContext, // // -------------------------------------------------------------------------- -// nsIChannel implementation... +// nsITransport 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) + nsISupports* aContext, + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 aFlags, + nsIRequest **aRequest) { + NS_ENSURE_ARG_POINTER(aRequest); nsresult rv = NS_OK; // Enter the socket transport lock... @@ -2148,39 +1342,55 @@ 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; - if (NS_SUCCEEDED(rv)) { - mReadContext = aContext; - mOnStartReadFired = PR_FALSE; - // Create a stream listener proxy to receive notifications... - rv = NS_NewStreamListenerProxy(getter_AddRefs(mReadListener), + nsCOMPtr listener; + + if (NS_SUCCEEDED(rv)) + rv = NS_NewStreamListenerProxy(getter_AddRefs(listener), 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) + nsISupports* aContext, + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 aFlags, + nsIRequest **aRequest) { + NS_ENSURE_ARG_POINTER(aRequest); nsresult rv = NS_OK; // Enter the socket transport lock... @@ -2192,17 +1402,26 @@ nsSocketTransport::AsyncWrite(nsIStreamProvider* aProvider, // If a write is already in progress then fail... if (GetWriteType() != eSocketWrite_None) rv = NS_ERROR_IN_PROGRESS; - - if (NS_SUCCEEDED(rv)) { - 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); + 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); } + else + rv = NS_ERROR_OUT_OF_MEMORY; } if (NS_SUCCEEDED(rv)) { @@ -2216,13 +1435,18 @@ 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(nsIInputStream* *result) +nsSocketTransport::OpenInputStream(PRUint32 aOffset, + PRUint32 aCount, + PRUint32 aFlags, + nsIInputStream **aResult) { + NS_ENSURE_ARG_POINTER(aResult); nsresult rv = NS_OK; // Enter the socket transport lock... @@ -2235,25 +1459,17 @@ nsSocketTransport::OpenInputStream(nsIInputStream* *result) if (GetReadType() != eSocketRead_None) rv = NS_ERROR_IN_PROGRESS; - // Create a new blocking input stream for reading data into... - if (NS_SUCCEEDED(rv)) { - mReadListener = 0; - mReadContext = 0; + if (NS_SUCCEEDED(rv)) + rv = doBlockingConnection(); - // 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); - } + 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); } } @@ -2261,20 +1477,23 @@ nsSocketTransport::OpenInputStream(nsIInputStream* *result) mOperation = eSocketOperation_ReadWrite; SetReadType(eSocketRead_Sync); - mLastActiveTime = PR_IntervalNow (); - rv = mService->AddToWorkQ(this); + mLastActiveTime = PR_IntervalNow(); } 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(nsIOutputStream* *result) +nsSocketTransport::OpenOutputStream(PRUint32 aOffset, + PRUint32 aCount, + PRUint32 aFlags, + nsIOutputStream **aResult) { nsresult rv = NS_OK; @@ -2288,231 +1507,35 @@ nsSocketTransport::OpenOutputStream(nsIOutputStream* *result) if (GetWriteType() != eSocketWrite_None) rv = NS_ERROR_IN_PROGRESS; + if (NS_SUCCEEDED(rv)) + rv = doBlockingConnection(); + if (NS_SUCCEEDED(rv)) { - // 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; + NS_NEWXPCOM(mBOS, nsSocketBOS); + if (!mBOS) + rv = NS_ERROR_OUT_OF_MEMORY; + else { + NS_ADDREF(mBOS); + mBOS->SetTransport(this); + mBOS->SetSocket(mSocketFD); } + } + 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) { @@ -2626,38 +1649,780 @@ nsSocketTransport::SetSocketConnectTimeout (PRUint32 a_Seconds) } nsresult -nsSocketTransport::fireStatus(PRUint32 aCode) +nsSocketTransport::OnStatus(nsSocketRequest *req, nsISupports *ctxt, nsresult message) { 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; } - nsAutoString host; host.AssignWithConversion(mHostName); - return mEventSink->OnStatus(this, mReadContext, status, host.GetUnicode()); + return rv; +} + +// +//---------------------------------------------------------------------------- +// nsSocketBIS +//---------------------------------------------------------------------------- +// + +NS_IMPL_THREADSAFE_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_THREADSAFE_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(("nsSocketIS: 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(("nsSocketIS: PR_Read() failed with PR_WOULD_BLOCK_ERROR\n")); + rv = NS_BASE_STREAM_WOULD_BLOCK; + } + else { + LOG(("nsSocketIS: 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; + + // Hack below: + // So, there are two cases that we are worried about: + // On the mac, the impl of PR_Poll is a timeout. What this means + // for us is that Available might return zero. If we passed zero, + // this we may cause read to terminate prematurely. + // The other case is SSL which might require PR_Read to be called + // even if there were no bytes to read. (for handshaking). + // Therefore, we will lie and say that there is data to read when + // available return zero. -- dougt/darin + + if (amount == 0) + amount = MAX_IO_TRANSFER_SIZE; + else + 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 = mInputStream->GetOffset() - offset; + 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 = mOutputStream->GetOffset() - offset; + 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; } diff --git a/mozilla/netwerk/base/src/nsSocketTransport.h b/mozilla/netwerk/base/src/nsSocketTransport.h index 4456f305641..94d93cfc513 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.h +++ b/mozilla/netwerk/base/src/nsSocketTransport.h @@ -1,5 +1,4 @@ -/* -*- 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 @@ -29,17 +28,15 @@ #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) @@ -115,23 +112,23 @@ enum nsSocketReadWriteInfo { // Forward declarations... class nsSocketTransportService; -class nsSocketInputStream; -class nsSocketOutputStream; -class nsIInterfaceRequestor; +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 nsSocketTransport : public nsISocketTransport, - public nsIChannel, - public nsIDNSListener, - public nsIInputStreamObserver, - public nsIOutputStreamObserver + public nsIDNSListener { 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: @@ -149,6 +146,8 @@ public: PRUint32 bufferMaxSize); nsresult Process(PRInt16 aSelectFlags); + + nsresult Cancel(nsresult status); nsresult CheckForTimeout (PRIntervalTime aCurrentTime); @@ -164,21 +163,26 @@ 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 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); + nsresult doBlockingConnection(); + nsresult doReadWrite(PRInt16 aSelectFlags); + nsresult doResolveHost(); + + nsresult OnStatus(nsresult message); // with either request + + void CompleteAsyncRead(); + void CompleteAsyncWrite(); -private: PRIntervalTime mSocketTimeout; PRIntervalTime mSocketConnectTimeout; @@ -205,71 +209,235 @@ private: 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; - PRBool mProxyTransparent; - PRBool mSSLProxy; + PRPackedBool mProxyTransparent; + PRPackedBool mSSLProxy; nsSocketTransportService* mService; PRUint32 mReadWriteState; PRInt16 mSelectFlags; nsresult mStatus; - PRInt32 mSuspendCount; PRFileDesc* mSocketFD; PRUint32 mSocketTypeCount; char* *mSocketTypes; - nsCOMPtr mReadListener; - nsCOMPtr mReadContext; - PRUint32 mReadOffset; - - nsCOMPtr mWriteProvider; - nsCOMPtr mWriteContext; - PRUint32 mWriteOffset; - PRInt32 mWriteCount; - - PRInt32 mBytesExpected; + PRInt32 mBytesExpected; PRUint32 mReuseCount; PRUint32 mLastReuseCount; - nsSocketInputStream *mSocketInputStream; - nsSocketOutputStream *mSocketOutputStream; - - nsCOMPtr mReadPipeIn; - nsCOMPtr mReadPipeOut; - nsCOMPtr mWritePipeIn; - nsCOMPtr mWritePipeOut; PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; PRUint32 mIdleTimeoutInSeconds; - PRBool mWasConnected; + + nsSocketBIS *mBIS; + nsSocketBOS *mBOS; + nsSocketReadRequest *mReadRequest; + nsSocketWriteRequest *mWriteRequest; + + PRPackedBool mCloseConnectionOnceDone; + PRPackedBool 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 IsInitialized() { return mStartFired; } + 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 40c977972e4..0d90b963c71 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransportService.cpp @@ -156,12 +156,6 @@ nsSocketTransportService::Init(void) } } - // Hold onto the eventQueue service. We do not want any eventqueues to go away - // when we shutdown until we process all remaining transports - - if (NS_SUCCEEDED(rv)) - mEventQueueService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv); - // // Create the transport thread... // @@ -283,7 +277,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 +493,7 @@ nsSocketTransportService::CreateTransport(const char* aHost, PRInt32 proxyPort, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, - nsIChannel** aResult) + nsITransport** aResult) { return CreateTransportOfTypes(0, nsnull, aHost, aPort, proxyHost, proxyPort, bufferSegmentSize, bufferMaxSize, aResult); @@ -513,7 +507,7 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType, PRInt32 proxyPort, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, - nsIChannel** aResult) + nsITransport** aResult) { const char * types[] = { aSocketType }; return CreateTransportOfTypes(1, types, aHost, aPort, proxyHost, proxyPort, @@ -529,7 +523,7 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount, PRInt32 proxyPort, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, - nsIChannel** aResult) + nsITransport** aResult) { nsresult rv = NS_OK; @@ -572,7 +566,7 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount, } NS_IMETHODIMP -nsSocketTransportService::ReuseTransport(nsIChannel* i_Transport, +nsSocketTransportService::ReuseTransport(nsITransport* i_Transport, PRBool * o_Reuse) { nsresult rv = NS_ERROR_FAILURE; @@ -590,7 +584,7 @@ nsSocketTransportService::ReuseTransport(nsIChannel* i_Transport, */ NS_IMETHODIMP -nsSocketTransportService::Wakeup (nsIChannel* i_Transport) +nsSocketTransportService::Wakeup (nsITransport* i_Transport) { nsSocketTransport *transport = NS_STATIC_CAST (nsSocketTransport *, i_Transport); diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.h b/mozilla/netwerk/base/src/nsSocketTransportService.h index c020c893a7c..03a2ee35bd5 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.h +++ b/mozilla/netwerk/base/src/nsSocketTransportService.h @@ -30,7 +30,6 @@ #include "nsIInputStream.h" #include "nsCOMPtr.h" #include "nsIStringBundle.h" -#include "nsIEventQueueService.h" #if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS) // @@ -95,7 +94,6 @@ protected: PRPollDesc* mSelectFDSet; nsSocketTransport** mActiveTransportList; nsCOMPtr m_stringBundle; - nsCOMPtr mEventQueueService; }; diff --git a/mozilla/netwerk/base/src/nsStreamListenerProxy.cpp b/mozilla/netwerk/base/src/nsStreamListenerProxy.cpp index b149350943b..52c1c6a0cf7 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 channel makes data +// A stream listener proxy maintains a pipe. When the request 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 channel, -// indicating that the channel should suspend itself. +// because the pipe was full, then WOULD_BLOCK is returned to the request, +// indicating that the request should suspend itself. // -// Once suspended in this manner, the channel is only resumed when the pipe is +// Once suspended in this manner, the request is only resumed when the pipe is // emptied. // -// XXX The current design does NOT allow the channel to be "externally" +// XXX The current design does NOT allow the request 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, - nsIChannel *aChannel, + nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aSource, PRUint32 aOffset) - : nsStreamObserverEvent(aProxy, aChannel, aContext) + : nsStreamObserverEvent(aProxy, aRequest, aContext) , mSource(aSource) , mOffset(aOffset) { @@ -112,33 +112,33 @@ protected: NS_IMETHODIMP nsOnDataAvailableEvent::HandleEvent() { - LOG(("nsOnDataAvailableEvent: HandleEvent [event=%x, chan=%x]", this, mChannel.get())); + LOG(("nsOnDataAvailableEvent: HandleEvent [event=%x, chan=%x]", this, mRequest.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(), mChannel.get())); + listenerProxy->GetListenerStatus(), mRequest.get())); return NS_ERROR_FAILURE; } nsCOMPtr listener = listenerProxy->GetListener(); if (!listener) { LOG(("nsOnDataAvailableEvent: Already called OnStopRequest (listener is NULL), [chan=%x]\n", - mChannel.get())); + mRequest.get())); return NS_ERROR_FAILURE; } nsresult status = NS_OK; - nsresult rv = mChannel->GetStatus(&status); + nsresult rv = mRequest->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); // - // We should only forward this event to the listener if the channel is + // We should only forward this event to the listener if the request 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 channel after _this_ event was triggered. + // have cancelled the request 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, mChannel.get())); + mOffset, count, avail, mRequest.get())); } #endif // Forward call to listener - rv = listener->OnDataAvailable(mChannel, mContext, mSource, mOffset, count); + rv = listener->OnDataAvailable(mRequest, mContext, mSource, mOffset, count); LOG(("nsOnDataAvailableEvent: Done with the consumer's OnDataAvailable " "[rv=%x, chan=%x]\n", - rv, mChannel.get())); + rv, mRequest.get())); // - // XXX Need to suspend the underlying channel... must consider + // XXX Need to suspend the underlying request... must consider // other pending events (such as OnStopRequest). These - // should not be forwarded to the listener if the channel + // should not be forwarded to the listener if the request // 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]", - mChannel.get())); + mRequest.get())); return NS_OK; } @@ -203,26 +203,25 @@ NS_IMPL_ISUPPORTS_INHERITED3(nsStreamListenerProxy, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamListenerProxy::OnStartRequest(nsIChannel *aChannel, +nsStreamListenerProxy::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { + nsresult rv = mPipeIn->SetObserver(this); + if (NS_FAILED(rv)) return rv; - return nsStreamProxyBase::OnStartRequest(aChannel, aContext); + return nsStreamProxyBase::OnStartRequest(aRequest, aContext); } NS_IMETHODIMP -nsStreamListenerProxy::OnStopRequest(nsIChannel *aChannel, +nsStreamListenerProxy::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { - // - // We are done with the pipe. - // mPipeIn = 0; mPipeOut = 0; - return nsStreamProxyBase::OnStopRequest(aChannel, aContext, + return nsStreamProxyBase::OnStopRequest(aRequest, aContext, aStatus, aStatusText); } @@ -232,7 +231,7 @@ nsStreamListenerProxy::OnStopRequest(nsIChannel *aChannel, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, +nsStreamListenerProxy::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aSource, PRUint32 aOffset, @@ -242,9 +241,9 @@ nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, PRUint32 bytesWritten=0; LOG(("nsStreamListenerProxy: OnDataAvailable [offset=%u count=%u chan=%x]\n", - aOffset, aCount, aChannel)); + aOffset, aCount, aRequest)); - NS_PRECONDITION(mChannelToResume == 0, "Unexpected call to OnDataAvailable"); + NS_PRECONDITION(mRequestToResume == 0, "Unexpected call to OnDataAvailable"); NS_PRECONDITION(mPipeIn, "Pipe not initialized"); NS_PRECONDITION(mPipeOut, "Pipe not initialized"); @@ -254,7 +253,7 @@ nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, { nsresult status = mListenerStatus; if (NS_FAILED(status)) { - LOG(("nsStreamListenerProxy: Listener failed [status=%x chan=%x]\n", status, aChannel)); + LOG(("nsStreamListenerProxy: Listener failed [status=%x chan=%x]\n", status, aRequest)); return status; } } @@ -265,29 +264,29 @@ nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, // Try to copy data into the pipe. // // If the pipe is full, then we return NS_BASE_STREAM_WOULD_BLOCK - // so the calling channel can suspend itself. If, however, we detect + // so the calling request 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, aChannel)); + rv, aCount, bytesWritten, aRequest)); 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", aChannel)); + LOG(("nsStreamListenerProxy: Pipe emptied; looping back [chan=%x]\n", aRequest)); continue; } - LOG(("nsStreamListenerProxy: Pipe full; setting channel to resume [chan=%x]\n", aChannel)); - mChannelToResume = aChannel; + LOG(("nsStreamListenerProxy: Pipe full; setting request to resume [chan=%x]\n", aRequest)); + mRequestToResume = aRequest; } return rv; } if (bytesWritten == 0) { - LOG(("nsStreamListenerProxy: Copied zero bytes; not posting an event [chan=%x]\n", aChannel)); + LOG(("nsStreamListenerProxy: Copied zero bytes; not posting an event [chan=%x]\n", aRequest)); return NS_OK; } @@ -301,7 +300,7 @@ nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, PRUint32 total = PR_AtomicAdd((PRInt32 *) &mPendingCount, bytesWritten); if (total > bytesWritten) { LOG(("nsStreamListenerProxy: Piggy-backing pending event [total=%u, chan=%x]\n", - total, aChannel)); + total, aRequest)); return NS_OK; } @@ -309,7 +308,7 @@ nsStreamListenerProxy::OnDataAvailable(nsIChannel *aChannel, // Post an event for the number of bytes actually written. // nsOnDataAvailableEvent *ev = - new nsOnDataAvailableEvent(this, aChannel, aContext, mPipeIn, aOffset); + new nsOnDataAvailableEvent(this, aRequest, aContext, mPipeIn, aOffset); if (!ev) return NS_ERROR_OUT_OF_MEMORY; rv = ev->FireEvent(GetEventQueue()); @@ -357,9 +356,6 @@ nsStreamListenerProxy::Init(nsIStreamListener *aListener, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; - rv = mPipeIn->SetObserver(this); - if (NS_FAILED(rv)) return rv; - SetReceiver(aListener); return SetEventQueue(aEventQ); } @@ -374,23 +370,23 @@ nsStreamListenerProxy::OnEmpty(nsIInputStream *aInputStream) { LOG(("nsStreamListenerProxy: OnEmpty\n")); // - // The pipe has been emptied by the listener. If the channel + // The pipe has been emptied by the listener. If the request // 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 chan; + nsCOMPtr req; { nsAutoLock lock(mLock); - if (mChannelToResume) { - chan = mChannelToResume; - mChannelToResume = 0; + if (mRequestToResume) { + req = mRequestToResume; + mRequestToResume = 0; } mPipeEmptied = PR_TRUE; // Flag this call } - if (chan) { - LOG(("nsStreamListenerProxy: Resuming channel\n")); - chan->Resume(); + if (req) { + LOG(("nsStreamListenerProxy: Resuming request\n")); + req->Resume(); } return NS_OK; } diff --git a/mozilla/netwerk/base/src/nsStreamListenerProxy.h b/mozilla/netwerk/base/src/nsStreamListenerProxy.h index f77d3b8fe99..99265db8752 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 mChannelToResume; + nsCOMPtr mRequestToResume; PRLock *mLock; PRUint32 mPendingCount; PRBool mPipeEmptied; diff --git a/mozilla/netwerk/base/src/nsStreamLoader.cpp b/mozilla/netwerk/base/src/nsStreamLoader.cpp index c63e62cef85..eb9cce7920a 100644 --- a/mozilla/netwerk/base/src/nsStreamLoader.cpp +++ b/mozilla/netwerk/base/src/nsStreamLoader.cpp @@ -35,16 +35,14 @@ nsStreamLoader::Init(nsIURI* aURL, nsISupports* context, nsILoadGroup* aGroup, nsIInterfaceRequestor* notificationCallbacks, - nsLoadFlags loadAttributes, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize) + nsLoadFlags loadAttributes) { nsresult rv = NS_OK; mObserver = observer; mContext = context; rv = NS_OpenURI(this, nsnull, aURL, nsnull, aGroup, notificationCallbacks, - loadAttributes, bufferSegmentSize, bufferMaxSize); + loadAttributes); if (NS_FAILED(rv) && mObserver) { // don't callback synchronously as it puts the caller // in a recursive situation and breaks the asynchronous @@ -96,26 +94,27 @@ nsStreamLoader::GetNumBytesRead(PRUint32* aNumBytes) return NS_OK; } +/* readonly attribute nsIRequest request; */ NS_IMETHODIMP -nsStreamLoader::GetChannel(nsIChannel** aChannel) +nsStreamLoader::GetRequest(nsIRequest * *aRequest) { - *aChannel = mChannel.get(); - NS_IF_ADDREF(*aChannel); - return NS_OK; + NS_IF_ADDREF(*aRequest=mRequest); + return NS_OK; } + NS_IMETHODIMP -nsStreamLoader::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +nsStreamLoader::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { return NS_OK; } NS_IMETHODIMP -nsStreamLoader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +nsStreamLoader::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - mChannel = channel; + mRequest = request; rv = mObserver->OnStreamComplete(this, mContext, aStatus, mData.Length(), mData.GetBuffer()); @@ -125,7 +124,7 @@ nsStreamLoader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, #define BUF_SIZE 1024 NS_IMETHODIMP -nsStreamLoader::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +nsStreamLoader::OnDataAvailable(nsIRequest* request, 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 f6f07cacba9..3d8deaa6c2d 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 mChannel; + nsCOMPtr mRequest; /// nsCOMPtr mLoadGroup; }; diff --git a/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp b/mozilla/netwerk/base/src/nsStreamObserverProxy.cpp index 3df29809b2d..6e9e515b86a 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, - nsIChannel *aChannel, + nsIRequest *aRequest, nsISupports *aContext) : mProxy(aProxy) - , mChannel(aChannel) + , mRequest(aRequest) , mContext(aContext) { NS_IF_ADDREF(mProxy); @@ -94,9 +94,9 @@ class nsOnStartRequestEvent : public nsStreamObserverEvent { public: nsOnStartRequestEvent(nsStreamProxyBase *aProxy, - nsIChannel *aChannel, + nsIRequest *aRequest, nsISupports *aContext) - : nsStreamObserverEvent(aProxy, aChannel, aContext) + : nsStreamObserverEvent(aProxy, aRequest, aContext) { MOZ_COUNT_CTOR(nsOnStartRequestEvent); } @@ -112,8 +112,8 @@ public: NS_IMETHODIMP nsOnStartRequestEvent::HandleEvent() { - LOG(("nsOnStartRequestEvent: HandleEvent [event=%x chan=%x]\n", - this, mChannel.get())); + LOG(("nsOnStartRequestEvent: HandleEvent [event=%x req=%x]\n", + this, mRequest.get())); nsCOMPtr observer = mProxy->GetReceiver(); if (!observer) { @@ -121,7 +121,7 @@ nsOnStartRequestEvent::HandleEvent() return NS_ERROR_FAILURE; } - return observer->OnStartRequest(mChannel, mContext); + return observer->OnStartRequest(mRequest, mContext); } // @@ -133,9 +133,9 @@ class nsOnStopRequestEvent : public nsStreamObserverEvent { public: nsOnStopRequestEvent(nsStreamProxyBase *aProxy, - nsIChannel *aChannel, nsISupports *aContext, + nsIRequest *aRequest, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) - : nsStreamObserverEvent(aProxy, aChannel, aContext) + : nsStreamObserverEvent(aProxy, aRequest, aContext) , mStatus(aStatus) , mStatusText(aStatusText) { @@ -157,8 +157,8 @@ protected: NS_IMETHODIMP nsOnStopRequestEvent::HandleEvent() { - LOG(("nsOnStopRequestEvent: HandleEvent [event=%x chan=%x]\n", - this, mChannel.get())); + LOG(("nsOnStopRequestEvent: HandleEvent [event=%x req=%x]\n", + this, mRequest.get())); nsCOMPtr observer = mProxy->GetReceiver(); if (!observer) { @@ -171,7 +171,7 @@ nsOnStopRequestEvent::HandleEvent() // mProxy->SetReceiver(nsnull); - return observer->OnStopRequest(mChannel, + return observer->OnStopRequest(mRequest, mContext, mStatus, mStatusText.GetUnicode()); @@ -191,12 +191,12 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsStreamProxyBase, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamProxyBase::OnStartRequest(nsIChannel *aChannel, +nsStreamProxyBase::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { - LOG(("nsStreamProxyBase: OnStartRequest [this=%x chan=%x]\n", this, aChannel)); + LOG(("nsStreamProxyBase: OnStartRequest [this=%x req=%x]\n", this, aRequest)); nsOnStartRequestEvent *ev = - new nsOnStartRequestEvent(this, aChannel, aContext); + new nsOnStartRequestEvent(this, aRequest, aContext); if (!ev) return NS_ERROR_OUT_OF_MEMORY; @@ -207,15 +207,15 @@ nsStreamProxyBase::OnStartRequest(nsIChannel *aChannel, } NS_IMETHODIMP -nsStreamProxyBase::OnStopRequest(nsIChannel *aChannel, +nsStreamProxyBase::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) { - LOG(("nsStreamProxyBase: OnStopRequest [this=%x chan=%x status=%x]\n", - this, aChannel, aStatus)); + LOG(("nsStreamProxyBase: OnStopRequest [this=%x req=%x status=%x]\n", + this, aRequest, aStatus)); nsOnStopRequestEvent *ev = - new nsOnStopRequestEvent(this, aChannel, aContext, aStatus, aStatusText); + new nsOnStopRequestEvent(this, aRequest, 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 6466f1fffe2..57b4fb3cc62 100644 --- a/mozilla/netwerk/base/src/nsStreamObserverProxy.h +++ b/mozilla/netwerk/base/src/nsStreamObserverProxy.h @@ -48,6 +48,8 @@ public: nsresult SetEventQueue(nsIEventQueue *); nsresult SetReceiver(nsIStreamObserver *aReceiver) { + PRBool same = ::SameCOMIdentity(aReceiver, this); + NS_ASSERTION((!same), "aReceiver is self"); mReceiver = aReceiver; return NS_OK; } @@ -70,7 +72,7 @@ class nsStreamObserverEvent { public: nsStreamObserverEvent(nsStreamProxyBase *proxy, - nsIChannel *channel, nsISupports *context); + nsIRequest *request, nsISupports *context); virtual ~nsStreamObserverEvent(); nsresult FireEvent(nsIEventQueue *); @@ -82,7 +84,7 @@ protected: PLEvent mEvent; nsStreamProxyBase *mProxy; - nsCOMPtr mChannel; + nsCOMPtr mRequest; nsCOMPtr mContext; }; diff --git a/mozilla/netwerk/base/src/nsStreamProviderProxy.cpp b/mozilla/netwerk/base/src/nsStreamProviderProxy.cpp index c931b187962..cc24f5984c5 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 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 +// 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 // proxy posts an asynchronous event for more data, and returns WOULD_BLOCK -// indicating that the channel should suspend itself. +// indicating that the request should suspend itself. // -// The channel is only resumed once the event has been successfully handled; +// The request 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, - nsIChannel *aChannel, + nsIRequest *aRequest, nsISupports *aContext, nsIOutputStream *aSink, PRUint32 aOffset, PRUint32 aCount) - : nsStreamObserverEvent(aProxy, aChannel, aContext) + : nsStreamObserverEvent(aProxy, aRequest, aContext) , mSink(aSink) , mOffset(aOffset) , mCount(aCount) @@ -89,7 +89,7 @@ NS_IMETHODIMP nsOnDataWritableEvent::HandleEvent() { LOG(("nsOnDataWritableEvent: HandleEvent [event=%x chan=%x]", - this, mChannel.get())); + this, mRequest.get())); nsStreamProviderProxy *providerProxy = NS_STATIC_CAST(nsStreamProviderProxy *, mProxy); @@ -101,18 +101,18 @@ nsOnDataWritableEvent::HandleEvent() } nsresult status = NS_OK; - nsresult rv = mChannel->GetStatus(&status); + nsresult rv = mRequest->GetStatus(&status); NS_ASSERTION(NS_SUCCEEDED(rv), "GetStatus failed"); // - // We should only forward this event to the provider if the channel is + // We should only forward this event to the provider if the request 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 channel after _this_ event was triggered. + // have cancelled the request after _this_ event was triggered. // if (NS_SUCCEEDED(status)) { LOG(("nsOnDataWritableEvent: Calling the consumer's OnDataWritable\n")); - rv = provider->OnDataWritable(mChannel, mContext, mSink, mOffset, mCount); + rv = provider->OnDataWritable(mRequest, 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 channel is already suspended, so unless the provider returned - // NS_BASE_STREAM_WOULD_BLOCK, we should wake up the channel. + // The request is already suspended, so unless the provider returned + // NS_BASE_STREAM_WOULD_BLOCK, we should wake up the request. // if (rv != NS_BASE_STREAM_WOULD_BLOCK) - mChannel->Resume(); + mRequest->Resume(); } else LOG(("nsOnDataWritableEvent: Not calling OnDataWritable")); @@ -149,14 +149,14 @@ NS_IMPL_ISUPPORTS_INHERITED2(nsStreamProviderProxy, //---------------------------------------------------------------------------- // NS_IMETHODIMP -nsStreamProviderProxy::OnStartRequest(nsIChannel *aChannel, +nsStreamProviderProxy::OnStartRequest(nsIRequest *request, nsISupports *aContext) { - return nsStreamProxyBase::OnStartRequest(aChannel, aContext); + return nsStreamProxyBase::OnStartRequest(request, aContext); } NS_IMETHODIMP -nsStreamProviderProxy::OnStopRequest(nsIChannel *aChannel, +nsStreamProviderProxy::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusText) @@ -167,7 +167,7 @@ nsStreamProviderProxy::OnStopRequest(nsIChannel *aChannel, mPipeIn = 0; mPipeOut = 0; - return nsStreamProxyBase::OnStopRequest(aChannel, aContext, + return nsStreamProxyBase::OnStopRequest(request, aContext, aStatus, aStatusText); } @@ -189,7 +189,7 @@ nsWriteToSink(nsIInputStream *source, } NS_IMETHODIMP -nsStreamProviderProxy::OnDataWritable(nsIChannel *aChannel, +nsStreamProviderProxy::OnDataWritable(nsIRequest *aRequest, nsISupports *aContext, nsIOutputStream *aSink, PRUint32 aOffset, @@ -215,7 +215,7 @@ nsStreamProviderProxy::OnDataWritable(nsIChannel *aChannel, } // - // Provide the channel with whatever data is already in the pipe (not + // Provide the request with whatever data is already in the pipe (not // exceeding aCount). // PRUint32 count; @@ -236,7 +236,7 @@ nsStreamProviderProxy::OnDataWritable(nsIChannel *aChannel, // Post an event requesting the provider for more data. // nsOnDataWritableEvent *ev = - new nsOnDataWritableEvent(this, aChannel, aContext, + new nsOnDataWritableEvent(this, aRequest, 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 ee589e19b9f..7f32fd4a2cd 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(nsIChannel* channel, nsISupports* context) +nsSyncStreamListener::OnStartRequest(nsIRequest* request, nsISupports* context) { return NS_OK; } NS_IMETHODIMP -nsSyncStreamListener::OnStopRequest(nsIChannel* channel, nsISupports* context, +nsSyncStreamListener::OnStopRequest(nsIRequest* request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { // XXX what do we do with the status and error message? @@ -69,7 +69,7 @@ nsSyncStreamListener::OnStopRequest(nsIChannel* channel, nsISupports* context, } NS_IMETHODIMP -nsSyncStreamListener::OnDataAvailable(nsIChannel* channel, +nsSyncStreamListener::OnDataAvailable(nsIRequest* request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, diff --git a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp index 797a1477f6a..7fdd93c2698 100644 --- a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp +++ b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.cpp @@ -232,11 +232,12 @@ nsDiskCacheRecordChannel::NotifyStorageInUse(PRInt32 aBytesUsed) } // implement nsISupports -NS_IMPL_THREADSAFE_ISUPPORTS4(nsDiskCacheRecordChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamObserver) +NS_IMPL_THREADSAFE_ISUPPORTS5(nsDiskCacheRecordChannel, + nsITransport, + nsIChannel, + nsIRequest, + nsIStreamListener, + nsIStreamObserver) // implement nsIRequest NS_IMETHODIMP @@ -250,10 +251,10 @@ NS_IMETHODIMP nsDiskCacheRecordChannel::IsPending(PRBool *aIsPending) { *aIsPending = PR_FALSE; - if(!mFileTransport) + if(!mFileRequest) return NS_OK; - return mFileTransport->IsPending(aIsPending); + return mFileRequest->IsPending(aIsPending); } NS_IMETHODIMP @@ -268,28 +269,28 @@ nsDiskCacheRecordChannel::Cancel(nsresult status) { NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code"); mStatus = status; - if(!mFileTransport) + if(!mFileRequest) return NS_ERROR_FAILURE; - return mFileTransport->Cancel(status); + return mFileRequest->Cancel(status); } NS_IMETHODIMP nsDiskCacheRecordChannel::Suspend(void) { - if(!mFileTransport) + if(!mFileRequest) return NS_ERROR_FAILURE; - return mFileTransport->Suspend(); + return mFileRequest->Suspend(); } NS_IMETHODIMP nsDiskCacheRecordChannel::Resume(void) { - if(!mFileTransport) + if(!mFileRequest) return NS_ERROR_FAILURE; - return mFileTransport->Resume(); + return mFileRequest->Resume(); } // implement nsIChannel @@ -313,23 +314,33 @@ nsDiskCacheRecordChannel::SetOriginalURI(nsIURI* aURI) NS_IMETHODIMP nsDiskCacheRecordChannel::GetURI(nsIURI* *aURI) { - if(!mFileTransport) - return NS_ERROR_FAILURE; - - return mFileTransport->GetURI(aURI); + NS_NOTREACHED("nsDiskCacheRecordChannel::GetURI"); + return NS_ERROR_NOT_IMPLEMENTED ; } NS_IMETHODIMP nsDiskCacheRecordChannel::SetURI(nsIURI* aURI) { - if(!mFileTransport) - return NS_ERROR_FAILURE; - - return mFileTransport->SetURI(aURI); + NS_NOTREACHED("nsDiskCacheRecordChannel::SetURI"); + return NS_ERROR_NOT_IMPLEMENTED ; } NS_IMETHODIMP -nsDiskCacheRecordChannel::OpenInputStream(nsIInputStream* *aResult) +nsDiskCacheRecordChannel::Open(nsIInputStream **aResult) +{ + return OpenInputStream(0, -1, 0, aResult); +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) +{ + nsCOMPtr req; + return AsyncRead(aListener, aContext, 0, -1, 0, getter_AddRefs(req)); +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::OpenInputStream(PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIInputStream* *aResult) { nsresult rv; @@ -346,7 +357,7 @@ nsDiskCacheRecordChannel::OpenInputStream(nsIInputStream* *aResult) // we don't need to worry about notification callbacks - rv = mFileTransport->OpenInputStream(aResult); + rv = mFileTransport->OpenInputStream(offset, count, 0, aResult); if(NS_FAILED(rv)) mFileTransport = nsnull; @@ -354,7 +365,8 @@ nsDiskCacheRecordChannel::OpenInputStream(nsIInputStream* *aResult) } NS_IMETHODIMP -nsDiskCacheRecordChannel::OpenOutputStream(nsIOutputStream* *aResult) +nsDiskCacheRecordChannel::OpenOutputStream(PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIOutputStream* *aResult) { nsresult rv; NS_ENSURE_ARG(aResult); @@ -374,7 +386,7 @@ nsDiskCacheRecordChannel::OpenOutputStream(nsIOutputStream* *aResult) // we don't need to worry about notification callbacks - rv = mFileTransport->OpenOutputStream(getter_AddRefs(outputStream)); + rv = mFileTransport->OpenOutputStream(offset, count, 0, getter_AddRefs(outputStream)); if(NS_FAILED(rv)) { mFileTransport = nsnull; return rv; @@ -384,9 +396,11 @@ nsDiskCacheRecordChannel::OpenOutputStream(nsIOutputStream* *aResult) } NS_IMETHODIMP -nsDiskCacheRecordChannel::AsyncRead(nsIStreamListener *aListener, - nsISupports *aContext) +nsDiskCacheRecordChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext, + PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIRequest **aResult) { + NS_ENSURE_ARG_POINTER(aResult); nsresult rv; if(mFileTransport) @@ -410,7 +424,7 @@ nsDiskCacheRecordChannel::AsyncRead(nsIStreamListener *aListener, } } - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -424,18 +438,21 @@ nsDiskCacheRecordChannel::AsyncRead(nsIStreamListener *aListener, // no callbacks - rv = mFileTransport->AsyncRead(tempListener, aContext); + rv = mFileTransport->AsyncRead(tempListener, aContext, offset, count, 0, + getter_AddRefs(mFileRequest)); if (NS_FAILED(rv)) { // release the transport so that we don't think we're in progress mFileTransport = nsnull; } + NS_ADDREF(*aResult = this); return rv; } NS_IMETHODIMP -nsDiskCacheRecordChannel::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt) +nsDiskCacheRecordChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt, + PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIRequest **aResult) { /* @@ -555,88 +572,6 @@ nsDiskCacheRecordChannel::SetContentLength(PRInt32 aContentLength) 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 nsDiskCacheRecordChannel::GetOwner(nsISupports* *aOwner) { @@ -691,39 +626,49 @@ nsDiskCacheRecordChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) return NS_OK; } +NS_IMETHODIMP +nsDiskCacheRecordChannel::GetProgressEventSink(nsIProgressEventSink **aSink) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsDiskCacheRecordChannel::SetProgressEventSink(nsIProgressEventSink *aSink) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + //////////////////////////////////////////////////////////////////////////////// // nsIStreamListener methods: //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsDiskCacheRecordChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) +nsDiskCacheRecordChannel::OnStartRequest(nsIRequest* transportRequest, nsISupports* context) { NS_ASSERTION(mRealListener, "No listener..."); return mRealListener->OnStartRequest(this, context); } NS_IMETHODIMP -nsDiskCacheRecordChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, +nsDiskCacheRecordChannel::OnStopRequest(nsIRequest* transportRequest, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; rv = mRealListener->OnStopRequest(this, context, aStatus, aStatusArg); - if (mLoadGroup) { - if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); - } - } + if (mLoadGroup) + mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); // Release the reference to the consumer stream listener... mRealListener = null_nsCOMPtr(); mFileTransport = null_nsCOMPtr(); + mFileRequest = null_nsCOMPtr(); return rv; } NS_IMETHODIMP -nsDiskCacheRecordChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, +nsDiskCacheRecordChannel::OnDataAvailable(nsIRequest* transportRequest, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -737,8 +682,8 @@ nsDiskCacheRecordChannel::OnDataAvailable(nsIChannel* transportChannel, nsISuppo // insure that the transport will go away even if it is blocked waiting // for the consumer to empty the pipe... // - if (NS_FAILED(rv) && mFileTransport) { - mFileTransport->Cancel(rv); + if (NS_FAILED(rv) && mFileRequest) { + mFileRequest->Cancel(rv); } return rv; } diff --git a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h index c2250402467..c54a4cfb93e 100644 --- a/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h +++ b/mozilla/netwerk/cache/filecache/nsDiskCacheRecordChannel.h @@ -25,6 +25,7 @@ #define _ns_DiskCacheRecordChannel_h_ #include "nsIChannel.h" +#include "nsITransport.h" #include "nsCOMPtr.h" #include "nsDiskCacheRecord.h" #include "nsIStreamListener.h" @@ -34,6 +35,7 @@ */ class nsDiskCacheRecordChannel : public nsIChannel, + public nsITransport, public nsIStreamListener { public: @@ -50,6 +52,14 @@ class nsDiskCacheRecordChannel : public nsIChannel, // Declare nsIChannel methods NS_DECL_NSICHANNEL + // Declare nsITransport methods + NS_IMETHOD GetProgressEventSink(nsIProgressEventSink **); + NS_IMETHOD SetProgressEventSink(nsIProgressEventSink *); + NS_IMETHOD OpenInputStream(PRUint32, PRUint32, PRUint32, nsIInputStream **); + NS_IMETHOD OpenOutputStream(PRUint32, PRUint32, PRUint32, nsIOutputStream **); + NS_IMETHOD AsyncRead(nsIStreamListener *, nsISupports *, PRUint32, PRUint32, PRUint32, nsIRequest **); + NS_IMETHOD AsyncWrite(nsIStreamProvider *, nsISupports *, PRUint32, PRUint32, PRUint32, nsIRequest **); + // Declare nsIStreamObserver methods NS_DECL_NSISTREAMOBSERVER @@ -66,7 +76,8 @@ class nsDiskCacheRecordChannel : public nsIChannel, nsCOMPtr mLoadGroup ; nsLoadFlags mLoadAttributes; nsCOMPtr mOwner ; - nsCOMPtr mFileTransport ; + nsCOMPtr mFileTransport ; + nsCOMPtr mFileRequest; nsCOMPtr< nsIFile > mSpec ; nsCOMPtr mRealListener; nsresult mStatus; diff --git a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp index a900bfc1fab..ba26bf91b47 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp +++ b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.cpp @@ -33,7 +33,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); -NS_IMPL_THREADSAFE_ISUPPORTS1(nsMemCacheChannel, nsIChannel) +NS_IMPL_THREADSAFE_ISUPPORTS3(nsMemCacheChannel, nsIChannel, nsIRequest, nsITransport) void nsMemCacheChannel::NotifyStorageInUse(PRInt32 aBytesUsed) @@ -52,7 +52,7 @@ class AsyncReadStreamAdaptor : public nsIInputStream, public: AsyncReadStreamAdaptor(nsMemCacheChannel* aChannel, nsIInputStream *aSyncStream): mSyncStream(aSyncStream), mDataAvailCursor(0), - mRemaining(-1), mAvailable(0), mChannel(aChannel), mAbortStatus(NS_OK), mSuspended(PR_FALSE) + mRemaining((PRUint32)-1), mAvailable(0), mChannel(aChannel), mAbortStatus(NS_OK), mSuspended(PR_FALSE) { NS_INIT_REFCNT(); NS_ADDREF(mChannel); @@ -104,7 +104,7 @@ public: // event to the downstream listener and causes another OnDataAvailable() // event to be enqueued. NS_IMETHOD - OnDataAvailable(nsIChannel *channel, nsISupports *aContext, + OnDataAvailable(nsIRequest *request, nsISupports *aContext, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv; @@ -124,7 +124,7 @@ public: } NS_IMETHOD - OnStartRequest(nsIChannel *channel, nsISupports *aContext) { + OnStartRequest(nsIRequest *request, nsISupports *aContext) { nsresult rv = NS_OK; NS_ASSERTION(mDownstreamListener, "no downstream listener"); @@ -139,7 +139,7 @@ public: } NS_IMETHOD - OnStopRequest(nsIChannel *channel, nsISupports *aContext, + OnStopRequest(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -385,7 +385,7 @@ private: NS_IMPL_THREADSAFE_ISUPPORTS1(MemCacheWriteStreamWrapper, nsIOutputStream) nsMemCacheChannel::nsMemCacheChannel(nsMemCacheRecord *aRecord, nsILoadGroup *aLoadGroup) - : mRecord(aRecord), mStartOffset(0), mStatus(NS_OK), + : mRecord(aRecord), mStatus(NS_OK), mLoadAttributes(nsIChannel::LOAD_NORMAL) { NS_INIT_REFCNT(); @@ -478,14 +478,28 @@ nsMemCacheChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsMemCacheChannel::OpenInputStream(nsIInputStream* *aResult) +nsMemCacheChannel::Open(nsIInputStream **aResult) +{ + return OpenInputStream(0, -1, 0, aResult); +} + +NS_IMETHODIMP +nsMemCacheChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) +{ + nsCOMPtr req; + return AsyncRead(aListener, aContext, 0, -1, 0, getter_AddRefs(req)); +} + +NS_IMETHODIMP +nsMemCacheChannel::OpenInputStream(PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIInputStream* *aResult) { nsresult rv; NS_ENSURE_ARG(aResult); if (mInputStream) return NS_ERROR_NOT_AVAILABLE; - rv = mRecord->mStorageStream->NewInputStream(mStartOffset, getter_AddRefs(mInputStream)); + rv = mRecord->mStorageStream->NewInputStream(offset, getter_AddRefs(mInputStream)); if (NS_FAILED(rv)) return rv; *aResult = mInputStream; NS_ADDREF(*aResult); @@ -493,7 +507,8 @@ nsMemCacheChannel::OpenInputStream(nsIInputStream* *aResult) } NS_IMETHODIMP -nsMemCacheChannel::OpenOutputStream(nsIOutputStream* *aResult) +nsMemCacheChannel::OpenOutputStream(PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIOutputStream* *aResult) { nsresult rv; NS_ENSURE_ARG(aResult); @@ -502,19 +517,23 @@ nsMemCacheChannel::OpenOutputStream(nsIOutputStream* *aResult) PRUint32 oldLength; mRecord->mStorageStream->GetLength(&oldLength); - rv = mRecord->mStorageStream->GetOutputStream(mStartOffset, getter_AddRefs(outputStream)); + rv = mRecord->mStorageStream->GetOutputStream(offset, getter_AddRefs(outputStream)); if (NS_FAILED(rv)) return rv; - if (mStartOffset < oldLength) - NotifyStorageInUse(mStartOffset - oldLength); + if (offset < oldLength) + NotifyStorageInUse(offset - oldLength); return MemCacheWriteStreamWrapper::Create(this, outputStream, aResult); } NS_IMETHODIMP -nsMemCacheChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext) +nsMemCacheChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext, + PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIRequest **aResult) { + NS_ENSURE_ARG_POINTER(aResult); + nsCOMPtr inputStream; - nsresult rv = OpenInputStream(getter_AddRefs(inputStream)); + nsresult rv = OpenInputStream(offset, count, flags, getter_AddRefs(inputStream)); if (NS_FAILED(rv)) return rv; AsyncReadStreamAdaptor *asyncReadStreamAdaptor; @@ -529,94 +548,20 @@ nsMemCacheChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext mAsyncReadStream = nsnull; NS_RELEASE(asyncReadStreamAdaptor); } + NS_ADDREF(*aResult = this); return rv; } NS_IMETHODIMP -nsMemCacheChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +nsMemCacheChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt, + PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIRequest **aResult) { // Not required to be implemented 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) { @@ -718,3 +663,15 @@ nsMemCacheChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) *aSecurityInfo = nsnull; return NS_OK; } + +NS_IMETHODIMP +nsMemCacheChannel::GetProgressEventSink(nsIProgressEventSink **aSink) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsMemCacheChannel::SetProgressEventSink(nsIProgressEventSink *aSink) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} diff --git a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h index a2c608ddbc5..6eea2ce9288 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h +++ b/mozilla/netwerk/cache/memcache/nsMemCacheChannel.h @@ -24,13 +24,14 @@ #include "nsMemCacheRecord.h" #include "nsIChannel.h" +#include "nsITransport.h" #include "nsIInputStream.h" #include "nsCOMPtr.h" class AsyncReadStreamAdaptor; -class nsMemCacheChannel : public nsIChannel +class nsMemCacheChannel : public nsIChannel, public nsITransport { public: // Constructors and Destructor @@ -46,6 +47,14 @@ public: // Declare nsIChannel methods NS_DECL_NSICHANNEL + // Declare nsITransport methods + NS_IMETHOD GetProgressEventSink(nsIProgressEventSink **); + NS_IMETHOD SetProgressEventSink(nsIProgressEventSink *); + NS_IMETHOD OpenInputStream(PRUint32, PRUint32, PRUint32, nsIInputStream **); + NS_IMETHOD OpenOutputStream(PRUint32, PRUint32, PRUint32, nsIOutputStream **); + NS_IMETHOD AsyncRead(nsIStreamListener *, nsISupports *, PRUint32, PRUint32, PRUint32, nsIRequest **); + NS_IMETHOD AsyncWrite(nsIStreamProvider *, nsISupports *, PRUint32, PRUint32, PRUint32, nsIRequest **); + protected: void NotifyStorageInUse(PRInt32 aBytesUsed); diff --git a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp index d1450f419c1..28bc0fc950c 100644 --- a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp +++ b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.cpp @@ -49,9 +49,9 @@ nsCacheEntryChannel::~nsCacheEntryChannel() } NS_IMPL_THREADSAFE_ISUPPORTS3(nsCacheEntryChannel, - nsISupports, - nsIChannel, - nsIRequest) + nsITransport, + nsIChannel, + nsIRequest) // A proxy for nsIOutputStream class CacheOutputStream : public nsIOutputStream { @@ -136,37 +136,30 @@ protected: NS_IMPL_THREADSAFE_ISUPPORTS1(CacheOutputStream, nsIOutputStream) NS_IMETHODIMP -nsCacheEntryChannel::GetTransferOffset(PRUint32 *aStartPosition) +nsCacheEntryChannel::Open(nsIInputStream **aInputStream) { - return mChannel->GetTransferOffset(aStartPosition); + return OpenInputStream(0, -1, 0, aInputStream); } NS_IMETHODIMP -nsCacheEntryChannel::SetTransferOffset(PRUint32 aStartPosition) +nsCacheEntryChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) { - mCacheEntry->mLogicalLength = aStartPosition; - return mChannel->SetTransferOffset(aStartPosition); + nsCOMPtr req; + return AsyncRead(aListener, aContext, 0, -1, 0, getter_AddRefs(req)); } 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) +nsCacheEntryChannel::OpenOutputStream(PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIOutputStream* *aOutputStream) { nsresult rv; nsCOMPtr baseOutputStream; - rv = mChannel->OpenOutputStream(getter_AddRefs(baseOutputStream)); + nsCOMPtr trans = do_QueryInterface(mChannel, &rv); + if (NS_FAILED(rv)) return rv; + + rv = trans->OpenOutputStream(offset, count, flags, + getter_AddRefs(baseOutputStream)); if (NS_FAILED(rv)) return rv; mCacheEntry->NoteAccess(); @@ -180,36 +173,60 @@ nsCacheEntryChannel::OpenOutputStream(nsIOutputStream* *aOutputStream) } NS_IMETHODIMP -nsCacheEntryChannel::OpenInputStream(nsIInputStream* *aInputStream) +nsCacheEntryChannel::OpenInputStream(PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIInputStream* *aInputStream) { mCacheEntry->NoteAccess(); - return mChannel->OpenInputStream(aInputStream); + nsresult rv; + nsCOMPtr trans = do_QueryInterface(mChannel, &rv); + if (NS_FAILED(rv)) return rv; + + return trans->OpenInputStream(offset, count, flags, aInputStream); } NS_IMETHODIMP -nsCacheEntryChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext) +nsCacheEntryChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext, + PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIRequest **aResult) { - nsresult rv; - - NS_ENSURE_ARG(aListener); - mCacheEntry->NoteAccess(); - rv = mChannel->AsyncRead(aListener, aContext); + nsresult rv; + nsCOMPtr trans = do_QueryInterface(mChannel, &rv); + if (NS_FAILED(rv)) return rv; - return rv; + return trans->AsyncRead(aListener, aContext, offset, count, flags, aResult); } // No async writes allowed to the cache yet NS_IMETHODIMP -nsCacheEntryChannel::AsyncWrite(nsIStreamProvider *aProvider, - nsISupports *aContext) +nsCacheEntryChannel::AsyncWrite(nsIStreamProvider *aProvider, nsISupports *aContext, + PRUint32 offset, PRUint32 count, PRUint32 flags, + nsIRequest **aResult) { NS_NOTREACHED("nsCacheEntryChannel::AsyncWrite"); return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsCacheEntryChannel::GetSecurityInfo(nsISupports **aResult) +{ + return mChannel->GetSecurityInfo(aResult); +} + +NS_IMETHODIMP +nsCacheEntryChannel::GetProgressEventSink(nsIProgressEventSink **aSink) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCacheEntryChannel::SetProgressEventSink(nsIProgressEventSink *aSink) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsCacheEntryChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) { diff --git a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h index 9f38336c53e..5f28677cb8a 100644 --- a/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h +++ b/mozilla/netwerk/cache/mgr/nsCacheEntryChannel.h @@ -27,6 +27,7 @@ #include "nsCOMPtr.h" #include "nsIChannel.h" +#include "nsITransport.h" #include "nsCachedNetData.h" #include "nsILoadGroup.h" @@ -47,25 +48,29 @@ protected: }; // Override several nsIChannel methods so that they interact with the cache manager -class nsCacheEntryChannel : public nsChannelProxy { +class nsCacheEntryChannel : public nsChannelProxy, public nsITransport { public: NS_DECL_ISUPPORTS - 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); + // nsIChannel methods + NS_IMETHOD Open(nsIInputStream* *aInputStream); + NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, 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); + // nsITransport methods + NS_IMETHOD GetSecurityInfo(nsISupports **); + NS_IMETHOD GetProgressEventSink(nsIProgressEventSink **); + NS_IMETHOD SetProgressEventSink(nsIProgressEventSink *); + NS_IMETHOD OpenInputStream(PRUint32, PRUint32, PRUint32, nsIInputStream **); + NS_IMETHOD OpenOutputStream(PRUint32, PRUint32, PRUint32, nsIOutputStream **); + NS_IMETHOD AsyncRead(nsIStreamListener *, nsISupports *, PRUint32, PRUint32, PRUint32, nsIRequest **); + NS_IMETHOD AsyncWrite(nsIStreamProvider *, nsISupports *, PRUint32, PRUint32, PRUint32, nsIRequest **); + protected: nsCacheEntryChannel(nsCachedNetData* aCacheEntry, nsIChannel* aChannel, nsILoadGroup* aLoadGroup); virtual ~nsCacheEntryChannel(); diff --git a/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp b/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp index f6c21f32676..ab75a68bd04 100644 --- a/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp +++ b/mozilla/netwerk/cache/mgr/nsCachedNetData.cpp @@ -35,6 +35,7 @@ #include "nsIBinaryOutputStream.h" #include "nsISupportsArray.h" #include "nsIArena.h" +#include "nsITransport.h" #include "nsCRT.h" #include "nsString.h" @@ -1178,19 +1179,18 @@ public: rv = mCacheEntry->NewChannel(0, getter_AddRefs(mChannel)); if (NS_FAILED(rv)) return rv; - rv = mChannel->SetTransferOffset(aStartingOffset); - if (NS_FAILED(rv)) return rv; - - return mChannel->OpenOutputStream(getter_AddRefs(mCacheStream)); + nsCOMPtr transport = do_QueryInterface(mChannel); + return transport->OpenOutputStream(aStartingOffset, -1, 0, + getter_AddRefs(mCacheStream)); } NS_DECL_ISUPPORTS - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { - return mOriginalListener->OnStartRequest(channel, ctxt); + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { + return mOriginalListener->OnStartRequest(request, ctxt); } - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { if (NS_FAILED(aStatus)) { mCacheEntry->SetFlag(nsCachedNetData::TRUNCATED_CONTENT); @@ -1208,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(channel, ctxt, aStatus, aStatusArg); + return mOriginalListener->OnStopRequest(request, ctxt, aStatus, aStatusArg); } - NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { mOriginalStream = inStr; - return mOriginalListener->OnDataAvailable(channel, ctxt, + return mOriginalListener->OnDataAvailable(request, ctxt, NS_STATIC_CAST(nsIInputStream*, this), sourceOffset, count); } diff --git a/mozilla/netwerk/macbuild/netwerk.mcp b/mozilla/netwerk/macbuild/netwerk.mcp index 013249ee8e1777ce2ee811c2342463983e5b0847..8cf00b99d3901498213e277ee6bd131a3f7351ba 100644 GIT binary patch delta 5045 zcmeHLX;f547Or|U(2Zbvi| zRrgihy7xBEe|!=0@LOx*v;_<1F~$NI;~kmSwvlOR4;hOB#m>E(xJzqSPZDFH5sXC= zThG=IbQsvw#B8^JWy<5kZ7tI?WLT#^!3-GZ1;!FdgJcryb&qEv0!Lj!Q>gB0L4tJHa-Wa~PXMR_JBu zO91Ax1_6D^@lEkuTss6tk%yHWJ53M~^~}MRyoyUD;e?n%|SDg#^L@#(>x$?r{gfCst!)#b?2W zo|jA>vWOXPbt%VftQ@eUeg|91oLt(kXScM%Gc2?L)VWPq~h4Bj8D@;|Gq%avc zo?h%yM2f;Jg_#QbDeS3mnZjNQdn@c?qL^CQBOX>?P;9os0aAOYG9?AtL5j^$n5%HG zob_#`t2Jf~RqQayCRHWi68l%R<(imMl|(Z-s2NM;jLND+Vn-=8huwIX@pU zev%tWKrPNPd-38@2%$<@q;RUjVujNbPFFZX;Y@|I6wX%os=_%EMRv85d^1ncB_@hl z)yeI^E_iN72?1p@7GXo0nprAm9;$8wzhAB%lY%reHwz3S9WX*+w27jZXC_%qH&-G( z6fRas1qmhKufyD)+*+0I(eZ7Jt3wxZ&)_JdV)QL8o(#Dx^3nrERACww6VVu*;c;8V zfY=(tIl3&+$bDc9Fmm^Y2FRMz7;T~4PBM#+JKZ9_$d5wh94PXJJF!+OjX4EvxWDQc zw}$HPr||@%;>;6^$34inv&N!%M#LBug%^7rLrq+9en$E`2tI%BDGuRxwl zN-UYJpCfevQeMiK19>evTKFZsi1dT^w0J2i5DJ=)HY!1{ z-h;Q>A=~98O#chy4Wz^+w9(Je^6&?EkWOX?*Fml%E&e*u^n0Z5yc|U!$Xw5^o`Pbd zsb<6Tbk|G~I3L$)C!;Z#rb5^!@b;(r0dOv45HZY>U(%_)0&v zSF0@NVKAU>+2?Ktr7kC=^#D4}jrjuUM$PX+#up-xRnGYOybK;ugvKl0WGqN-)Vu8s zFy<#Dzq1&}vNx%4)f3BD+87Kn;=Ma=Kt4b$>`;MFC%gAA$OnmKY-A@4 zG6lR3oRAL@%lM!eyr0L(9eL<9=P}5f@D&qxgjj5df-A$E@0;`rWZEnY{c`KG z9Pt&zf_cZ}S;S~yM`{0W6u8GEZ#x5Yl`LK~PanBYD=Fve;Ogce%pDHpyK-U|+LR1J z@BJ*u$4#DB0z+%0;jhWH6N2{AZahLHH>J?E8|hnTg%2AoPA22=atf ze82r!5PIt<#r%?g1aGJy^vxLy4!;1@y8HoyyeeP*&mf;97FR;)uCD47UBfA2G5hubAS|H!Q9(HW8f0=k+EBVnb+XP@$P^oBLoZ;EC-X(# zflSY6BPkQq$!wH@7l~!OiQ-5F;dQDd9}$iJ`&s&25PB)Keq$=w6Z!&`LFlcbH2tmQ yM-2h0AY4T?00jn3<5ev|*oC}y+2mPz98d+}=ifuVBKiFNz*LGM|G9lyPwn6Aj(Ao8 delta 9060 zcmb_h33QZ2wyyg7&(_(O4oP>X(+QA-uqGgD3<*nQa}1k7;UOV}HIR@62m&1!7D0qi z3@tbeQO6OGD6!R`gAQ+SJfbp+`grpg4v#m;A_}+-I*8_dx2ig6mNVzfymxbM-S7XZ z{#tLf!QB3`Dt=uH#Ko}^?4C3`5@D-MKp z6-T1_2-oNg;joU2;GClmoFUyQ4u++Pn)nZ1tv3?6m=a3WCW`RLlpy3XhV0H_f94F| z2JYr!VB)%<-C+0l-b`F>cBBumbfz^L3EAoBCI{4#8T7M zx@8TIHIk^`T7ZHu4id(nz29MZbt&@2`p&z>SNG=2t{k&v`dZx8y!8ogM9SXA(5Usu zsj7InxYonsi>fJQ;1q3}Q+ z3yp)uLldAjXd<)|6z;;4p?0VP>V&4CzMo+^^DyoL$b`aSc{gY_v^z8n+6CGJ+7sFf z>V|fOW(WxgnK6zaC^wkYv zfAUA}tsKS^iD4}FDaoYlp;^T%N=%8jzqa#7S6kcOI9bHlYkC(C;|U=ZTbbNvFDLW(m{eVPYj73Y;ot#-A84ZX_D7EgCItT{&_c zspA(Fr{4QbA9;{4V}I(@>Mv1fr7pCJ@_nnC|H8e^ZTyJn^SbGKZ$vHkd79yTv@MG9+VxR_UBqm8j8llD`Bc*zwkcIGzu>|?5fd>dYl2@=IcR^PQfI8HVoo3_R#HPcMf_AWTbe6c7k?8&X`#eZ&K5X+oVB_h&`6Vgb7gBN1E`EB{8Z)?P zQn9T0X%YIV`lI$I2i z_Ntj%F;ixbs4Nq)E0RTCO@tWpaHROA)+XyXSm%)TWL=sFuaAnowJP@#yKt_+fwLq| zTwNJwL9fJgk0VBw9A3F_Vd)IKQi<>5tl=ivdsY$c&pNOfFTRZ|Z8`q1m@73Lm)b!bDXCwtA($eOwJy$pIbsbyZ5h z)A;3yd4U5hE*|bK9$9qjNM*)t+@WcC`zpQJ0gu&oifZrri1L|rb8hmRmSt}LTpwGO z;)j7fQM-%?9@ zdp}Xt1~|+5`qUd*gvaT_ytnTH#l1BXk%P;kU_zfDJPJ-xJt;NS^(d+3tD zmA$(rH6ZU|y?=M8k-#TzUZ5KtBc(Pe^LAaije`i!^7ifd)bjSlY`kF?d{ArmKJo{i zA`VSHB@Wp_eJy=I35koq-9g?>Cd?&G^H9JPJ*Ync{fxTO^_h>s_+X>oE)OM1#lcg0UL;L68 z?GnvS(e^%V>$SaK+vU=Vw}v{y@YXc>=sco6Iv$QSO zcDA;2w4JN%JZ}AV3O1 zlo0aNas(~3#p5qo9Zi|H_-6(f{dSh|0 zJVm0{ZLoUmhcP0W5{UiJNGQmG*eU#>U+ zehiqFhxpyV=%BF?vAv(A8%QP@n<8NH`)S>l1f85&ci2)QM{8aPYi z=YcU&$^QvBTVwbYh2$h%FenPiCHCaufwmN+ODQmUJmEFKy)}Lo7%@6Ym&3q08h-(t zt8iB=7sc)*T?YZfUnHIie22!XfctCw8{h$q&6kBfzyn4n@nv9CK$1bDAFOc!@DPou zqv$wE24;|c43PL~VEiZ`@!P;dH9ikq;M+AU)@UrALg(wD*rPWQ3_e66MZ!CVBhx=NN8-`g@IN^SvyA1ys zc!;9qslJzn;~;E5GdDNi3pV-rwNLZtEfpcYwNpYP(q%9l*tq~gU3EoE=Q^ChQ}vf6Y7N5|iM8OER*3qQZ@nEXewujzPX(Er!qo@w30jfnOEt3&^vY(Z7gSRB&&l*O2y z_77$=f-{T$Ne@e~@)N7YKhytG!~axE)|*;ZU$vXr#$wy;+~C%ZtJghjN(24myRfDf zM{0oZnK(+LiLVG?0sAh%51Yg+xfqc}vj9Hj>Sy$tk z++ZApMvsM6H8>Ol%M3(Yp|cj&&Osjnc}q;|xD3O^jmKxSR%9A$4NnsqOj=l3iwXke zo(<@1OjULHY-aRrMoyW^wa~V=OP;@j6PL|W{MH7>q7Eqj4LUK)75^;C2PY{0><)1F zJV3au0Y90|ud4P?1EJxd<`9qGPC#ymYB-T*W3Hsx%j@wQxatr;M`d+~Umu5e+^YQg z&%nzQ3T5vD&Q}d@dk+{hLJ~RxNtEKB{*=C_dYMAeFq^3|Hq(d~LLs5AAWV?hONeFcAO;>} z(`y_y3d~Z;v#>Q@vxm{kbG4v-?TlfxL^K*YnTyrh(bARE@;oSc7Ka(}FJ0Pyf?FYZ z9tkJaOK0??@6}4h$7Xdb-S01fTP1mB&4tac@<``9w;2zZB@!!5rCK{^oiX@2@OmgD5}$89GCu1w;0?rr>WV~-jL(b#ewU*-_h3mrKH)gbnmCVjE&x7 zImWWq*ZUbm4g7=STXf%&D|>0){{;%3k%js9nCGBS#Xs^Va5QzOHvv87YA2W%lfj%- z{PpfAKTVbQTELx?JljWWt?U2jGVpoH8(n^2EW|TOy>KT@+Xa=;gH9GwxUaaaQFq2`wD;H^}Uu}*owv|~K8nfXvQ9>P^doE=tuiOjUOz*7Z~xG6}K ztD7^w1s^GCR)pKJ-eP7YJY7dwJnveEuk64zJ;UmgXF z(LwkYOu65yUr7fchl&o(My~dioO$5mRe3MgN&AW!(*Qm}^2S}@{Z3u=4tSg7JuGP$ zfI5%O2wJ~HnZe?ogw;#12_CCsIu^GNygDSz?=k)U@GcI^=U;-^mEdV>LJHH6sN>j- z%>Yj`4571yCwbKNJB>5c|4+LV{;05sgsK1w4t4%&SP`^9`GrWHaN~}{V6q< z4*>6yJWKiwtU8X(mvA=lRLS#0DDU4L%RD$_xLam0+bLMRJs!gT*1;tIqZb2fQXPH2 z3_O+r!aqi1`nqIhVN^QCG{#hS?2bOva2Hvgb?XVNZcFB`J_5%1Pu~sx=dm5zW6CxV zm?n~J>}mh*7`YLArs9)6fYnRW@B;WO&7X$VOYJf?vw0|ZI6O(xRcc>* z^)@(!KZ<><0a$%d%mdSad&u(4O>3%m$Mst97!gS_?Q>mE{Ydb1ae%B}1FSwk=C$*{ z^ksuNIn}>AJj^UR2&Rw9_-~BTzdf#nfX87$B5)e|cSq)E;9N=b&wkmlJ0@T({wUd9 zf_%L@hCd4)GYR3Jf8DV=HeLtefyYCPijy7N0VTKI#lP2-{{yKCB@*e{v`Bs4|Yd1-P_D5EyyS!`hNi< C-_=_H diff --git a/mozilla/netwerk/macbuild/netwerkIDL.mcp b/mozilla/netwerk/macbuild/netwerkIDL.mcp index e9d5e3c41dff000a00ce69ae3c583a46fa3f7bfa..ad6bed27141bca1fe735980dc677615e7446c087 100644 GIT binary patch delta 363 zcmZoU&C+t3WrH^_uNwmcLjog^0OF9%5xi!+tQ;Xg?&QXejuQjgRSSUZ1_lO>R0akf 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 delta 322 zcmZoU&C+t3WrH^_uPXxsLjog^0OH`y5xi!+(=}KaB_;-J70d^UHZU-7gfKAh0GSN= z(-TA(#Wy!guVb8SD%&_QfMxSGSrJA7pp**`ColmCAP$=7C^=b2RcbS@ydC4@Qv1x! zTNGS)Ctuwzy}6ZM%RZqX8pO!*Ryx{4$J!U_Sw!3 channel; + nsCOMPtr transport; 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(channel)) ; + rv = fts->CreateTransport(mFile, PR_WRONLY|PR_CREATE_FILE, PR_IRWXU, getter_AddRefs(transport)) ; if(NS_FAILED(rv)) return rv ; // we don't need to worry about notification callbacks nsCOMPtr stream; - rv = channel->OpenOutputStream( getter_AddRefs( stream ) ) ; + rv = transport->OpenOutputStream(0, -1, 0, getter_AddRefs( stream ) ) ; if(NS_FAILED(rv)) return rv ; nsCOMPtr enumerator; @@ -683,20 +683,19 @@ private: nsresult nsXMLMIMEDataSource::InitFromFile( nsIFile* aFile ) { + nsresult rv; + nsCOMPtr transport; - 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 ; + 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 ; // we don't need to worry about notification callbacks nsCOMPtr stream; - rv = channel->OpenInputStream( getter_AddRefs( stream ) ) ; + rv = transport->OpenInputStream(0, -1, 0, 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 bb6882e5542..7ec85a896ce 100644 --- a/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp +++ b/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp @@ -305,26 +305,15 @@ nsDataChannel::SetURI(nsIURI* aURI) // This class NS_IMETHODIMP -nsDataChannel::OpenInputStream(nsIInputStream **_retval) +nsDataChannel::Open(nsIInputStream **_retval) { - // XXX we should honor the startPosition and count passed in. - - *_retval = mDataStream; - NS_ADDREF(*_retval); - + NS_ENSURE_ARG_POINTER(_retval); + NS_ADDREF(*_retval = mDataStream); return NS_OK; } NS_IMETHODIMP -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) +nsDataChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) { nsresult rv; nsCOMPtr eventQ; @@ -352,19 +341,9 @@ nsDataChannel::AsyncRead(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) { @@ -416,83 +395,6 @@ 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) { @@ -526,6 +428,7 @@ 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; @@ -538,9 +441,10 @@ nsDataChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCall return NS_OK; } -NS_IMETHODIMP -nsDataChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +NS_IMETHODIMP +nsDataChannel::GetSecurityInfo(nsISupports **sec) { - *aSecurityInfo = nsnull; + NS_ENSURE_ARG_POINTER(sec); + *sec = nsnull; return NS_OK; } diff --git a/mozilla/netwerk/protocol/data/src/nsDataChannel.h b/mozilla/netwerk/protocol/data/src/nsDataChannel.h index c1694c237e3..6e0ee4b7b2c 100644 --- a/mozilla/netwerk/protocol/data/src/nsDataChannel.h +++ b/mozilla/netwerk/protocol/data/src/nsDataChannel.h @@ -63,8 +63,6 @@ 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 082a0a6cc27..bffed0e9da7 100644 --- a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp @@ -28,6 +28,8 @@ #include "nsIInterfaceRequestor.h" #include "nsXPIDLString.h" #include "nsISocketTransportService.h" +#include "nsITransport.h" +#include "nsIProgressEventSink.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -41,7 +43,11 @@ 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) @@ -156,57 +162,48 @@ nsDateTimeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsDateTimeChannel::OpenInputStream(nsIInputStream **_retval) +nsDateTimeChannel::Open(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, 32, 32, getter_AddRefs(channel)); + nsCOMPtr transport; + rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + transport->SetProgressEventSink(sink); + } - return channel->OpenInputStream(_retval); + return transport->OpenInputStream(0, -1, 0, _retval); } NS_IMETHODIMP -nsDateTimeChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("nsDateTimeChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener, - nsISupports *ctxt) +nsDateTimeChannel::AsyncOpen(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, 0, 32, 32, getter_AddRefs(channel)); + nsCOMPtr transport; + rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + transport->SetProgressEventSink(sink); + } mListener = aListener; - - return channel->AsyncRead(this, ctxt); -} - -NS_IMETHODIMP -nsDateTimeChannel::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt) -{ - NS_NOTREACHED("nsDateTimeChannel::AsyncWrite"); - return NS_ERROR_NOT_IMPLEMENTED; + + nsCOMPtr request; + return transport->AsyncRead(this, ctxt, 0, -1, 0, getter_AddRefs(request)); } NS_IMETHODIMP @@ -256,83 +253,6 @@ 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) { @@ -345,11 +265,11 @@ NS_IMETHODIMP nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) { if (mLoadGroup) // if we already had a load group remove ourselves... - (void)mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); + (void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); mLoadGroup = aLoadGroup; if (mLoadGroup) { - return mLoadGroup->AddChannel(this, nsnull); + return mLoadGroup->AddRequest(this, nsnull); } return NS_OK; } @@ -384,25 +304,26 @@ nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification return NS_OK; } -NS_IMETHODIMP -nsDateTimeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +NS_IMETHODIMP +nsDateTimeChannel::GetSecurityInfo(nsISupports **sec) { - *aSecurityInfo = nsnull; + NS_ENSURE_ARG_POINTER(sec); + *sec = nsnull; return NS_OK; } // nsIStreamObserver methods NS_IMETHODIMP -nsDateTimeChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { +nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { return mListener->OnStartRequest(this, aContext); } NS_IMETHODIMP -nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, +nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { if (mLoadGroup) { - nsresult rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); + nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } return mListener->OnStopRequest(this, aContext, aStatus, aStatusArg); @@ -411,7 +332,7 @@ nsDateTimeChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsDateTimeChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, +nsDateTimeChannel::OnDataAvailable(nsIRequest *request, 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 e80a83681c8..278f9c7a198 100644 --- a/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h +++ b/mozilla/netwerk/protocol/datetime/src/nsDateTimeChannel.h @@ -39,7 +39,10 @@ #include "nsIStreamListener.h" -class nsDateTimeChannel : public nsIChannel, public nsIStreamListener { +class nsDateTimeChannel +: public nsIChannel, + public nsIStreamListener { + public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -67,8 +70,6 @@ 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 0d31cc4be18..fecc229fa77 100644 --- a/mozilla/netwerk/protocol/file/public/nsIFileChannel.idl +++ b/mozilla/netwerk/protocol/file/public/nsIFileChannel.idl @@ -1,131 +1 @@ -/* -*- 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); -}; - +/* see nsIChannel.idl */ \ No newline at end of file diff --git a/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl b/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl index 1e2e0a4df7b..837df187d6b 100644 --- a/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl +++ b/mozilla/netwerk/protocol/file/public/nsIFileProtocolHandler.idl @@ -1,38 +1 @@ -/* -*- 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); -}; +/* remove */ \ No newline at end of file diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index 77be1784ed1..b0f51bee115 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 (mFileTransport) - return mFileTransport->GetName(result); + if (mCurrentRequest) + return mCurrentRequest->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 (mFileTransport) - return mFileTransport->IsPending(result); + if (mCurrentRequest) + return mCurrentRequest->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 (mFileTransport) - return mFileTransport->Cancel(status); + if (mCurrentRequest) + return mCurrentRequest->Cancel(status); return NS_OK; } @@ -167,8 +167,8 @@ nsFileChannel::Suspend() NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif - if (mFileTransport) - return mFileTransport->Suspend(); + if (mCurrentRequest) + return mCurrentRequest->Suspend(); return NS_OK; } @@ -179,8 +179,8 @@ nsFileChannel::Resume() NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif - if (mFileTransport) - return mFileTransport->Resume(); + if (mCurrentRequest) + return mCurrentRequest->Resume(); return NS_OK; } @@ -230,35 +230,14 @@ nsFileChannel::EnsureTransport() getter_AddRefs(mFileTransport)); if (NS_FAILED(rv)) return rv; - 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; - } + if (mCallbacks && !(mLoadAttributes & LOAD_BACKGROUND)) + (void)mFileTransport->SetProgressEventSink(this); + return rv; } NS_IMETHODIMP -nsFileChannel::OpenInputStream(nsIInputStream **result) +nsFileChannel::Open(nsIInputStream **result) { nsresult rv; @@ -268,7 +247,7 @@ nsFileChannel::OpenInputStream(nsIInputStream **result) rv = EnsureTransport(); if (NS_FAILED(rv)) goto done; - rv = mFileTransport->OpenInputStream(result); + rv = mFileTransport->OpenInputStream(0, -1, 0, result); done: if (NS_FAILED(rv)) { // release the transport so that we don't think we're in progress @@ -277,12 +256,14 @@ nsFileChannel::OpenInputStream(nsIInputStream **result) return rv; } +// XXX What does OpenOutputStream mean for a file "channel" +#if 0 NS_IMETHODIMP -nsFileChannel::OpenOutputStream(nsIOutputStream **result) +nsFileChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **result) { nsresult rv; - if (mFileTransport) + if (mCurrentRequest) return NS_ERROR_IN_PROGRESS; mIOFlags |= PR_WRONLY; @@ -290,18 +271,19 @@ nsFileChannel::OpenOutputStream(nsIOutputStream **result) rv = EnsureTransport(); if (NS_FAILED(rv)) goto done; - rv = mFileTransport->OpenOutputStream(result); + rv = mFileTransport->OpenOutputStream(transferOffset, transferCount, 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::AsyncRead(nsIStreamListener *listener, - nsISupports *ctxt) +nsFileChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; @@ -333,72 +315,23 @@ nsFileChannel::AsyncRead(nsIStreamListener *listener, } } - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } rv = EnsureTransport(); if (NS_FAILED(rv)) goto done; - - rv = mFileTransport->AsyncRead(tempListener, ctxt); + + rv = mFileTransport->AsyncRead(tempListener, ctxt, 0, -1, 0, + getter_AddRefs(mCurrentRequest)); 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; - } - 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"); + nsresult rv2 = mLoadGroup->RemoveRequest(this, ctxt, rv, nsnull); // XXX fix error message + NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveRequest failed"); // release the transport so that we don't think we're in progress mFileTransport = nsnull; + mCurrentRequest = nsnull; } return rv; } @@ -430,7 +363,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); @@ -481,84 +414,6 @@ 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) { @@ -623,7 +478,7 @@ nsFileChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) +nsFileChannel::OnStartRequest(nsIRequest* request, nsISupports* context) { #ifdef DEBUG NS_ASSERTION(mInitiator == PR_CurrentThread(), @@ -638,7 +493,7 @@ nsFileChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context } NS_IMETHODIMP -nsFileChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, +nsFileChannel::OnStopRequest(nsIRequest* request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { #ifdef DEBUG @@ -653,18 +508,19 @@ nsFileChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, if (mLoadGroup) { if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); + mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); } } // Release the reference to the consumer stream listener... - mRealListener = null_nsCOMPtr(); - mFileTransport = null_nsCOMPtr(); + mRealListener = 0; + mFileTransport = 0; + mCurrentRequest = 0; return rv; } NS_IMETHODIMP -nsFileChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, +nsFileChannel::OnDataAvailable(nsIRequest* request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -683,8 +539,8 @@ nsFileChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* contex // insure that the transport will go away even if it is blocked waiting // for the consumer to empty the pipe... // - if (NS_FAILED(rv)) { - mFileTransport->Cancel(rv); + if (NS_FAILED(rv) && mCurrentRequest) { + mCurrentRequest->Cancel(rv); } return rv; } @@ -713,7 +569,7 @@ nsFileChannel::GetInterface(const nsIID &anIID, void **aResult ) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsFileChannel::OnStatus(nsIChannel *aChannel, nsISupports* ctxt, +nsFileChannel::OnStatus(nsIRequest *request, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -724,7 +580,7 @@ nsFileChannel::OnStatus(nsIChannel *aChannel, nsISupports* ctxt, } NS_IMETHODIMP -nsFileChannel::OnProgress(nsIChannel* aChannel, +nsFileChannel::OnProgress(nsIRequest *request, 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 f4a82c91f19..2ec12647eb2 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.h +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.h @@ -38,6 +38,7 @@ #include "nsCOMPtr.h" #include "nsIFile.h" /* Solaris/gcc needed this here. */ #include "nsIProgressEventSink.h" +#include "nsITransport.h" class nsFileChannel : public nsIFileChannel, public nsIInterfaceRequestor, @@ -72,7 +73,7 @@ protected: nsCOMPtr mCallbacks; PRInt32 mIOFlags; PRInt32 mPerm; - nsCOMPtr mFileTransport; + nsCOMPtr mFileTransport; nsCString mContentType; PRUint32 mLoadAttributes; nsCOMPtr mLoadGroup; @@ -84,6 +85,7 @@ 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 f85e08414cf..c43dadd3a62 100644 --- a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.cpp +++ b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.cpp @@ -32,6 +32,7 @@ #include "nsMimeTypes.h" #include "nsIStreamConverterService.h" #include "nsITXTToHTMLConv.h" +#include "nsIProgressEventSink.h" #include "nsNetUtil.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); @@ -53,8 +54,11 @@ 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) @@ -144,8 +148,8 @@ nsFingerChannel::Cancel(nsresult status) nsresult rv = NS_ERROR_FAILURE; mStatus = status; - if (mTransport) { - rv = mTransport->Cancel(status); + if (mTransportRequest) { + rv = mTransportRequest->Cancel(status); } return rv; } @@ -198,60 +202,48 @@ nsFingerChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsFingerChannel::OpenInputStream(nsIInputStream **_retval) +nsFingerChannel::Open(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(channel)); + BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + mTransport->SetProgressEventSink(sink); + } - return channel->OpenInputStream(_retval); + return mTransport->OpenInputStream(0, -1, 0, _retval); } NS_IMETHODIMP -nsFingerChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("nsFingerChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt) +nsFingerChannel::AsyncOpen(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(channel)); + BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; - rv = channel->SetNotificationCallbacks(mCallbacks); - if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) + mTransport->SetProgressEventSink(sink); + } mListener = aListener; mResponseContext = ctxt; - mTransport = channel; - return SendRequest(channel); -} - -NS_IMETHODIMP -nsFingerChannel::AsyncWrite(nsIStreamProvider *provider, - nsISupports *ctxt) -{ - NS_NOTREACHED("nsFingerChannel::AsyncWrite"); - return NS_ERROR_NOT_IMPLEMENTED; + return SendRequest(mTransport); } NS_IMETHODIMP @@ -301,83 +293,6 @@ 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) { @@ -432,7 +347,7 @@ nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) // nsIStreamObserver methods NS_IMETHODIMP -nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { +nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { if (!mActAsObserver) { // acting as a listener return mListener->OnStartRequest(this, mResponseContext); @@ -445,14 +360,14 @@ nsFingerChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { NS_IMETHODIMP -nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, +nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (NS_FAILED(aStatus) || !mActAsObserver) { if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); + rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } rv = mListener->OnStopRequest(this, mResponseContext, aStatus, aStatusArg); @@ -487,7 +402,8 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, converter->PreFormatHTML(PR_TRUE); } - return aChannel->AsyncRead(converterListener, mResponseContext); + return mTransport->AsyncRead(converterListener, mResponseContext, 0,-1, 0, + getter_AddRefs(mTransportRequest)); } } @@ -495,7 +411,7 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, // nsIStreamListener method NS_IMETHODIMP -nsFingerChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, +nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext, nsIInputStream *aInputStream, PRUint32 aSourceOffset, PRUint32 aLength) { mContentLength = aLength; @@ -503,7 +419,7 @@ nsFingerChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, } nsresult -nsFingerChannel::SendRequest(nsIChannel* aChannel) { +nsFingerChannel::SendRequest(nsITransport* aTransport) { // The text to send should already be in mUser nsresult rv = NS_OK; @@ -512,7 +428,7 @@ nsFingerChannel::SendRequest(nsIChannel* aChannel) { nsCString requestBuffer(mUser); if (mLoadGroup) { - mLoadGroup->AddChannel(this, nsnull); + mLoadGroup->AddRequest(this, nsnull); } requestBuffer.Append(CRLF); @@ -525,9 +441,10 @@ nsFingerChannel::SendRequest(nsIChannel* aChannel) { charstream = do_QueryInterface(result, &rv); if (NS_FAILED(rv)) return rv; - rv = aChannel->SetTransferCount(requestBuffer.Length()); - if (NS_FAILED(rv)) return rv; - rv = NS_AsyncWriteFromStream(aChannel, charstream, this, nsnull); + rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest), + aTransport, charstream, + 0, requestBuffer.Length(), 0, + this, nsnull); return rv; } diff --git a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h index dc24c0e6d24..e77455dc689 100644 --- a/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h +++ b/mozilla/netwerk/protocol/finger/src/nsFingerChannel.h @@ -33,9 +33,12 @@ #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 @@ -74,11 +77,12 @@ protected: nsXPIDLCString mRequest; nsCOMPtr mResponseContext; - nsCOMPtr mTransport; + nsCOMPtr mTransport; + nsCOMPtr mTransportRequest; nsresult mStatus; protected: - nsresult SendRequest(nsIChannel* aChannel); + nsresult SendRequest(nsITransport* aTransport); }; #endif /* nsFingerChannel_h___ */ diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 6e69cc6984f..074591e459e 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -49,8 +49,6 @@ nsFTPChannel::nsFTPChannel() mAmount(0), mContentLength(-1), mFTPState(nsnull), - mBufferSegmentSize(0), - mBufferMaxSize(0), mLock(nsnull), mStatus(NS_OK), mProxyPort(-1), @@ -74,7 +72,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS8(nsFTPChannel, nsIChannel, nsIFTPChannel, nsIProxy, - nsIRequest, + nsIRequest, nsIInterfaceRequestor, nsIProgressEventSink, nsIStreamListener, @@ -226,29 +224,20 @@ nsFTPChannel::SetURI(nsIURI* aURL) } NS_IMETHODIMP -nsFTPChannel::OpenInputStream(nsIInputStream **result) +nsFTPChannel::Open(nsIInputStream **result) { if (mProxyChannel) - return mProxyChannel->OpenInputStream(result); - NS_NOTREACHED("nsFTPChannel::OpenInputStream"); + return mProxyChannel->Open(result); + NS_NOTREACHED("nsFTPChannel::Open"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -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) +nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; - PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFTPChannel::AsyncRead() called\n")); + PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFTPChannel::AsyncOpen() called\n")); mListener = listener; mUserContext = ctxt; @@ -262,17 +251,12 @@ nsFTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) } if (mLoadGroup) { - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } if (mProxyChannel) { - // 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); + return mProxyChannel->AsyncOpen(this, ctxt); } //////////////////////////////// @@ -282,8 +266,7 @@ nsFTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) if (!mFTPState) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mFTPState); } - rv = mFTPState->Init(this, mPrompter, - mBufferSegmentSize, mBufferMaxSize); + rv = mFTPState->Init(this, mPrompter); if (NS_FAILED(rv)) return rv; rv = mFTPState->SetStreamListener(this, ctxt); @@ -292,52 +275,6 @@ nsFTPChannel::AsyncRead(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) { @@ -409,83 +346,6 @@ 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) { @@ -559,10 +419,9 @@ nsFTPChannel::GetInterface(const nsIID &anIID, void **aResult ) { } } - // nsIProgressEventSink methods NS_IMETHODIMP -nsFTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, +nsFTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { if (!mEventSink) @@ -580,7 +439,7 @@ nsFTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, } NS_IMETHODIMP -nsFTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, +nsFTPChannel::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { return mEventSink ? mEventSink->OnProgress(this, aContext, aProgress, (PRUint32) mContentLength) : NS_OK; } @@ -588,13 +447,13 @@ nsFTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, // nsIStreamObserver methods. NS_IMETHODIMP -nsFTPChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, +nsFTPChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mLoadGroup) { - rv = mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); + rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); if (NS_FAILED(rv)) return rv; } @@ -611,7 +470,7 @@ nsFTPChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, } NS_IMETHODIMP -nsFTPChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { +nsFTPChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) { nsresult rv = NS_OK; if (mObserver) { rv = mObserver->OnStartRequest(this, aContext); @@ -628,7 +487,7 @@ nsFTPChannel::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { // nsIStreamListener method NS_IMETHODIMP -nsFTPChannel::OnDataAvailable(nsIChannel* aChannel, nsISupports* aContext, +nsFTPChannel::OnDataAvailable(nsIRequest *request, 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 b58db0f1087..d3f75902e5c 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -42,6 +42,18 @@ #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, @@ -92,14 +104,13 @@ 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 9d4a327a0ce..029143f37e6 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -19,6 +19,7 @@ * * Contributor(s): */ +#include "nsFTPChannel.h" #include "nsFtpConnectionThread.h" #include "nsFtpControlConnection.h" #include "nsFtpProtocolHandler.h" @@ -47,17 +48,86 @@ 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, @@ -81,9 +151,7 @@ nsFtpState::nsFtpState() { mLastModified = LL_ZERO; mWriteCount = 0; - mBufferSegmentSize = 0; - mBufferMaxSize = 0; - + mControlReadContinue = PR_FALSE; mControlReadBrokenLine = PR_FALSE; @@ -102,11 +170,11 @@ nsFtpState::~nsFtpState() // nsIStreamListener implementation NS_IMETHODIMP -nsFtpState::OnDataAvailable(nsIChannel *aChannel, - nsISupports *aContext, - nsIInputStream *aInStream, - PRUint32 aOffset, - PRUint32 aCount) +nsFtpState::OnDataAvailable(nsIRequest *request, + nsISupports *aContext, + nsIInputStream *aInStream, + PRUint32 aOffset, + PRUint32 aCount) { if (aCount == 0) return NS_OK; /*** should this be an error?? */ @@ -127,6 +195,11 @@ nsFtpState::OnDataAvailable(nsIChannel *aChannel, 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. @@ -217,7 +290,7 @@ nsFtpState::OnDataAvailable(nsIChannel *aChannel, // nsIStreamObserver implementation NS_IMETHODIMP -nsFtpState::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) +nsFtpState::OnStartRequest(nsIRequest *request, nsISupports *aContext) { #if defined(PR_LOGGING) nsXPIDLCString spec; @@ -230,7 +303,7 @@ nsFtpState::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) } NS_IMETHODIMP -nsFtpState::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsFtpState::OnStopRequest(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) nsFtpState::OnStopRequest() rv=%d\n", this, aStatus)); @@ -278,17 +351,14 @@ nsFtpState::EstablishControlConnection() rv = mURL->GetHost(getter_Copies(host)); if (NS_FAILED(rv)) return rv; - nsCOMPtr channel; + nsCOMPtr transport; // build our own - rv = CreateTransport(host, mPort, - FTP_COMMAND_CHANNEL_SEG_SIZE, - FTP_COMMAND_CHANNEL_MAX_SIZE, - getter_AddRefs(channel)); // the command channel + rv = CreateTransport(host, mPort, getter_AddRefs(transport)); // the command transport if (NS_FAILED(rv)) return rv; mState = FTP_READ_BUF; - mControlConnection = new nsFtpControlConnection(channel); + mControlConnection = new nsFtpControlConnection(transport); if (!mControlConnection) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mControlConnection); @@ -1126,7 +1196,6 @@ nsFtpState::R_cwd() { // update mURL->SetPath(mCwd); - #ifdef FTP_NO_HTTP_INDEX_FORMAT nsresult rv = mChannel->SetContentType("text/html"); #else @@ -1162,7 +1231,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; @@ -1252,12 +1321,18 @@ nsFtpState::S_list() { } mFireCallbacks = PR_FALSE; // listener callbacks will be handled by the transport. -#ifdef FTP_NO_HTTP_INDEX_FORMAT - return mDPipe->AsyncRead(mListener, nsnull); -#else - return mDPipe->AsyncRead(converterListener, mListenerContext); -#endif + DataRequestForwarder *forwarder = new DataRequestForwarder; + if (!forwarder) return NS_ERROR_FAILURE; + NS_ADDREF(forwarder); +#ifdef FTP_NO_HTTP_INDEX_FORMAT + fowarder->Init(mChannel, mListener); +#else + forwarder->Init(mChannel, converterListener); +#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 @@ -1281,7 +1356,15 @@ nsFtpState::S_retr() { mFireCallbacks = PR_FALSE; // listener callbacks will be handled by the transport. - return mDPipe->AsyncRead(mListener, mListenerContext); + 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; } FTP_STATE @@ -1323,12 +1406,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(mDPipe, mWriteStream, mObserver, mObserverContext); + return NS_AsyncWriteFromStream(getter_AddRefs(mDPipeRequest), mDPipe, mWriteStream, + 0, mWriteCount, 0, mObserver, mObserverContext); } FTP_STATE @@ -1348,8 +1431,8 @@ nsFtpState::S_pasv() { // Find IPv6 socket address, if server is IPv6 mIPv6Checked = PR_TRUE; PR_ASSERT(mIPv6ServerAddress == 0); - nsCOMPtr controlSocket; - mControlConnection->GetChannel(getter_AddRefs(controlSocket)); + nsCOMPtr controlSocket; + mControlConnection->GetTransport(getter_AddRefs(controlSocket)); if (!controlSocket) return FTP_ERROR; nsCOMPtr sTrans = do_QueryInterface(controlSocket, &rv); @@ -1460,8 +1543,7 @@ nsFtpState::R_pasv() { const char* hostStr = mIPv6ServerAddress ? mIPv6ServerAddress : host.GetBuffer(); // now we know where to connect our data channel - rv = CreateTransport(hostStr, port, mBufferSegmentSize, mBufferMaxSize, - getter_AddRefs(mDPipe)); // the data channel + rv = CreateTransport(hostStr, port, 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)); @@ -1472,12 +1554,16 @@ nsFtpState::R_pasv() { if (NS_FAILED(sTrans->SetReuseConnection(PR_FALSE))) return FTP_ERROR; // hook ourself up as a proxy for progress notifications - nsCOMPtr progressProxy(do_QueryInterface(mChannel)); - rv = mDPipe->SetNotificationCallbacks(progressProxy); - if (NS_FAILED(rv)) return FTP_ERROR; + nsCOMPtr requestor(do_QueryInterface(mChannel)); + if (requestor) { + nsCOMPtr sink = do_GetInterface(requestor); + if (sink) + mDPipe->SetProgressEventSink(sink); + } // 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) @@ -1570,15 +1656,11 @@ nsFtpState::IsPending(PRBool *result) nsresult rv = NS_OK; *result = PR_FALSE; - nsCOMPtr controlSocket; - mControlConnection->GetChannel(getter_AddRefs(controlSocket)); + nsCOMPtr request; + mControlConnection->GetReadRequest(getter_AddRefs(request)); - if (controlSocket) { - rv = controlSocket->IsPending(result); - if (NS_FAILED(rv)) return rv; - } - if (mDPipe) { - rv = mDPipe->IsPending(result); + if (request) { + rv = request->IsPending(result); if (NS_FAILED(rv)) return rv; } return rv; @@ -1607,8 +1689,8 @@ nsFtpState::Cancel(nsresult status) mCanceled = PR_TRUE; // kill the data connection immediately. - if (mDPipe) { - mDPipe->Cancel(status); + if (mDPipeRequest) { + mDPipeRequest->Cancel(status); } return NS_OK; @@ -1625,15 +1707,18 @@ nsFtpState::Suspend(void) // enough. if (mSuspendCount < 1) { mSuspendCount++; - nsCOMPtr controlSocket; - mControlConnection->GetChannel(getter_AddRefs(controlSocket)); - if (controlSocket) { - rv = controlSocket->Suspend(); + // only worry about the read request. + nsCOMPtr request; + mControlConnection->GetReadRequest(getter_AddRefs(request)); + + if (request) { + rv = request->Suspend(); if (NS_FAILED(rv)) return rv; } - if (mDPipe) { - rv = mDPipe->Suspend(); + + if (mDPipeRequest) { + rv = mDPipeRequest->Suspend(); if (NS_FAILED(rv)) return rv; } } @@ -1650,16 +1735,16 @@ nsFtpState::Resume(void) // cause the FTP state machine to unblock and // go on about it's business. if (mSuspendCount) { - // only a suspended thread can be resumed - nsCOMPtr controlSocket; - mControlConnection->GetChannel(getter_AddRefs(controlSocket)); - - if (controlSocket) { - rv = controlSocket->Resume(); + // only worry about the read request. + nsCOMPtr request; + mControlConnection->GetReadRequest(getter_AddRefs(request)); + + if (request) { + rv = request->Resume(); if (NS_FAILED(rv)) return rv; } - if (mDPipe) { - rv = mDPipe->Resume(); + if (mDPipeRequest) { + rv = mDPipeRequest->Resume(); if (NS_FAILED(rv)) return rv; } rv = NS_OK; @@ -1670,20 +1755,15 @@ nsFtpState::Resume(void) nsresult nsFtpState::Init(nsIFTPChannel* aChannel, - nsIPrompt* aPrompter, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize) { + nsIPrompt* aPrompter) { nsresult rv = NS_OK; mKeepRunning = PR_TRUE; mPrompter = aPrompter; - mBufferSegmentSize = bufferSegmentSize; - mBufferMaxSize = bufferMaxSize; - // parameter validation - NS_ASSERTION(aChannel, "FTP: thread needs a channel"); + NS_ASSERTION(aChannel, "FTP: needs a channel"); mChannel = aChannel; // a straight com ptr to the channel @@ -1768,8 +1848,9 @@ nsFtpState::KillControlConnnection() { // if the control goes away, the data socket goes away... if (mDPipe) { - mDPipe->SetNotificationCallbacks(nsnull); + mDPipe->SetProgressEventSink(nsnull); mDPipe = 0; + mDPipeRequest = 0; } mIPv6Checked = PR_FALSE; @@ -1823,9 +1904,12 @@ nsFtpState::StopProcessing() { // Clean up the event loop mKeepRunning = PR_FALSE; - - if (NS_FAILED(mInternalError) && mChannel) { - mChannel->Cancel(mInternalError); + + nsCOMPtr request = do_QueryInterface(mChannel); + + if (NS_FAILED(mInternalError) && mChannel && request) { + if (request) + request->Cancel(mInternalError); } KillControlConnnection(); @@ -1839,7 +1923,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(mChannel, mObserverContext, mInternalError, nsnull); + rv = asyncObserver->OnStopRequest(request, mObserverContext, mInternalError, nsnull); if (NS_FAILED(rv)) return rv; } @@ -1850,7 +1934,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(mChannel, mListenerContext, mInternalError, nsnull); + rv = asyncListener->OnStopRequest(request, mListenerContext, mInternalError, nsnull); if (NS_FAILED(rv)) return rv; } } @@ -1909,10 +1993,7 @@ nsFtpState::SetDirMIMEType(nsString& aString) { } nsresult -nsFtpState::CreateTransport(const char * host, PRInt32 port, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans) +nsFtpState::CreateTransport(const char * host, PRInt32 port, nsITransport** o_pTrans) { nsresult rv; @@ -1939,23 +2020,26 @@ nsFtpState::CreateTransport(const char * host, PRInt32 port, 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, bufferSegmentSize, - bufferMaxSize, o_pTrans); + return sts->CreateTransportOfType("socks", 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, proxyHost, proxyPort, + FTP_COMMAND_CHANNEL_SEG_SIZE, + FTP_COMMAND_CHANNEL_MAX_SIZE, o_pTrans); } } - return sts->CreateTransport(host, port, nsnull, -1, bufferSegmentSize, - bufferMaxSize, o_pTrans); + return sts->CreateTransport(host, port, nsnull, -1, + FTP_COMMAND_CHANNEL_SEG_SIZE, + FTP_COMMAND_CHANNEL_MAX_SIZE, o_pTrans); } nsresult @@ -1963,6 +2047,17 @@ 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 ebd7207727a..9db0e392ecb 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -40,6 +40,7 @@ #include "nsAutoLock.h" #include "nsIEventQueueService.h" #include "nsIPrompt.h" +#include "nsITransport.h" #include "nsFtpControlConnection.h" @@ -85,7 +86,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 @@ -95,10 +96,7 @@ public: nsFtpState(); virtual ~nsFtpState(); - nsresult Init(nsIFTPChannel *aChannel, - nsIPrompt *aPrompter, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize); + nsresult Init(nsIFTPChannel *aChannel, nsIPrompt *aPrompter); // use this to set an observer. nsresult SetStreamObserver(nsIStreamObserver *aObserver, nsISupports *aContext); @@ -143,9 +141,7 @@ private: nsresult Process(); virtual nsresult CreateTransport(const char * host, PRInt32 port, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans); + nsITransport** o_pTrans); void KillControlConnnection(); nsresult StopProcessing(); @@ -165,8 +161,8 @@ private: // ****** channel/transport/stream vars nsFtpControlConnection* mControlConnection;// cacheable control connection (owns mCPipe) - nsCOMPtr mDPipe; // the data channel transport - + nsCOMPtr mDPipe; // the data transport + nsCOMPtr mDPipeRequest; // ****** consumer vars nsCOMPtr mListener; // the consumer of our read events nsCOMPtr mListenerContext; // the context we pass through our read events @@ -216,7 +212,5 @@ 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 4547cb79dd9..b5ce505b84c 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 "nsNetUtil.h" +#include "nsIStreamProvider.h" #if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; @@ -35,19 +35,19 @@ class nsFtpStreamProvider : public nsIStreamProvider { public: NS_DECL_ISUPPORTS - nsFtpStreamProvider() { NS_INIT_REFCNT();} + nsFtpStreamProvider() { NS_INIT_ISUPPORTS(); } virtual ~nsFtpStreamProvider() {} // // nsIStreamObserver implementation ... // - 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; } + 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; } // // nsIStreamProvider implementation ... // - NS_IMETHODIMP OnDataWritable(nsIChannel *aChannel, nsISupports *aContext, + NS_IMETHODIMP OnDataWritable(nsIRequest *aRequest, 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(nsIChannel* socketTransport) +nsFtpControlConnection::nsFtpControlConnection(nsITransport* socketTransport) : mCPipe(socketTransport) { NS_INIT_REFCNT(); @@ -154,11 +154,17 @@ nsFtpControlConnection::Connect() NS_STATIC_CAST(nsFtpStreamProvider*, NS_STATIC_CAST(nsIStreamProvider*, provider))->mInStream = inStream; - rv = mCPipe->AsyncWrite(provider, NS_STATIC_CAST(nsISupports*, this)); + rv = mCPipe->AsyncWrite(provider, + NS_STATIC_CAST(nsISupports*, this), + 0, 0, 0, + getter_AddRefs(mWriteRequest)); 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); + rv = mCPipe->AsyncRead(NS_STATIC_CAST(nsIStreamListener*, this), + nsnull, 0, -1, 0, + getter_AddRefs(mReadRequest)); + if (NS_FAILED(rv)) return rv; mConnected = PR_TRUE; @@ -172,7 +178,8 @@ nsFtpControlConnection::Disconnect() PR_LOG(gFTPLog, PR_LOG_ALWAYS, ("(%x) nsFtpControlConnection disconnecting", this)); mConnected = PR_FALSE; - if (mCPipe) mCPipe->Cancel(NS_BINDING_ABORTED); + if (mWriteRequest) mWriteRequest->Cancel(NS_BINDING_ABORTED); + if (mReadRequest) mReadRequest->Cancel(NS_BINDING_ABORTED); return NS_OK; } @@ -181,11 +188,6 @@ 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; @@ -193,7 +195,7 @@ nsFtpControlConnection::Write(nsCString& command) if (NS_SUCCEEDED(rv) && len==cnt) { if (mSuspendedWrite) { mSuspendedWrite = PR_FALSE; - mCPipe->Resume(); + mWriteRequest->Resume(); } return NS_OK; } @@ -203,9 +205,9 @@ nsFtpControlConnection::Write(nsCString& command) } nsresult -nsFtpControlConnection::GetChannel(nsIChannel** controlChannel) +nsFtpControlConnection::GetTransport(nsITransport** controlTransport) { - NS_IF_ADDREF(*controlChannel = mCPipe); + NS_IF_ADDREF(*controlTransport = mCPipe); return NS_OK; } @@ -218,7 +220,7 @@ nsFtpControlConnection::SetStreamListener(nsIStreamListener *aListener) } NS_IMETHODIMP -nsFtpControlConnection::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) +nsFtpControlConnection::OnStartRequest(nsIRequest *request, nsISupports *aContext) { if (!mConnected) return NS_OK; @@ -235,11 +237,11 @@ nsFtpControlConnection::OnStartRequest(nsIChannel *aChannel, nsISupports *aConte if (!myListener) return NS_OK; - return myListener->OnStartRequest(aChannel, aContext); + return myListener->OnStartRequest(request, aContext); } NS_IMETHODIMP -nsFtpControlConnection::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsFtpControlConnection::OnStopRequest(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { @@ -258,12 +260,12 @@ nsFtpControlConnection::OnStopRequest(nsIChannel *aChannel, nsISupports *aContex if (!myListener) return NS_OK; - return myListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); + return myListener->OnStopRequest(request, aContext, aStatus, aStatusArg); } NS_IMETHODIMP -nsFtpControlConnection::OnDataAvailable(nsIChannel *aChannel, +nsFtpControlConnection::OnDataAvailable(nsIRequest *request, nsISupports *aContext, nsIInputStream *aInStream, PRUint32 aOffset, @@ -279,6 +281,6 @@ nsFtpControlConnection::OnDataAvailable(nsIChannel *aChannel, if (!myListener) return NS_OK; - return myListener->OnDataAvailable(aChannel, aContext, aInStream, + return myListener->OnDataAvailable(request, aContext, aInStream, aOffset, aCount); } diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.h b/mozilla/netwerk/protocol/ftp/src/nsFtpControlConnection.h index cf2c7bf7507..9ef86f458e9 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 "nsIChannel.h" +#include "nsITransport.h" #include "nsString.h" #include "nsIOutputStream.h" #include "nsAutoLock.h" @@ -39,15 +39,18 @@ public: NS_DECL_NSISTREAMLISTENER NS_DECL_NSISTREAMOBSERVER - nsFtpControlConnection(nsIChannel* socketTransport); + nsFtpControlConnection(nsITransport* socketTransport); virtual ~nsFtpControlConnection(); nsresult Connect(); nsresult Disconnect(); nsresult Write(nsCString& command); PRBool IsConnected() { return mConnected; } - - nsresult GetChannel(nsIChannel** controlChannel); + + void GetReadRequest(nsIRequest** request) { NS_ADDREF(*request=mReadRequest); } + void GetWriteRequest(nsIRequest** request) { NS_ADDREF(*request=mWriteRequest); } + + nsresult GetTransport(nsITransport** controlTransport); nsresult SetStreamListener(nsIStreamListener *aListener); PRUint32 mServerType; // what kind of server is it. @@ -59,10 +62,14 @@ public: private: PRLock* mLock; // protects mListener. - nsCOMPtr mCPipe; - nsCOMPtr mOutStream; + + nsCOMPtr mReadRequest; + nsCOMPtr mWriteRequest; + nsCOMPtr mCPipe; + nsCOMPtr mOutStream; nsCOMPtr mListener; - PRBool mConnected; + PRPackedBool mConnected; + PRPackedBool mWriteSuspened; }; diff --git a/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHTTPChannel.idl index 99cedbf944d..ce2ed64de97 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 OpenInputStream or not + * even queue for Open() or not */ - attribute boolean openInputStreamHasEventQueue; + attribute boolean openHasEventQueue; }; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index 62f55a09a87..b0736286413 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,20 +93,18 @@ 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), - mOpenInputStreamHasEventQueue (PR_TRUE) + mOpenHasEventQueue(PR_TRUE) { NS_INIT_REFCNT(); NS_NewISupportsArray(getter_AddRefs(mStreamAsFileObserverArray)); @@ -248,25 +246,25 @@ nsHTTPChannel::SetURI(nsIURI* o_URL) } NS_IMETHODIMP -nsHTTPChannel::GetOpenInputStreamHasEventQueue (PRBool * hasEventQueue) +nsHTTPChannel::GetOpenHasEventQueue (PRBool * hasEventQueue) { if (!hasEventQueue) return NS_ERROR_NULL_POINTER; - *hasEventQueue = mOpenInputStreamHasEventQueue; + *hasEventQueue = mOpenHasEventQueue; return NS_OK; } NS_IMETHODIMP -nsHTTPChannel::SetOpenInputStreamHasEventQueue (PRBool hasEventQueue) +nsHTTPChannel::SetOpenHasEventQueue (PRBool hasEventQueue) { - mOpenInputStreamHasEventQueue = hasEventQueue; + mOpenHasEventQueue = hasEventQueue; return NS_OK; } NS_IMETHODIMP -nsHTTPChannel::OpenInputStream(nsIInputStream **o_Stream) +nsHTTPChannel::Open(nsIInputStream **o_Stream) { nsresult rv; if (mConnected) return NS_ERROR_ALREADY_CONNECTED; @@ -280,34 +278,26 @@ nsHTTPChannel::OpenInputStream(nsIInputStream **o_Stream) if (NS_FAILED(rv)) return rv; - if (mOpenInputStreamHasEventQueue) - { - rv = AsyncRead (listener, nsnull); + if (mOpenHasEventQueue) { + rv = AsyncOpen(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::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("nsHTTPChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsHTTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *aContext) +nsHTTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) { nsresult rv = NS_OK; @@ -332,7 +322,7 @@ nsHTTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *aContext) mResponseContext = aContext; - Open(); + Begin(); // 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 @@ -340,37 +330,9 @@ nsHTTPChannel::AsyncRead(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) { @@ -480,89 +442,6 @@ 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) { @@ -615,25 +494,18 @@ nsHTTPChannel::SetNotificationCallbacks(nsIInterfaceRequestor* mCallbacks = aNotificationCallbacks; // Verify that the event sink is http - 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)); + if (mCallbacks) { + mRealEventSink = do_GetInterface(mCallbacks); + mRealPrompter = do_GetInterface(mCallbacks); + mRealProgressEventSink = do_GetInterface(mCallbacks); - rv = BuildNotificationProxies (); - + rv = BuildNotificationProxies(); } return rv; } nsresult -nsHTTPChannel::BuildNotificationProxies () +nsHTTPChannel::BuildNotificationProxies() { nsresult rv = NS_OK; @@ -644,11 +516,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; @@ -714,7 +586,7 @@ NS_IMETHODIMP nsHTTPChannel::GetResponseHeader(nsIAtom* i_Header, char* *o_Value) { if (!mConnected) - Open(); + Begin(); if (mResponse) return mResponse->GetHeader(i_Header, o_Value); else @@ -728,7 +600,7 @@ nsHTTPChannel::GetResponseHeaderEnumerator(nsISimpleEnumerator** aResult) nsresult rv; if (!mConnected) { - Open(); + Begin(); } if (mResponse) { @@ -745,7 +617,7 @@ nsHTTPChannel::SetResponseHeader(nsIAtom* i_Header, const char* i_HeaderValue) { nsresult rv = NS_OK; if (!mConnected) { - rv = Open(); + rv = Begin(); if (NS_FAILED(rv)) return rv; } @@ -767,7 +639,7 @@ NS_IMETHODIMP nsHTTPChannel::GetResponseStatus(PRUint32 *o_Status) { if (!mConnected) - Open(); + Begin(); if (mResponse) return mResponse->GetStatus(o_Status); return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ? @@ -777,7 +649,7 @@ NS_IMETHODIMP nsHTTPChannel::GetResponseString(char* *o_String) { if (!mConnected) - Open(); + Begin(); if (mResponse) return mResponse->GetStatusString(o_String); return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ? @@ -894,7 +766,7 @@ nsHTTPChannel::GetInterface(const nsIID &anIID, void **aResult ) // nsIProgressEventSink methods NS_IMETHODIMP -nsHTTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, +nsHTTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -905,7 +777,7 @@ nsHTTPChannel::OnStatus(nsIChannel *aChannel, nsISupports *aContext, } NS_IMETHODIMP -nsHTTPChannel::OnProgress(nsIChannel* aChannel, nsISupports* aContext, +nsHTTPChannel::OnProgress(nsIRequest *request, 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 @@ -925,7 +797,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, mBufferSegmentSize, mBufferMaxSize); + mRequest = new nsHTTPRequest(mURI, mHandler); if (!mRequest) { return NS_ERROR_OUT_OF_MEMORY; } @@ -1015,10 +887,10 @@ nsHTTPChannel::CheckCache() } // Hook up stream as listener - nsCOMPtr streamAsFile( do_QueryInterface( mCacheEntry ) ); - if ( streamAsFile ) + nsCOMPtr streamAsFile(do_QueryInterface(mCacheEntry)); + if (streamAsFile) { - nsCOMPtr< nsIStreamAsFileObserver> observer; + nsCOMPtr observer; PRUint32 count = 0; mStreamAsFileObserverArray->Count( & count ); for ( PRUint32 i=0; i< count; i++ ) @@ -1026,7 +898,6 @@ nsHTTPChannel::CheckCache() mStreamAsFileObserverArray->GetElementAt( i, getter_AddRefs( observer ) ); streamAsFile->AddObserver( observer ); } - } // Be pessimistic: Assume cache entry has no useful data @@ -1078,7 +949,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; @@ -1234,14 +1105,14 @@ nsHTTPChannel::ReadFromCache() #endif /* PR_LOGGING */ // Create a cache transport to read the cached response... - rv = mCacheEntry->NewChannel(mLoadGroup, getter_AddRefs(mCacheTransport)); + rv = mCacheEntry->NewChannel(mLoadGroup, getter_AddRefs(mCacheChannel)); if (NS_FAILED(rv)) return rv; // // Propagate the load attributes of this channel into the cache channel. // This will ensure that notifications are suppressed if necessary. // - rv = mCacheTransport->SetLoadAttributes(mLoadAttributes); + rv = mCacheChannel->SetLoadAttributes(mLoadAttributes); if (NS_FAILED(rv)) return rv; // Fake it so that HTTP headers come from cached versions @@ -1262,7 +1133,7 @@ nsHTTPChannel::ReadFromCache() FinishedResponseHeaders(); // Pump the cache data downstream - rv = mCacheTransport->AsyncRead(listener, mResponseContext); + rv = mCacheChannel->AsyncOpen(listener, mResponseContext); NS_RELEASE(listener); if (NS_FAILED(rv)) { ResponseCompleted(nsnull, rv, nsnull); @@ -1456,7 +1327,7 @@ nsHTTPChannel::CacheReceivedResponse(nsIStreamListener *aListener, } nsresult -nsHTTPChannel::Open(PRBool bIgnoreCache) +nsHTTPChannel::Begin(PRBool bIgnoreCache) { if (mConnected || (mState > HS_WAITING_FOR_OPEN)) return NS_ERROR_ALREADY_CONNECTED; @@ -1468,7 +1339,7 @@ nsHTTPChannel::Open(PRBool bIgnoreCache) // If this is the first time, then add the channel to its load group if (mState == HS_IDLE) { if (mLoadGroup) - mLoadGroup->AddChannel(this, nsnull); + mLoadGroup->AddRequest(this, nsnull); // See if there's a cache entry for the given URL if (!bIgnoreCache) @@ -1689,8 +1560,10 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, rv = serv->NewURI(aNewLocation, mURI, getter_AddRefs(newURI)); if (NS_FAILED(rv)) return rv; -#if 0 + // removing redirect.xul for loop. bugs 44153, 56523, 58658 +// XXX This is broken +#if 0 nsXPIDLCString spec1; nsXPIDLCString spec2; @@ -1725,7 +1598,6 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, nsXPIDLCString baseref; nsCOMPtr baseurl; - baseurl = do_QueryInterface(mURI, &rv); if (NS_SUCCEEDED(rv)) { @@ -1767,18 +1639,18 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, loadFlags |= nsIChannel::LOAD_REPLACE; rv = NS_OpenURI(getter_AddRefs(channel), newURI, serv, mLoadGroup, - mCallbacks, loadFlags, - mBufferSegmentSize, mBufferMaxSize); + mCallbacks, loadFlags); if (NS_FAILED(rv)) return rv; rv = channel->SetOriginalURI(mOriginalURI); if (NS_FAILED(rv)) return rv; if (mLoadGroup) { - nsCOMPtr tempChannel; - rv = mLoadGroup->GetDefaultLoadChannel(getter_AddRefs(tempChannel)); + nsCOMPtr tempRequest; + rv = mLoadGroup->GetDefaultLoadRequest(getter_AddRefs(tempRequest)); if (NS_SUCCEEDED(rv)) { + nsCOMPtr tempChannel = do_QueryInterface(tempRequest); if (tempChannel == this) { - mLoadGroup->SetDefaultLoadChannel(channel); + mLoadGroup->SetDefaultLoadRequest(channel); } } } @@ -1806,9 +1678,9 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, { // Start the redirect... nsIStreamListener *sl = mResponseDataListener; - nsHTTPFinalListener *fl = NS_STATIC_CAST (nsHTTPFinalListener*, sl); - rv = channel->AsyncRead(fl -> GetListener (), mResponseContext); - fl -> Shutdown (); + nsHTTPFinalListener *fl = NS_STATIC_CAST(nsHTTPFinalListener*, sl); + rv = channel->AsyncOpen(fl->GetListener(), mResponseContext); + fl->Shutdown(); } else rv = NS_ERROR_FAILURE; @@ -1827,9 +1699,7 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation, // mResponseDataListener = 0; - *aResult = channel; - NS_ADDREF(*aResult); - + NS_ADDREF(*aResult = channel); return rv; } @@ -1871,7 +1741,7 @@ nsresult nsHTTPChannel::ResponseCompleted(nsIStreamListener *aListener, // Release the cache transport. This would free the entry's channelCount enabling changes // to the cacheEntry - mCacheTransport = nsnull; + mCacheChannel = nsnull; if (mCacheEntry) { @@ -1949,7 +1819,7 @@ nsresult nsHTTPChannel::ResponseCompleted(nsIStreamListener *aListener, // if (mLoadGroup) - mLoadGroup->RemoveChannel(this, nsnull, aStatus, aStatusArg); + mLoadGroup->RemoveRequest(this, nsnull, aStatus, aStatusArg); // Null out pointers that are no longer needed... @@ -2278,8 +2148,7 @@ 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, mBufferSegmentSize, mBufferMaxSize); + mURI, serv, mLoadGroup, mCallbacks, mLoadAttributes); if (NS_FAILED(rv)) return rv; rv = channel->SetOriginalURI(mOriginalURI); if (NS_FAILED(rv)) return rv; @@ -2306,7 +2175,8 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth) // Fire the new request... nsIStreamListener *sl = mResponseDataListener; nsHTTPFinalListener *fl = NS_STATIC_CAST (nsHTTPFinalListener*, sl); - rv = channel->AsyncRead(fl -> GetListener (), mResponseContext); + nsCOMPtr request; + rv = channel->AsyncOpen(fl->GetListener (), mResponseContext); } else rv = NS_ERROR_FAILURE; @@ -2589,24 +2459,23 @@ nsHTTPChannel::ProcessNotModifiedResponse(nsIStreamListener *aListener) SetResponse(mCachedResponse); // Create a cache transport to read the cached response... - rv = mCacheEntry->NewChannel(mLoadGroup, getter_AddRefs(mCacheTransport)); + rv = mCacheEntry->NewChannel(mLoadGroup, getter_AddRefs(mCacheChannel)); 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(mCacheChannel); + 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; @@ -2619,7 +2488,7 @@ nsHTTPChannel::ProcessNotModifiedResponse(nsIStreamListener *aListener) cacheListener->SetListener(aListener); mResponseDataListener = 0/* aListener */; - rv = mCacheTransport->AsyncRead(cacheListener, mResponseContext); + rv = mCacheChannel->AsyncOpen(cacheListener, mResponseContext); if (NS_FAILED(rv)) { ResponseCompleted(cacheListener, rv, nsnull); } @@ -2844,7 +2713,7 @@ nsHTTPChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) if (mRequest) { - nsCOMPtr trans; + nsCOMPtr trans; mRequest->GetTransport(getter_AddRefs(trans)); if (trans) @@ -2961,7 +2830,8 @@ nsSyncHelper::Run() // initiate the AsyncRead from this thread so events are // sent here for processing. - rv = mChannel->AsyncRead(this, nsnull); + + rv = mChannel->AsyncOpen(this, nsnull); if (NS_FAILED(rv)) return rv; // process events until we're finished. @@ -2983,29 +2853,29 @@ nsSyncHelper::Run() // nsIStreamListener implementation NS_IMETHODIMP -nsSyncHelper::OnDataAvailable(nsIChannel *aChannel, +nsSyncHelper::OnDataAvailable(nsIRequest *request, nsISupports *aContext, nsIInputStream *aInStream, PRUint32 aOffset, PRUint32 aCount) { - return mListener->OnDataAvailable(aChannel, aContext, aInStream, + return mListener->OnDataAvailable(request, aContext, aInStream, aOffset, aCount); } // nsIStreamObserver implementation NS_IMETHODIMP -nsSyncHelper::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) +nsSyncHelper::OnStartRequest(nsIRequest *request, nsISupports *aContext) { - return mListener->OnStartRequest(aChannel, aContext); + return mListener->OnStartRequest(request, aContext); } NS_IMETHODIMP -nsSyncHelper::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsSyncHelper::OnStopRequest(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { mProcessing = PR_FALSE; - return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); } @@ -3017,7 +2887,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 f68b7c5ccec..a5f0428744b 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.h @@ -27,6 +27,7 @@ #include "nsIHTTPChannel.h" #include "nsIChannel.h" +#include "nsITransport.h" #include "nsHTTPEnums.h" #include "nsIURI.h" #include "nsHTTPHandler.h" @@ -45,6 +46,7 @@ #include "nsIPrompt.h" #include "nsIHTTPEventSink.h" #include "nsIStreamAsFile.h" + class nsIFile; class nsHTTPRequest; @@ -88,13 +90,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 Open(PRBool bIgnoreCache=PR_FALSE); + nsresult Begin(PRBool bIgnoreCache=PR_FALSE); nsresult Redirect(const char *aURL, nsIChannel **aResult, PRInt32 aStatusCode); @@ -192,11 +194,9 @@ protected: // (such as socks) we want to reverse conditional proxy behavior PRBool mProxyTransparent; - PRUint32 mBufferSegmentSize; - PRUint32 mBufferMaxSize; nsresult mStatus; - nsCOMPtr mCacheTransport; + nsCOMPtr mCacheChannel; PRBool mPipeliningAllowed; nsHTTPPipelinedRequest* mPipelinedRequest; @@ -204,7 +204,7 @@ protected: // Stream as file nsCOMPtr mStreamAsFileObserverArray; PRBool mApplyConversion; - PRBool mOpenInputStreamHasEventQueue; + PRBool mOpenHasEventQueue; }; #include "nsIRunnable.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp index 84f3c5bfad0..3d4c0a4e3b8 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp @@ -865,9 +865,7 @@ nsHTTPHandler::~nsHTTPHandler() nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, nsHTTPChannel* i_Channel, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans, + nsITransport** o_pTrans, PRUint32 flags) { nsresult rv; @@ -914,7 +912,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; @@ -929,8 +927,8 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, { for (index = count - 1; index >= 0; --index) { - nsCOMPtr cTrans = - dont_AddRef ((nsIChannel*) mIdleTransports->ElementAt(index)); + nsCOMPtr cTrans = + dont_AddRef ((nsITransport*) mIdleTransports->ElementAt(index)); if (cTrans) { @@ -951,18 +949,20 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, for (index = count - 1; index >= 0; --index) { nsCOMPtr uri; - nsCOMPtr cTrans = dont_AddRef ((nsIChannel*) mIdleTransports->ElementAt(index) ); + nsCOMPtr cTrans = + dont_AddRef ((nsITransport*) mIdleTransports->ElementAt(index) ); + + nsCOMPtr socketTrans = do_QueryInterface(cTrans); - if (cTrans && - (NS_SUCCEEDED (cTrans->GetURI(getter_AddRefs(uri))))) + if (socketTrans) { nsXPIDLCString idlehost; - if (NS_SUCCEEDED (uri->GetHost(getter_Copies(idlehost)))) + if (NS_SUCCEEDED (socketTrans->GetHost(getter_Copies(idlehost)))) { if (!PL_strcasecmp (usingProxy ? proxy : host, idlehost)) { PRInt32 idleport; - if (NS_SUCCEEDED (uri->GetPort(&idleport))) + if (NS_SUCCEEDED (socketTrans->GetPort(&idleport))) { if (idleport == -1) GetDefaultPort (&idleport); @@ -1011,16 +1011,12 @@ 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) ); } @@ -1054,12 +1050,9 @@ nsresult nsHTTPHandler::CreateTransport(const char* host, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans) + nsITransport** o_pTrans) { - return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, - bufferSegmentSize, bufferMaxSize, o_pTrans); + return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, o_pTrans); } nsresult nsHTTPHandler::CreateTransportOfType(const char* type, @@ -1067,9 +1060,7 @@ nsresult nsHTTPHandler::CreateTransportOfType(const char* type, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans) + nsITransport** o_pTrans) { nsresult rv; @@ -1082,8 +1073,8 @@ nsresult nsHTTPHandler::CreateTransportOfType(const char* type, port, proxyHost, proxyPort, - bufferSegmentSize, - bufferMaxSize, + HTTP_DEFAULT_SEGMENT_SIZE, + HTTP_DEFAULT_BUFFER_SIZE, o_pTrans); return rv; @@ -1092,7 +1083,7 @@ nsresult nsHTTPHandler::CreateTransportOfType(const char* type, static PRUint32 sMaxKeepAlives = 0; nsresult -nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , +nsHTTPHandler::ReleaseTransport (nsITransport* i_pTrans , PRUint32 aCapabilities, PRBool aDontRestartChannels, PRUint32 aKeepAliveTimeout, @@ -1128,12 +1119,11 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , PRInt32 port = -1; nsXPIDLCString host; - i_pTrans->GetURI (getter_AddRefs (uri)); - - if (uri) + // Get the address of the socket transport { - uri->GetHost (getter_Copies (host)); - uri->GetPort (&port); + nsCOMPtr socketTrans = do_QueryInterface(i_pTrans); + socketTrans->GetHost(getter_Copies(host)); + socketTrans->GetPort(&port); } if (port == -1) GetDefaultPort (&port); @@ -1153,7 +1143,7 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , for (index = count - 1; index >= 0; --index) { - nsCOMPtr cTrans = dont_AddRef ((nsIChannel*) mIdleTransports->ElementAt (index) ); + nsCOMPtr cTrans = dont_AddRef ((nsITransport*) mIdleTransports->ElementAt (index) ); if (cTrans) { @@ -1166,23 +1156,19 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , else if (capabilities & (ALLOW_KEEPALIVE|ALLOW_PROXY_KEEPALIVE)) { - cTrans->GetURI (getter_AddRefs (uri)); - if (uri) - { - PRInt32 lPort = -1; - nsXPIDLCString lHost; + PRInt32 lPort = -1; + nsXPIDLCString lHost; - uri->GetHost (getter_Copies (lHost)); - uri->GetPort (&lPort); - if (lPort == -1) - GetDefaultPort (&lPort); + sTrans->GetHost (getter_Copies (lHost)); + sTrans->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 */ @@ -1190,12 +1176,12 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , if (capabilities & (ALLOW_KEEPALIVE|ALLOW_PROXY_KEEPALIVE)) { - nsCOMPtr trans = do_QueryInterface (i_pTrans, &rv); + nsCOMPtr sTrans = do_QueryInterface (i_pTrans, &rv); if (NS_SUCCEEDED (rv)) { PRBool alive = PR_FALSE; - rv = trans->IsAlive(0, &alive); + rv = sTrans->IsAlive(0, &alive); if (NS_SUCCEEDED (rv) && alive) { @@ -1209,8 +1195,8 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , NS_ASSERTION(added, "Failed to add a socket to idle transports list!"); - trans->SetReuseConnection(PR_TRUE); - trans->SetIdleTimeout(aKeepAliveTimeout); + sTrans->SetReuseConnection(PR_TRUE); + sTrans->SetIdleTimeout(aKeepAliveTimeout); mIdleTransports->Count(&count); if (count > sMaxKeepAlives) @@ -1225,7 +1211,7 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , // to the transport and the transport which references the HTTPChannel // through the event sink... // - rv = i_pTrans->SetNotificationCallbacks(nsnull); + rv = i_pTrans->SetProgressEventSink(nsnull); rv = mTransportList->RemoveElement(i_pTrans); NS_ASSERTION(NS_SUCCEEDED(rv), "Transport not in table..."); @@ -1260,7 +1246,7 @@ nsHTTPHandler::ReleaseTransport (nsIChannel* i_pTrans , PR_LOG (gHTTPLog, PR_LOG_ALWAYS, ("nsHTTPHandler::ReleaseTransport." "\tRestarting nsHTTPChannel [%x]\n", channel)); - channel->Open(); + channel->Begin(); } return rv; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h index 4b95b2f67de..f00264ca54b 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h @@ -52,6 +52,7 @@ //Forward decl. class nsHashtable; class nsHTTPChannel; +class nsITransport; #define TRANSPORT_REUSE_ALIVE 1 #define TRANSPORT_OPEN_ALWAYS 2 @@ -70,6 +71,10 @@ class nsHTTPChannel; #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; @@ -97,9 +102,7 @@ public: */ virtual nsresult RequestTransport(nsIURI *i_Uri, nsHTTPChannel* i_Channel, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans, PRUint32 flags = TRANSPORT_REUSE_ALIVE); + nsITransport** o_pTrans, PRUint32 flags = TRANSPORT_REUSE_ALIVE); /** * Called to create a transport from RequestTransport to accually @@ -109,20 +112,16 @@ public: virtual nsresult CreateTransport(const char* host, PRInt32 port, const char* aPrintHost, PRBool usingProxy, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans); + nsITransport** o_pTrans); virtual nsresult CreateTransportOfType(const char* socketType, const char* host, PRInt32 port, const char* aPrintHost, PRBool usingProxy, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans); + nsITransport** o_pTrans); /* Remove this transport from the list. */ - virtual nsresult ReleaseTransport(nsIChannel* i_pTrans, PRUint32 capabilies = 0, PRBool aDontRestartChannels = PR_FALSE, PRUint32 aKeepAliveTimeout = 0, PRInt32 aKeepAliveMaxCon = -1); + virtual nsresult ReleaseTransport(nsITransport* 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 fd2ee5015a7..aa6fdb645d4 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.cpp @@ -57,12 +57,8 @@ 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, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize) + nsHTTPHandler* i_Handler) : - mBufferSegmentSize(bufferSegmentSize), - mBufferMaxSize(bufferMaxSize), mPipelinedRequest(nsnull), mDoingProxySSLConnect(PR_FALSE), mSSLConnected(PR_FALSE), @@ -186,10 +182,12 @@ nsHTTPRequest::Resume() return rv; } + nsresult nsHTTPRequest::Clone(const nsHTTPRequest* *o_Request) const { return NS_ERROR_FAILURE; } + nsresult nsHTTPRequest::SetMethod(nsIAtom * i_Method) { @@ -204,6 +202,7 @@ nsIAtom * nsHTTPRequest::GetMethod(void) const return mMethod; } + nsresult nsHTTPRequest::SetPriority() { @@ -258,12 +257,13 @@ nsresult nsHTTPRequest::GetConnection(nsHTTPChannel** o_Connection) return rv; } -nsresult nsHTTPRequest::SetTransport(nsIChannel * aTransport) + +nsresult nsHTTPRequest::SetTransport(nsITransport * aTransport) { return NS_OK; } -nsresult nsHTTPRequest::GetTransport(nsIChannel **aTransport) +nsresult nsHTTPRequest::GetTransport(nsITransport **aTransport) { if (mPipelinedRequest) return mPipelinedRequest->GetTransport(aTransport); @@ -273,6 +273,7 @@ nsresult nsHTTPRequest::GetTransport(nsIChannel **aTransport) return NS_OK; } + nsresult nsHTTPRequest::GetHeaderEnumerator(nsISimpleEnumerator** aResult) { return mHeaders.GetEnumerator(aResult); @@ -418,7 +419,7 @@ nsHTTPRequest::formBuffer(nsCString * requestBuffer, PRUint32 capabilities) if (mDoingProxySSLConnect) { - nsCOMPtr trans; + nsCOMPtr trans; PRUint32 reuse = 0; GetTransport(getter_AddRefs(trans)); nsCOMPtr sockTrans = @@ -554,8 +555,6 @@ 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), @@ -604,21 +603,17 @@ nsHTTPPipelinedRequest::~nsHTTPPipelinedRequest() } nsresult -nsHTTPPipelinedRequest::SetTransport(nsIChannel * aTransport) +nsHTTPPipelinedRequest::SetTransport(nsITransport * aTransport) { mTransport = aTransport; return NS_OK; } nsresult -nsHTTPPipelinedRequest::GetTransport(nsIChannel **aTransport) +nsHTTPPipelinedRequest::GetTransport(nsITransport **aTransport) { - if (aTransport == NULL) - return NS_ERROR_NULL_POINTER; - - *aTransport = mTransport; - NS_IF_ADDREF(*aTransport); - + NS_ENSURE_ARG_POINTER(aTransport); + NS_IF_ADDREF(*aTransport = mTransport); return NS_OK; } @@ -661,7 +656,7 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) if (mInputStream) tMode &= ~(TRANSPORT_REUSE_ALIVE); - rv = mHandler->RequestTransport(req->mURI, req->mConnection, mBufferSegmentSize, mBufferMaxSize, + rv = mHandler->RequestTransport(req->mURI, req->mConnection, getter_AddRefs(mTransport), tMode); if (NS_FAILED(rv)) @@ -686,9 +681,6 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) { req =(nsHTTPRequest *) mRequests->ElementAt(index); req->formBuffer(&mRequestBuffer, mCapabilities); - if (index == 0) - mTransport->SetNotificationCallbacks(req->mConnection); - NS_RELEASE(req); mTotalWritten++; } @@ -715,13 +707,9 @@ 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 @@ -731,11 +719,26 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL; req->mConnection->GetLoadAttributes(&loadAttributes); - mTransport->SetLoadAttributes(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); + } } mOnStopDone = PR_FALSE; - rv = NS_AsyncWriteFromStream(mTransport, stream, this, (nsISupports*)(nsIRequest*)req->mConnection); + + rv = NS_AsyncWriteFromStream( + getter_AddRefs(mCurrentWriteRequest), + mTransport, stream, 0, mRequestBuffer.Length(), 0, + this, NS_STATIC_CAST(nsIRequest*, req->mConnection)); + NS_RELEASE(req); return rv; @@ -745,7 +748,7 @@ nsHTTPPipelinedRequest::WriteRequest(nsIInputStream* iRequestStream) // nsIStreamObserver methods: NS_IMETHODIMP -nsHTTPPipelinedRequest::OnStartRequest(nsIChannel* channel, nsISupports* i_Context) +nsHTTPPipelinedRequest::OnStartRequest(nsIRequest *request, nsISupports* i_Context) { PR_LOG(gHTTPLog, PR_LOG_ALWAYS, ("nsHTTPRequest [this=%x]. Starting to write data to the server.\n", @@ -755,7 +758,7 @@ nsHTTPPipelinedRequest::OnStartRequest(nsIChannel* channel, nsISupports* i_Conte } NS_IMETHODIMP -nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Context, +nsHTTPPipelinedRequest::OnStopRequest(nsIRequest *request, nsISupports* i_Context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -785,8 +788,10 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex ("nsHTTPRequest [this=%x]. " "Writing PUT/POST data to the server.\n", this)); - rv = NS_AsyncWriteFromStream(mTransport, mInputStream, this, - (nsISupports*)(nsIRequest*)req->mConnection); + rv = NS_AsyncWriteFromStream( + getter_AddRefs(mCurrentWriteRequest), + mTransport, mInputStream, 0, 0, 0, + this, NS_STATIC_CAST(nsIRequest*, req->mConnection)); /* the mInputStream is released below... */ } @@ -810,7 +815,8 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex if (pListener) { NS_ADDREF(pListener); - rv = mTransport->AsyncRead(pListener, i_Context); + rv = mTransport->AsyncRead(pListener, i_Context, 0, -1, 0, + getter_AddRefs(mCurrentReadRequest)); mListener = pListener; NS_RELEASE(pListener); } @@ -868,6 +874,9 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex mHandler->ReleaseTransport(mTransport, nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES, PR_TRUE); mTransport = null_nsCOMPtr(); + mCurrentWriteRequest = 0; + mCurrentReadRequest = 0; + mOnStopDone = PR_TRUE; rv = WriteRequest(mInputStream); @@ -890,8 +899,10 @@ nsHTTPPipelinedRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_Contex if (mTransport) { - nsIChannel *p = mTransport; - mTransport = null_nsCOMPtr(); + nsITransport *p = mTransport; + mTransport = 0; + mCurrentWriteRequest = 0; + mCurrentReadRequest = 0; mHandler->ReleaseTransport(p, nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES); } @@ -994,6 +1005,8 @@ nsHTTPPipelinedRequest::RestartRequest(PRUint32 aType) mHandler->ReleaseTransport(mTransport, nsIHTTPProtocolHandler::DONTRECORD_CAPABILITIES, PR_TRUE); mTransport = null_nsCOMPtr(); + mCurrentWriteRequest = 0; + mCurrentReadRequest = 0; rval = WriteRequest(mInputStream); } @@ -1005,10 +1018,9 @@ nsHTTPPipelinedRequest::RestartRequest(PRUint32 aType) nsresult nsHTTPPipelinedRequest::GetName(PRUnichar* *result) { - if (mTransport) - return mTransport->GetName(result); + if (mCurrentReadRequest) + return mCurrentReadRequest->GetName(result); - NS_NOTREACHED("nsHTTPPipelinedRequest::GetName"); return NS_ERROR_NOT_IMPLEMENTED; } @@ -1017,8 +1029,8 @@ nsHTTPPipelinedRequest::IsPending(PRBool *result) { nsresult rv = NS_OK; - if (mTransport) - rv = mTransport->IsPending(result); + if (mCurrentReadRequest) + rv = mCurrentReadRequest->IsPending(result); else *result = PR_FALSE; @@ -1030,8 +1042,11 @@ nsHTTPPipelinedRequest::Cancel(nsresult status) { nsresult rv = NS_OK; - if (mTransport) - rv = mTransport->Cancel(status); + if (mCurrentReadRequest) + rv = mCurrentReadRequest->Cancel(status); + + if (mCurrentWriteRequest) + (void) mCurrentWriteRequest->Cancel(status); return rv; } @@ -1041,8 +1056,12 @@ nsHTTPPipelinedRequest::Suspend(void) { nsresult rv = NS_ERROR_FAILURE; - if (mTransport) - rv = mTransport->Suspend(); + if (mCurrentReadRequest) + rv = mCurrentReadRequest->Suspend(); + + if (mCurrentWriteRequest) + (void) mCurrentWriteRequest->Suspend(); + return rv; } @@ -1051,8 +1070,12 @@ nsHTTPPipelinedRequest::Resume() { nsresult rv = NS_ERROR_FAILURE; - if (mTransport) - rv = mTransport->Resume(); + if (mCurrentReadRequest) + rv = mCurrentReadRequest->Resume(); + + if (mCurrentWriteRequest) + (void) mCurrentWriteRequest->Resume(); + return rv; } @@ -1097,12 +1120,6 @@ 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; @@ -1197,8 +1214,12 @@ 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) - mTransport->SetNotificationCallbacks(req->mConnection); + if (mTransport) { + nsCOMPtr sink = + do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor*, req->mConnection)); + if (sink) + mTransport->SetProgressEventSink(sink); + } NS_RELEASE(req); } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h index 9540e0c295f..527c3e66cbe 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPRequest.h @@ -37,6 +37,7 @@ #include "nsHTTPHandler.h" #include "nsISupportsArray.h" #include "nsXPIDLString.h" +#include "nsITransport.h" class nsIInputStream; class nsHTTPChannel; @@ -68,11 +69,10 @@ class nsHTTPPipelinedRequest; class nsHTTPRequest : public nsIRequest { - public: // Constructor - nsHTTPRequest(nsIURI* i_URL, nsHTTPHandler* i_Handler, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize); + nsHTTPRequest(nsIURI* i_URL, nsHTTPHandler* i_Handler); NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -112,8 +112,8 @@ public: nsresult GetConnection(nsHTTPChannel** o_Connection); nsresult SetConnection(nsHTTPChannel* i_Connection); - nsresult SetTransport (nsIChannel * aTransport); - nsresult GetTransport (nsIChannel **aTransport); + nsresult SetTransport (nsITransport * aTransport); + nsresult GetTransport (nsITransport **aTransport); nsresult GetUploadStream(nsIInputStream** o_UploadStream); nsresult SetUploadStream(nsIInputStream* i_UploadStream); @@ -121,9 +121,6 @@ public: nsresult SetOverrideRequestSpec(const char* i_Spec); nsresult GetOverrideRequestSpec(char** o_Spec); - PRUint32 mBufferSegmentSize; - PRUint32 mBufferMaxSize; - // for POST or PUT data... nsCOMPtr mInputStream; @@ -192,8 +189,8 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSISTREAMOBSERVER - nsresult SetTransport (nsIChannel * aTransport); - nsresult GetTransport (nsIChannel **aTransport); + nsresult SetTransport (nsITransport * aTransport); + nsresult GetTransport (nsITransport **aTransport); // Build the actual request string based on the settings. nsresult WriteRequest(nsIInputStream* iRequestStream); @@ -220,7 +217,9 @@ protected: PRUint32 mCapabilities; PRUint32 mAttempts; - nsCOMPtr mTransport; + nsCOMPtr mTransport; + nsCOMPtr mCurrentWriteRequest; + nsCOMPtr mCurrentReadRequest; PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index 0a478c2af4d..b350466d5ad 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -138,21 +138,27 @@ nsHTTPCacheListener::~nsHTTPCacheListener() // nsIStreamObserver methods: NS_IMETHODIMP -nsHTTPCacheListener::OnStartRequest(nsIChannel *aChannel, +nsHTTPCacheListener::OnStartRequest(nsIRequest *aRequest, 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. - aChannel->GetContentLength(&mContentLength) ; + nsCOMPtr cr = do_QueryInterface(aRequest); + if (!cr) return NS_ERROR_FAILURE; + + cr->GetContentLength(&mContentLength) ; +#endif return mResponseDataListener->OnStartRequest(mChannel, aContext) ; } NS_IMETHODIMP -nsHTTPCacheListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsHTTPCacheListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, @@ -172,7 +178,7 @@ nsHTTPCacheListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, // nsIStreamListener methods: NS_IMETHODIMP -nsHTTPCacheListener::OnDataAvailable(nsIChannel *aChannel, +nsHTTPCacheListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aStream, PRUint32 aSourceOffset, @@ -276,7 +282,7 @@ nsHTTPServerListener::~nsHTTPServerListener() // nsIStreamListener methods: NS_IMETHODIMP -nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, +nsHTTPServerListener::OnDataAvailable(nsIRequest* request, nsISupports* context, nsIInputStream *i_pStream, PRUint32 i_SourceOffset, @@ -361,29 +367,35 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, 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 = do_QueryInterface(channel, &rv) ; + nsCOMPtr trans; + rv = req->GetTransport(getter_AddRefs(trans)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr sTrans = do_QueryInterface(trans, &rv); // XXX/ruslan: will be replaced with the new Cancel(code) if (NS_SUCCEEDED(rv)) - trans->SetBytesExpected(0) ; + sTrans->SetBytesExpected(0); } else { - OnStartRequest(nsnull, nsnull) ; + OnStartRequest(nsnull, nsnull); } } else @@ -393,7 +405,7 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, mFirstLineParsed = PR_FALSE; mHeaderBuffer.Truncate() ; - mChannel->SetResponse(nsnull) ; + mChannel->SetResponse(nsnull); NS_RELEASE(mResponse) ; mResponse = nsnull; @@ -411,22 +423,22 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, 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; } @@ -491,7 +503,7 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, fromStr.GetUnicode() , toStr.GetUnicode() , mResponseDataListener, - channel, + request, getter_AddRefs(converterListener)) ; if (NS_FAILED(rv)) return rv; mResponseDataListener = converterListener; @@ -593,11 +605,18 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, mHandler->ReleasePipelinedRequest(mPipelinedRequest) ; mPipelinedRequest = nsnull; - nsCOMPtr trans = do_QueryInterface(channel, &rv1) ; + 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) ; // XXX/ruslan: will be replaced with the new Cancel(code) if (NS_SUCCEEDED(rv1)) - trans->SetBytesExpected(0) ; + sTrans->SetBytesExpected(0); } else @@ -618,7 +637,7 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, i_pStream->Available(&streamLen) ; if (streamLen > 0) - OnDataAvailable(channel, context, i_pStream, 0, streamLen) ; + OnDataAvailable(request, context, i_pStream, 0, streamLen) ; } } } @@ -627,7 +646,7 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel, NS_IMETHODIMP -nsHTTPServerListener::OnStartRequest(nsIChannel* channel, nsISupports* i_pContext) +nsHTTPServerListener::OnStartRequest(nsIRequest* request, nsISupports* i_pContext) { PR_LOG(gHTTPLog, PR_LOG_ALWAYS, ("nsHTTPServerListener::OnStartRequest [this=%x].\n", this)) ; @@ -670,7 +689,7 @@ nsHTTPServerListener::OnStartRequest(nsIChannel* channel, nsISupports* i_pContex } NS_IMETHODIMP -nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext, +nsHTTPServerListener::OnStopRequest(nsIRequest* request, nsISupports* i_pContext, nsresult i_Status, const PRUnichar* aStatusArg) { nsresult rv = i_Status, channelStatus = NS_OK; @@ -740,7 +759,7 @@ nsHTTPServerListener::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext PRUint32 keepAliveTimeout = 0; PRInt32 keepAliveMaxCon = -1; - if (mResponse && channel) // this is the actual response from the transport + if (mResponse && request) // this is the actual response from the transport { HTTPVersion ver; rv = mResponse->GetServerVersion(&ver) ; @@ -787,33 +806,40 @@ nsHTTPServerListener::OnStopRequest(nsIChannel* channel, 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; } - if (channel) - mHandler->ReleaseTransport(channel, capabilities, PR_FALSE, keepAliveTimeout, keepAliveMaxCon) ; + nsCOMPtr req = do_QueryInterface(request); + if (req) { + nsCOMPtr transport; + req->GetTransport(getter_AddRefs(transport)); + + if (transport) + mHandler->ReleaseTransport(transport, capabilities, PR_FALSE, + keepAliveTimeout, keepAliveMaxCon); + } } - NS_IF_RELEASE(mChannel) ; - NS_IF_RELEASE(mResponse) ; + NS_IF_RELEASE(mChannel); + NS_IF_RELEASE(mResponse); return NS_OK; } @@ -1131,7 +1157,7 @@ nsHTTPFinalListener::~nsHTTPFinalListener() // nsIStreamObserver methods: NS_IMETHODIMP -nsHTTPFinalListener::OnStartRequest(nsIChannel *aChannel, +nsHTTPFinalListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, @@ -1142,11 +1168,11 @@ nsHTTPFinalListener::OnStartRequest(nsIChannel *aChannel, return NS_OK; mOnStartFired = PR_TRUE; - return mListener->OnStartRequest(aChannel, aContext) ; + return mListener->OnStartRequest(aRequest, aContext) ; } NS_IMETHODIMP -nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsHTTPFinalListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { PR_LOG(gHTTPLog, PR_LOG_DEBUG, @@ -1179,7 +1205,7 @@ nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, } mOnStopFired = PR_TRUE; - nsresult rv = mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg) ; + nsresult rv = mListener->OnStopRequest(aRequest, aContext, aStatus, aStatusArg) ; return rv; } @@ -1188,7 +1214,7 @@ nsHTTPFinalListener::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, // nsIStreamListener methods: NS_IMETHODIMP -nsHTTPFinalListener::OnDataAvailable(nsIChannel *aChannel, +nsHTTPFinalListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aStream, PRUint32 aSourceOffset, @@ -1211,7 +1237,7 @@ nsHTTPFinalListener::OnDataAvailable(nsIChannel *aChannel, return NS_OK; mBusy = PR_TRUE; - nsresult rv = mListener->OnDataAvailable(aChannel, aContext, + nsresult rv = mListener->OnDataAvailable(aRequest, 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 7d769398501..02a891bc25e 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp @@ -73,12 +73,9 @@ nsresult nsHTTPSHandler::CreateTransport(const char* host, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans) + nsITransport** o_pTrans) { - return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, - bufferSegmentSize, bufferMaxSize, o_pTrans); + return CreateTransportOfType(nsnull, host, port, proxyHost, proxyPort, o_pTrans); } nsresult nsHTTPSHandler::CreateTransportOfType(const char * type, @@ -86,9 +83,7 @@ nsresult nsHTTPSHandler::CreateTransportOfType(const char * type, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans) + nsITransport** o_pTrans) { nsresult rv; @@ -103,7 +98,7 @@ nsresult nsHTTPSHandler::CreateTransportOfType(const char * type, port, proxyHost, proxyPort, - bufferSegmentSize, - bufferMaxSize, + 0, + 0, o_pTrans); } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h index 9b4ec14c3d3..925ae459827 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h @@ -74,18 +74,14 @@ public: PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans); + nsITransport** o_pTrans); virtual nsresult CreateTransportOfType(const char* socketType, const char* host, PRInt32 port, const char* proxyHost, PRInt32 proxyPort, - PRUint32 bufferSegmentSize, - PRUint32 bufferMaxSize, - nsIChannel** o_pTrans); + nsITransport** o_pTrans); }; #endif /* _nsHTTPSHandler_h_ */ diff --git a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp index 5ef89b162d8..9ae0ba2b1e1 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp @@ -31,6 +31,7 @@ #include "nsMimeTypes.h" #include "nsScriptSecurityManager.h" #include "nsIAggregatePrincipal.h" +#include "nsIProgressEventSink.h" #include "nsXPIDLString.h" static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); @@ -60,13 +61,9 @@ 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) { @@ -174,9 +171,9 @@ nsJARChannel::Cancel(nsresult status) if (mJarExtractionTransport) { rv = mJarExtractionTransport->Cancel(status); - if (NS_FAILED(rv)) return rv; mJarExtractionTransport = nsnull; } + mStatus = status; return rv; } @@ -184,29 +181,27 @@ nsJARChannel::Cancel(nsresult status) NS_IMETHODIMP nsJARChannel::Suspend() { - nsresult rv; + nsresult rv = NS_OK; nsAutoMonitor monitor(mMonitor); if (mJarExtractionTransport) { rv = mJarExtractionTransport->Suspend(); - if (NS_FAILED(rv)) return rv; } - return NS_OK; + return rv; } NS_IMETHODIMP nsJARChannel::Resume() { - nsresult rv; + nsresult rv = NS_OK; nsAutoMonitor monitor(mMonitor); if (mJarExtractionTransport) { rv = mJarExtractionTransport->Resume(); - if (NS_FAILED(rv)) return rv; } - return NS_OK; + return rv; } //////////////////////////////////////////////////////////////////////////////// @@ -255,12 +250,12 @@ nsJARChannel::OpenJARElement() rv = Open(nsnull, nsnull); if (NS_SUCCEEDED(rv)) rv = GetInputStream(getter_AddRefs(mSynchronousInputStream)); - mon.Notify(); // wake up OpenInputStream + mon.Notify(); // wake up nsIChannel::Open return rv; } NS_IMETHODIMP -nsJARChannel::OpenInputStream(nsIInputStream* *result) +nsJARChannel::Open(nsIInputStream* *result) { nsAutoCMonitor mon(this); nsresult rv; @@ -273,7 +268,7 @@ nsJARChannel::OpenInputStream(nsIInputStream* *result) { *result = mSynchronousInputStream; // Result of GetInputStream called on transport thread NS_ADDREF(*result); - mSynchronousInputStream = null_nsCOMPtr(); + mSynchronousInputStream = 0; return NS_OK; } else @@ -281,14 +276,7 @@ nsJARChannel::OpenInputStream(nsIInputStream* *result) } NS_IMETHODIMP -nsJARChannel::OpenOutputStream(nsIOutputStream* *result) -{ - NS_NOTREACHED("nsJARChannel::OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsJARChannel::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) +nsJARChannel::AsyncOpen(nsIStreamListener* listener, nsISupports* ctxt) { nsresult rv; mUserContext = ctxt; @@ -310,7 +298,7 @@ nsJARChannel::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) } } } - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -342,7 +330,7 @@ nsJARChannel::EnsureJARFileAvailable() rv = NS_NewDownloader(getter_AddRefs(mDownloader), mJARBaseURI, this, nsnull, mSynchronousRead, mLoadGroup, mCallbacks, - mLoadAttributes, mBufferSegmentSize, mBufferMaxSize); + mLoadAttributes); // if DownloadComplete() was called early, need to release the reference. if (mSynchronousRead && mSynchronousInputStream) @@ -350,7 +338,7 @@ nsJARChannel::EnsureJARFileAvailable() error: if (NS_FAILED(rv) && mLoadGroup) { - nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, NS_OK, nsnull); + nsresult rv2 = mLoadGroup->RemoveRequest(this, nsnull, NS_OK, nsnull); NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } return rv; @@ -366,20 +354,18 @@ nsJARChannel::AsyncReadJARElement() NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - 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); + nsCOMPtr jarTransport; + rv = fts->CreateTransportFromStreamIO(this, getter_AddRefs(jarTransport)); if (NS_FAILED(rv)) return rv; + if (mCallbacks) { + nsCOMPtr sink = do_GetInterface(mCallbacks); + if (sink) { + // don't think that this is not needed anymore + // jarTransport->SetProgressEventSink(sink); + } + } + #ifdef PR_LOGGING nsXPIDLCString jarURLStr; mURI->GetSpec(getter_Copies(jarURLStr)); @@ -387,18 +373,12 @@ nsJARChannel::AsyncReadJARElement() ("nsJarProtocol: AsyncRead jar entry %s", (const char*)jarURLStr)); #endif - rv = mJarExtractionTransport->AsyncRead(this, nsnull); + rv = jarTransport->AsyncRead(this, nsnull, 0, -1, 0, getter_AddRefs(mJarExtractionTransport)); + mJarExtractionTransport = 0; + jarTransport = 0; 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) { @@ -491,83 +471,6 @@ 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) { @@ -667,7 +570,7 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu else rv = AsyncReadJARElement(); } - mDownloader = null_nsCOMPtr(); + mDownloader = 0; return rv; } @@ -675,14 +578,14 @@ nsJARChannel::OnDownloadComplete(nsIDownloader* aDownloader, nsISupports* aClosu // nsIStreamObserver methods: NS_IMETHODIMP -nsJARChannel::OnStartRequest(nsIChannel* jarExtractionTransport, +nsJARChannel::OnStartRequest(nsIRequest* jarExtractionTransport, nsISupports* context) { return mUserListener->OnStartRequest(this, mUserContext); } NS_IMETHODIMP -nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* context, +nsJARChannel::OnStopRequest(nsIRequest* jarExtractionTransport, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; @@ -698,12 +601,10 @@ nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* con #endif rv = mUserListener->OnStopRequest(this, mUserContext, aStatus, aStatusArg); + NS_ASSERTION(NS_SUCCEEDED(rv), "OnStopRequest failed"); - if (mLoadGroup) { - if (NS_SUCCEEDED(rv)) { - mLoadGroup->RemoveChannel(this, context, aStatus, aStatusArg); - } - } + if (mLoadGroup) + mLoadGroup->RemoveRequest(this, context, aStatus, aStatusArg); mUserListener = nsnull; mUserContext = nsnull; @@ -715,7 +616,7 @@ nsJARChannel::OnStopRequest(nsIChannel* jarExtractionTransport, nsISupports* con // nsIStreamListener methods: NS_IMETHODIMP -nsJARChannel::OnDataAvailable(nsIChannel* jarCacheTransport, +nsJARChannel::OnDataAvailable(nsIRequest* 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 9bfdf71c3c4..e8d08e93c06 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARChannel.h +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.h @@ -89,8 +89,6 @@ protected: nsLoadFlags mLoadAttributes; nsCOMPtr mOwner; - PRUint32 mStartPosition; - PRInt32 mReadCount; nsCOMPtr mUserContext; nsCOMPtr mUserListener; @@ -100,15 +98,13 @@ 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 f96a1773a2d..976e2901ffb 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 +REQUIRES = xpcom exthandler mime CPPSRCS = \ nsResChannel.cpp \ diff --git a/mozilla/netwerk/protocol/res/src/nsResChannel.cpp b/mozilla/netwerk/protocol/res/src/nsResChannel.cpp index 558fde17734..ad114e946e8 100644 --- a/mozilla/netwerk/protocol/res/src/nsResChannel.cpp +++ b/mozilla/netwerk/protocol/res/src/nsResChannel.cpp @@ -29,6 +29,11 @@ #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); @@ -52,12 +57,8 @@ PRLogModuleInfo* gResChannelLog = nsnull; //////////////////////////////////////////////////////////////////////////////// nsResChannel::nsResChannel() - : mLoadAttributes(LOAD_NORMAL), +: mLoadAttributes(nsIResChannel::LOAD_NORMAL), mState(QUIESCENT), - mStartPosition(0), - mCount(-1), - mBufferSegmentSize(0), - mBufferMaxSize(0), mStatus(NS_OK) #ifdef DEBUG ,mInitiator(nsnull) @@ -87,12 +88,19 @@ nsResChannel::~nsResChannel() { } -NS_IMPL_ISUPPORTS5(nsResChannel, - nsIResChannel, - nsIChannel, - nsIRequest, - nsIStreamListener, - nsIStreamProvider) + +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_METHOD nsResChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) @@ -116,7 +124,8 @@ nsResChannel::Substitutions::Init() nsresult rv; nsResChannel* channel = GET_SUBSTITUTIONS_CHANNEL(this); - NS_ASSERTION(mSubstitutions == nsnull, "failed to call destructor"); + if (mSubstitutions) + return NS_ERROR_FAILURE; char* root; rv = channel->mResourceURI->GetHost(&root); @@ -294,31 +303,15 @@ nsResChannel::EnsureNextResolvedChannel() rv = mResolvedChannel->SetLoadGroup(mLoadGroup); if (NS_FAILED(rv)) goto done; } - if (mLoadAttributes != LOAD_NORMAL) { + if (mLoadAttributes != nsIResChannel::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; @@ -334,7 +327,7 @@ nsResChannel::EnsureNextResolvedChannel() } NS_IMETHODIMP -nsResChannel::OpenInputStream(nsIInputStream **result) +nsResChannel::Open(nsIInputStream **result) { nsresult rv; @@ -349,14 +342,16 @@ nsResChannel::OpenInputStream(nsIInputStream **result) if (NS_FAILED(rv)) break; if (mResolvedChannel) - rv = mResolvedChannel->OpenInputStream(result); + rv = mResolvedChannel->Open(result); } while (NS_FAILED(rv)); return rv; } +// XXX What does OpenOutputStream mean for a res "channel" +#if 0 NS_IMETHODIMP -nsResChannel::OpenOutputStream(nsIOutputStream **result) +nsResChannel::OpenOutputStream(PRUint32 transferOffset, PRUint32 transferCount, nsIOutputStream **result) { nsresult rv; @@ -371,14 +366,15 @@ nsResChannel::OpenOutputStream(nsIOutputStream **result) if (NS_FAILED(rv)) break; if (mResolvedChannel) - rv = mResolvedChannel->OpenOutputStream(result); + rv = mResolvedChannel->OpenOutputStream(transferOffset, transferCount, result); } while (NS_FAILED(rv)); return rv; } +#endif NS_IMETHODIMP -nsResChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +nsResChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { nsresult rv; @@ -415,65 +411,13 @@ nsResChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) if (NS_FAILED(rv)) break; if (mResolvedChannel) - rv = mResolvedChannel->AsyncRead(this, nsnull); + rv = mResolvedChannel->AsyncOpen(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; } @@ -497,7 +441,11 @@ nsResChannel::GetContentType(char * *aContentType) { if (mResolvedChannel) return mResolvedChannel->GetContentType(aContentType); - return NS_ERROR_FAILURE; + + // 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); } NS_IMETHODIMP @@ -505,6 +453,7 @@ nsResChannel::SetContentType(const char *aContentType) { if (mResolvedChannel) return mResolvedChannel->SetContentType(aContentType); + return NS_ERROR_FAILURE; } @@ -513,6 +462,7 @@ nsResChannel::GetContentLength(PRInt32 *aContentLength) { if (mResolvedChannel) return mResolvedChannel->GetContentLength(aContentLength); + return NS_ERROR_FAILURE; } @@ -523,104 +473,6 @@ 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) { @@ -678,18 +530,18 @@ nsResChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsResChannel::OnStartRequest(nsIChannel* transportChannel, nsISupports* context) +nsResChannel::OnStartRequest(nsIRequest* request, nsISupports* context) { #ifdef DEBUG NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif NS_ASSERTION(mUserObserver, "No observer..."); - return mUserObserver->OnStartRequest(this, mUserContext); + return mUserObserver->OnStartRequest(NS_STATIC_CAST(nsIResChannel*, this), mUserContext); } NS_IMETHODIMP -nsResChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context, +nsResChannel::OnStopRequest(nsIRequest* request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { #ifdef DEBUG @@ -697,12 +549,12 @@ nsResChannel::OnStopRequest(nsIChannel* transportChannel, 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 AsyncRead(GetUserListener(), mUserContext); - case ASYNC_WRITE: - return AsyncWrite(GetUserProvider(), mUserContext); + return AsyncOpen(GetUserListener(), mUserContext); default: break; } @@ -714,7 +566,8 @@ nsresult nsResChannel::EndRequest(nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; - rv = mUserObserver->OnStopRequest(this, mUserContext, aStatus, aStatusArg); + rv = mUserObserver->OnStopRequest(NS_STATIC_CAST(nsIResChannel*, 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)) { @@ -730,7 +583,7 @@ nsResChannel::EndRequest(nsresult aStatus, const PRUnichar* aStatusArg) } NS_IMETHODIMP -nsResChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context, +nsResChannel::OnDataAvailable(nsIRequest* request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) { @@ -738,20 +591,69 @@ nsResChannel::OnDataAvailable(nsIChannel* transportChannel, nsISupports* context NS_ASSERTION(mInitiator == PR_CurrentThread(), "wrong thread calling this routine"); #endif - return GetUserListener()->OnDataAvailable(this, mUserContext, aIStream, + return GetUserListener()->OnDataAvailable(NS_STATIC_CAST(nsIResChannel*, this), + mUserContext, aIStream, aSourceOffset, aLength); } -NS_IMETHODIMP -nsResChannel::OnDataWritable(nsIChannel* transportChannel, nsISupports* context, - nsIOutputStream *aOStream, PRUint32 aOffset, PRUint32 aLength) +//////////////////////////////////////////////////////////////////////////////// + + +/* void init (in nsIFile file, in long ioFlags, in long perm); */ +NS_IMETHODIMP nsResChannel::Init(nsIFile *file, PRInt32 ioFlags, PRInt32 perm) { -#ifdef DEBUG - NS_ASSERTION(mInitiator == PR_CurrentThread(), - "wrong thread calling this routine"); -#endif - return GetUserProvider()->OnDataWritable(this, mUserContext, aOStream, - aOffset, aLength); + 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 20736d8b06c..312c52ed038 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 nsIStreamListener, - public nsIStreamProvider + public nsIFileChannel, + public nsIStreamListener { 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,10 +119,6 @@ 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 734f3bed6d8..73cc77952ae 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 = channel; + *result = (nsIChannel*)(nsIResChannel*)channel; return NS_OK; } diff --git a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index c884c550bf5..a1180570b30 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(nsIChannel *channel, nsISupports *ctxt, +mozTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { @@ -1096,13 +1096,13 @@ mozTXTToHTMLConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, } NS_IMETHODIMP -mozTXTToHTMLConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) +mozTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -mozTXTToHTMLConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, +mozTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { return NS_ERROR_NOT_IMPLEMENTED; @@ -1159,10 +1159,6 @@ 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 52f995d6779..5604aab5211 100644 --- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -60,7 +60,10 @@ 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 @@ -245,10 +248,15 @@ nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnicha // nsIStreamListener implementation NS_IMETHODIMP -nsFTPDirListingConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, +nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { - NS_ASSERTION(channel, "FTP dir listing stream converter needs a channel"); + NS_ASSERTION(request, "FTP dir listing stream converter needs a request"); + nsresult rv; + + nsCOMPtr channel = do_QueryInterface(request, &rv); + if (NS_FAILED(rv)) return rv; + PRUint32 read, streamLen; nsCAutoString indexFormat; indexFormat.SetCapacity(72); // quick guess @@ -263,7 +271,7 @@ nsFTPDirListingConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, // the dir listings are ascii text, null terminate this sucker. buffer[streamLen] = '\0'; - PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::OnData(channel = %x, ctxt = %x, inStr = %x, sourceOffset = %d, count = %d)\n", channel, ctxt, inStr, sourceOffset, count)); + PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("nsFTPDirListingConv::OnData(request = %x, ctxt = %x, inStr = %x, sourceOffset = %d, count = %d)\n", request, ctxt, inStr, sourceOffset, count)); if (!mBuffer.IsEmpty()) { // we have data left over from a previous OnDataAvailable() call. @@ -346,22 +354,29 @@ nsFTPDirListingConv::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, // nsIStreamObserver implementation NS_IMETHODIMP -nsFTPDirListingConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { +nsFTPDirListingConv::OnStartRequest(nsIRequest* request, 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(nsIChannel *channel, nsISupports *ctxt, +nsFTPDirListingConv::OnStopRequest(nsIRequest* request, 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; - nsresult rv = mPartChannel->GetLoadGroup(getter_AddRefs(loadgroup)); + rv = channel->GetLoadGroup(getter_AddRefs(loadgroup)); if (NS_FAILED(rv)) return rv; if (loadgroup) - (void)loadgroup->RemoveChannel(mPartChannel, nsnull, aStatus, aStatusArg); + (void)loadgroup->RemoveRequest(mPartChannel, nsnull, aStatus, aStatusArg); return mFinalListener->OnStopRequest(mPartChannel, ctxt, aStatus, aStatusArg); } @@ -734,6 +749,9 @@ 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) { @@ -845,6 +863,64 @@ 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); @@ -921,3 +997,4 @@ 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 80ff10b0125..41b1ca48ab8 100644 --- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.h +++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.h @@ -54,7 +54,8 @@ 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 @@ -69,7 +70,8 @@ typedef enum _FTP_Server_Type { CMS, TCPC, VMS, - NT + NT, + EPLF } FTP_Server_Type; typedef enum _FTPentryType { diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp b/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp index 7d0f1dfb6b2..7a25acb1743 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 (nsIChannel *aChannel, nsISupports *aContext) +nsHTTPChunkConv::OnStartRequest (nsIRequest* request, nsISupports *aContext) { - return mListener -> OnStartRequest (aChannel, aContext); + return mListener->OnStartRequest (request, aContext); } NS_IMETHODIMP -nsHTTPChunkConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsHTTPChunkConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); } NS_IMETHODIMP nsHTTPChunkConv::OnDataAvailable ( - nsIChannel *aChannel, + nsIRequest* request, nsISupports *aContext, nsIInputStream *iStr, PRUint32 aSourceOffset, @@ -160,7 +160,7 @@ nsHTTPChunkConv::OnDataAvailable ( if (NS_FAILED (rv)) return rv; - rv = mListener -> OnDataAvailable (aChannel, aContext, convertedStream, aSourceOffset, mChunkBufferLength); + rv = mListener -> OnDataAvailable (request, 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 (aChannel, aContext, convertedStream, aSourceOffset, mChunkBufferLength); + rv = mListener -> OnDataAvailable (request, aContext, convertedStream, aSourceOffset, mChunkBufferLength); if (NS_FAILED (rv)) return rv; @@ -440,4 +440,3 @@ NS_NewHTTPChunkConv (nsHTTPChunkConv ** aHTTPChunkConv) return NS_OK; } - diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index e8923e274ff..c5ea3c46f6f 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 (nsIChannel *aChannel, nsISupports *aContext) +nsHTTPCompressConv::OnStartRequest (nsIRequest* request, nsISupports *aContext) { - return mListener -> OnStartRequest (aChannel, aContext); + return mListener->OnStartRequest (request, aContext); } NS_IMETHODIMP -nsHTTPCompressConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsHTTPCompressConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); } NS_IMETHODIMP nsHTTPCompressConv::OnDataAvailable ( - nsIChannel *aChannel, + nsIRequest* request, 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 (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, (PRUint32) uLen); + rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, (PRUint32) uLen); if (NS_FAILED (rv)) return rv; @@ -211,7 +211,7 @@ nsHTTPCompressConv::OnDataAvailable ( { if (bytesWritten) { - rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); if (NS_FAILED (rv)) return rv; } @@ -225,7 +225,7 @@ nsHTTPCompressConv::OnDataAvailable ( { if (bytesWritten) { - rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); if (NS_FAILED (rv)) return rv; } @@ -235,7 +235,7 @@ nsHTTPCompressConv::OnDataAvailable ( { if (bytesWritten) { - rv = do_OnDataAvailable (aChannel, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); + rv = do_OnDataAvailable (request, aContext, aSourceOffset, (char *)mOutBuffer, bytesWritten); if (NS_FAILED (rv)) return rv; } @@ -248,7 +248,7 @@ nsHTTPCompressConv::OnDataAvailable ( break; default: - rv = mListener -> OnDataAvailable (aChannel, aContext, iStr, aSourceOffset, aCount); + rv = mListener->OnDataAvailable (request, aContext, iStr, aSourceOffset, aCount); if (NS_FAILED (rv)) return rv; } /* switch */ @@ -271,24 +271,7 @@ nsHTTPCompressConv::Convert ( } 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; -} - -nsresult -nsHTTPCompressConv::do_OnDataAvailable (nsIChannel *aChannel, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount) +nsHTTPCompressConv::do_OnDataAvailable (nsIRequest* request, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount) { nsresult rv; @@ -308,7 +291,7 @@ nsHTTPCompressConv::do_OnDataAvailable (nsIChannel *aChannel, nsISupports *aCont if (NS_FAILED (rv)) return rv; - rv = mListener -> OnDataAvailable (aChannel, aContext, convertedStream, aSourceOffset, aCount); + rv = mListener->OnDataAvailable (request, aContext, convertedStream, aSourceOffset, aCount); return rv; } @@ -339,7 +322,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]) @@ -375,7 +358,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++; @@ -386,7 +369,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; @@ -396,7 +379,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; @@ -408,7 +391,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++; } @@ -417,7 +400,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; @@ -429,7 +412,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) { @@ -447,7 +430,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) @@ -466,3 +449,23 @@ 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 d49c95fcf52..201bcddf2f2 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 (nsIChannel *aChannel, nsISupports *aContext, PRUint32 aSourceOffset, char *buffer, PRUint32 aCount); + nsresult do_OnDataAvailable (nsIRequest *request, 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 356713feae9..ec0a40d27af 100644 --- a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -34,8 +34,10 @@ 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 @@ -69,14 +71,17 @@ nsMultiMixedConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnichar * // nsIStreamListener implementation NS_IMETHODIMP -nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *context, +nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv = NS_OK; char *buffer = nsnull; PRUint32 bufLen = count, read; - NS_ASSERTION(channel, "multimixed converter needs a channel"); + NS_ASSERTION(request, "multimixed converter needs a request"); + nsCOMPtr channel = do_QueryInterface(request, &rv); + if (NS_FAILED(rv)) return rv; + buffer = (char*)nsMemory::Alloc(bufLen); if (!buffer) ERR_OUT @@ -204,7 +209,7 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *context, // nsIStreamObserver implementation NS_IMETHODIMP -nsMultiMixedConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { +nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { // we're assuming the content-type is available at this stage NS_ASSERTION(!mToken, "a second on start???"); char *bndry = nsnull; @@ -212,9 +217,11 @@ nsMultiMixedConv::OnStartRequest(nsIChannel *channel, 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; - rv = channel->QueryInterface(NS_GET_IID(nsIHTTPChannel), getter_AddRefs(httpChannel)); + nsCOMPtr httpChannel = do_QueryInterface(channel, &rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr header = NS_NewAtom("content-type"); if (!header) return NS_ERROR_OUT_OF_MEMORY; @@ -223,7 +230,7 @@ nsMultiMixedConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { } else { // try asking the channel directly rv = channel->GetContentType(getter_Copies(delimiter)); - if (NS_FAILED(rv)) return rv; + if (!delimiter || NS_FAILED(rv)) return NS_ERROR_FAILURE; } if (!delimiter) return NS_ERROR_FAILURE; @@ -250,7 +257,7 @@ nsMultiMixedConv::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { } NS_IMETHODIMP -nsMultiMixedConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, +nsMultiMixedConv::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -268,10 +275,10 @@ nsMultiMixedConv::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, } rv = mFinalListener->OnStopRequest(mPartChannel, mContext, aStatus, aStatusArg); } else { - rv = mFinalListener->OnStartRequest(channel, ctxt); + rv = mFinalListener->OnStartRequest(request, ctxt); if (NS_FAILED(rv)) return rv; - rv = mFinalListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); + rv = mFinalListener->OnStopRequest(request, ctxt, aStatus, aStatusArg); } } else { @@ -332,7 +339,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()) @@ -346,9 +353,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)); @@ -356,7 +363,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) { if (loadGroup) { rv = mPartChannel->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; - rv = loadGroup->AddChannel(mPartChannel, nsnull); + rv = loadGroup->AddRequest(mPartChannel, nsnull); if (NS_FAILED(rv)) return rv; } @@ -376,7 +383,7 @@ nsMultiMixedConv::SendStop() { (void) mPartChannel->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) { - loadGroup->RemoveChannel(mPartChannel, mContext, NS_OK, nsnull); + loadGroup->RemoveRequest(mPartChannel, mContext, NS_OK, nsnull); } mPartChannel = 0; @@ -548,3 +555,4 @@ 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 7c039c7f5f0..44a86833b14 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(nsIChannel *aChannel, nsISupports *aContext) { +nsTXTToHTMLConv::OnStartRequest(nsIRequest* request, nsISupports *aContext) { mBuffer.AssignWithConversion("\n"); mBuffer.Append(mPageTitle); mBuffer.AppendWithConversion("\n\n"); @@ -66,7 +66,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { // Push mBuffer to the listener now, so the initial HTML will not // be parsed in OnDataAvailable(). - nsresult rv = mListener->OnStartRequest(aChannel, aContext); + nsresult rv = mListener->OnStartRequest(request, aContext); if (NS_FAILED(rv)) return rv; nsCOMPtr inputData; @@ -75,7 +75,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { if (NS_FAILED(rv)) return rv; inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(aChannel, aContext, + rv = mListener->OnDataAvailable(request, aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; mBuffer.AssignWithConversion(""); @@ -83,7 +83,7 @@ nsTXTToHTMLConv::OnStartRequest(nsIChannel *aChannel, nsISupports *aContext) { } NS_IMETHODIMP -nsTXTToHTMLConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +nsTXTToHTMLConv::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; if (mToken) { @@ -105,11 +105,11 @@ nsTXTToHTMLConv::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(aChannel, aContext, + rv = mListener->OnDataAvailable(request, aContext, inputData, 0, mBuffer.Length()); if (NS_FAILED(rv)) return rv; - return mListener->OnStopRequest(aChannel, aContext, aStatus, aStatusArg); + return mListener->OnStopRequest(request, aContext, aStatus, aStatusArg); } // nsITXTToHTMLConv methods @@ -127,7 +127,7 @@ nsTXTToHTMLConv::PreFormatHTML(PRBool value) { // nsIStreamListener method NS_IMETHODIMP -nsTXTToHTMLConv::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, +nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext, nsIInputStream *aInStream, PRUint32 aOffset, PRUint32 aCount) { nsresult rv = NS_OK; @@ -180,7 +180,7 @@ nsTXTToHTMLConv::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, inputData = do_QueryInterface(inputDataSup); - rv = mListener->OnDataAvailable(aChannel, aContext, + rv = mListener->OnDataAvailable(request, aContext, inputData, 0, pushBuffer.Length()); if (NS_FAILED(rv)) { nsMemory::Free(buffer); @@ -277,17 +277,3 @@ 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 bc5f7e2066e..124d69641b5 100644 --- a/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.h +++ b/mozilla/netwerk/streamconv/converters/nsTXTToHTMLConv.h @@ -36,7 +36,6 @@ 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 a9b1f39b4d2..7b6204b5e6e 100644 --- a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -21,7 +21,6 @@ */ #include "nsUnknownDecoder.h" - #include "nsIServiceManager.h" #include "nsIStreamConverterService.h" @@ -120,7 +119,7 @@ nsUnknownDecoder::AsyncConvertData(const PRUnichar *aFromType, // ---- NS_IMETHODIMP -nsUnknownDecoder::OnDataAvailable(nsIChannel *aChannel, +nsUnknownDecoder::OnDataAvailable(nsIRequest* request, nsISupports *aCtxt, nsIInputStream *aStream, PRUint32 aSourceOffset, @@ -161,11 +160,11 @@ nsUnknownDecoder::OnDataAvailable(nsIChannel *aChannel, // aSourceOffset += mBufferLen; - DetermineContentType(aChannel); + DetermineContentType(request); NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); - rv = FireListenerNotifications(aChannel, aCtxt); + rv = FireListenerNotifications(request, aCtxt); } } @@ -173,7 +172,7 @@ nsUnknownDecoder::OnDataAvailable(nsIChannel *aChannel, NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); - rv = mNextListener->OnDataAvailable(aChannel, aCtxt, aStream, + rv = mNextListener->OnDataAvailable(request, aCtxt, aStream, aSourceOffset, aCount); } @@ -187,7 +186,7 @@ nsUnknownDecoder::OnDataAvailable(nsIChannel *aChannel, // ---- NS_IMETHODIMP -nsUnknownDecoder::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) +nsUnknownDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt) { nsresult rv = NS_OK; @@ -207,7 +206,7 @@ nsUnknownDecoder::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) } NS_IMETHODIMP -nsUnknownDecoder::OnStopRequest(nsIChannel *aChannel, nsISupports *aCtxt, +nsUnknownDecoder::OnStopRequest(nsIRequest* request, nsISupports *aCtxt, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv = NS_OK; @@ -219,25 +218,25 @@ nsUnknownDecoder::OnStopRequest(nsIChannel *aChannel, nsISupports *aCtxt, // Analyze the buffer now... // if (mContentType.IsEmpty()) { - DetermineContentType(aChannel); + DetermineContentType(request); NS_ASSERTION(!mContentType.IsEmpty(), "Content type should be known by now."); - rv = FireListenerNotifications(aChannel, aCtxt); + rv = FireListenerNotifications(request, aCtxt); if (NS_FAILED(rv)) { aStatus = rv; } } - rv = mNextListener->OnStopRequest(aChannel, aCtxt, aStatus, aStatusArg); + rv = mNextListener->OnStopRequest(request, aCtxt, aStatus, aStatusArg); mNextListener = 0; return rv; } -void nsUnknownDecoder::DetermineContentType(nsIChannel *aChannel) +void nsUnknownDecoder::DetermineContentType(nsIRequest* request) { PRUint32 i; @@ -276,7 +275,10 @@ void nsUnknownDecoder::DetermineContentType(nsIChannel *aChannel) */ PRBool isLocalFile = PR_FALSE; - if (aChannel) { + if (request) { + nsCOMPtr aChannel = do_QueryInterface(request); + if (!request) { NS_WARNING("QI failed"); return; } + nsCOMPtr pURL; if (NS_SUCCEEDED(aChannel->GetURI(getter_AddRefs(pURL)))) pURL->SchemeIs(nsIURI::FILE, &isLocalFile); @@ -324,7 +326,7 @@ void nsUnknownDecoder::DetermineContentType(nsIChannel *aChannel) } } -nsresult nsUnknownDecoder::FireListenerNotifications(nsIChannel *aChannel, +nsresult nsUnknownDecoder::FireListenerNotifications(nsIRequest* request, nsISupports *aCtxt) { nsresult rv = NS_OK; @@ -333,11 +335,14 @@ nsresult nsUnknownDecoder::FireListenerNotifications(nsIChannel *aChannel, 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... - aChannel->SetContentType(mContentType); + channel->SetContentType(mContentType); // Fire the OnStartRequest(...) - rv = mNextListener->OnStartRequest(aChannel, aCtxt); + rv = mNextListener->OnStartRequest(request, aCtxt); // Fire the first OnDataAvailable for the data that was read from the // stream into the sniffer buffer... @@ -354,7 +359,7 @@ nsresult nsUnknownDecoder::FireListenerNotifications(nsIChannel *aChannel, rv = out->Write(mBuffer, mBufferLen, &len); if (NS_SUCCEEDED(rv)) { if (len == mBufferLen) { - rv = mNextListener->OnDataAvailable(aChannel, aCtxt, in, 0, len); + rv = mNextListener->OnDataAvailable(request, 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 4cc2be95291..78d037aab7d 100644 --- a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.h +++ b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.h @@ -53,14 +53,13 @@ public: // nsIStreamObserver methods NS_DECL_NSISTREAMOBSERVER - nsUnknownDecoder(); protected: virtual ~nsUnknownDecoder(); - void DetermineContentType(nsIChannel *aChannel); - nsresult FireListenerNotifications(nsIChannel *aChannel, nsISupports *aCtxt); + void DetermineContentType(nsIRequest* request); + nsresult FireListenerNotifications(nsIRequest* request, nsISupports *aCtxt); protected: nsCOMPtr mNextListener; diff --git a/mozilla/netwerk/streamconv/test/Converters.cpp b/mozilla/netwerk/streamconv/test/Converters.cpp index a310aebea97..91ba0e12e61 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(nsIChannel *channel, +TestConverter::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, @@ -87,20 +87,20 @@ TestConverter::OnDataAvailable(nsIChannel *channel, PRUint32 len; convertedStream->Available(&len); - return mListener->OnDataAvailable(channel, ctxt, convertedStream, sourceOffset, len); + return mListener->OnDataAvailable(request, ctxt, convertedStream, sourceOffset, len); }; // nsIStreamObserver methods /* These methods just pass through directly to the mListener */ NS_IMETHODIMP -TestConverter::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { - return mListener->OnStartRequest(channel, ctxt); +TestConverter::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { + return mListener->OnStartRequest(request, ctxt); }; NS_IMETHODIMP -TestConverter::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, +TestConverter::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { - return mListener->OnStopRequest(channel, ctxt, aStatus, aStatusArg); + return mListener->OnStopRequest(request, ctxt, aStatus, aStatusArg); }; diff --git a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp index 379d2034911..c27bc708918 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(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, + NS_IMETHOD OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv; @@ -102,12 +102,12 @@ public: } // nsIStreamObserver methods - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) + NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt) { return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIRequest* request, 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, nsIChannel* aChannel) { +nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) { nsString data; data.AssignWithConversion(aData); nsCOMPtr dataStream; @@ -129,9 +129,9 @@ nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIChannel* if (NS_FAILED(rv)) return rv; dataStream = do_QueryInterface(sup, &rv); if (NS_FAILED(rv)) return rv; - return aListener->OnDataAvailable(aChannel, nsnull, dataStream, 0, -1); + return aListener->OnDataAvailable(request, nsnull, dataStream, 0, -1); } -#define SEND_DATA(x) SendData(x, converterListener, dummyChannel) +#define SEND_DATA(x) SendData(x, converterListener, nsnull) 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 dummyChannel; + nsCOMPtr channel; nsCOMPtr dummyURI; rv = serv->NewURI("http://neverneverland.com", nsnull, getter_AddRefs(dummyURI)); if (NS_FAILED(rv)) return rv; - rv = NS_NewInputStreamChannel(getter_AddRefs(dummyChannel), + rv = NS_NewInputStreamChannel(getter_AddRefs(channel), dummyURI, nsnull, // inStr "multipart/x-mixed-replacE;boundary=thisrandomstring", @@ -300,9 +300,10 @@ 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(dummyChannel, nsnull); + rv = converterListener->OnStartRequest(nsnull, 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; @@ -325,7 +326,7 @@ main(int argc, char* argv[]) if (NS_FAILED(rv)) return rv; // Finish the request. - rv = converterListener->OnStopRequest(dummyChannel, nsnull, rv, nsnull); + rv = converterListener->OnStopRequest(nsnull, nsnull, rv, nsnull); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/netwerk/test/Makefile.in b/mozilla/netwerk/test/Makefile.in index 2959cc0908d..cca320cb156 100644 --- a/mozilla/netwerk/test/Makefile.in +++ b/mozilla/netwerk/test/Makefile.in @@ -36,10 +36,10 @@ CPPSRCS = \ TestSocketInput.cpp \ TestSocketTransport.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 70306b04b18..fd56cf15be6 100644 --- a/mozilla/netwerk/test/TestCacheMgr.cpp +++ b/mozilla/netwerk/test/TestCacheMgr.cpp @@ -23,6 +23,7 @@ #include "nsIOutputStream.h" #include "nsIEventQueue.h" #include "nsIEventQueueService.h" +#include "nsITransport.h" #include "nsIChannel.h" #include "nsCOMPtr.h" @@ -192,13 +193,13 @@ public: return NS_OK; } - NS_IMETHOD OnStartRequest(nsIChannel* channel, + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports* context) { mStartTime = PR_IntervalNow(); return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIChannel* channel, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -217,7 +218,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { PRIntervalTime endTime; PRIntervalTime duration; @@ -297,7 +298,7 @@ TestReadStream(nsICachedNetData *cacheEntry, nsITestDataStream *testDataStream, rv = reader->Init(testDataStream, expectedStreamLength); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - rv = channel->AsyncRead(0, reader); + rv = channel->AsyncOpen(0, reader); NS_ASSERTION(NS_SUCCEEDED(rv), " "); reader->Release(); @@ -493,7 +494,8 @@ FillCache(nsINetDataCacheManager *aCache, PRUint32 aFlags, PRUint32 aCacheCapaci rv = cacheEntry->GetCache(getter_AddRefs(containingCache)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - rv = channel->OpenOutputStream(getter_AddRefs(outStream)); + nsCOMPtr trans(do_QueryInterface(channel)); + rv = trans->OpenOutputStream(0, -1, 0,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 264d6100f7a..b61f5ca92bc 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(nsIChannel *aChannel, nsISupports *aContext); + nsresult Validate(nsIRequest *request, 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(nsIChannel *aChannel, nsISupports* aContext) { +Consumer::OnStartRequest(nsIRequest *request, nsISupports* aContext) { fprintf(stderr, "Consumer::OnStart() -> in\n\n"); if (mOnStart) { @@ -108,7 +108,7 @@ Consumer::OnStartRequest(nsIChannel *aChannel, nsISupports* aContext) { } mOnStart = PR_TRUE; - nsresult rv = Validate(aChannel, aContext); + nsresult rv = Validate(request, aContext); if (NS_FAILED(rv)) return rv; fprintf(stderr, "Consumer::OnStart() -> out\n\n"); @@ -116,7 +116,7 @@ Consumer::OnStartRequest(nsIChannel *aChannel, nsISupports* aContext) { } NS_IMETHODIMP -Consumer::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, +Consumer::OnStopRequest(nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar* aStatusArg) { fprintf(stderr, "Consumer::OnStop() -> in\n\n"); @@ -133,7 +133,7 @@ Consumer::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, mOnStop = PR_TRUE; - nsresult rv = Validate(aChannel, aContext); + nsresult rv = Validate(request, aContext); if (NS_FAILED(rv)) return rv; fprintf(stderr, "Consumer::OnStop() -> out\n\n"); @@ -143,7 +143,7 @@ Consumer::OnStopRequest(nsIChannel *aChannel, nsISupports *aContext, // nsIStreamListener implementation NS_IMETHODIMP -Consumer::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, +Consumer::OnDataAvailable(nsIRequest *request, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 aOffset, PRUint32 aLength) { fprintf(stderr, "Consumer::OnData() -> in\n\n"); @@ -155,7 +155,7 @@ Consumer::OnDataAvailable(nsIChannel *aChannel, nsISupports *aContext, mOnDataCount += 1; - nsresult rv = Validate(aChannel, aContext); + nsresult rv = Validate(request, 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,9 +196,11 @@ Consumer::Init(nsIURI *aURI, nsIChannel *aChannel, nsISupports *aContext) { } nsresult -Consumer::Validate(nsIChannel *aChannel, nsISupports *aContext) { +Consumer::Validate(nsIRequest* request, 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; @@ -310,6 +312,6 @@ nsresult StartLoad(char *aURISpec) { if (NS_FAILED(rv)) return rv; // kick off the load - return channel->AsyncRead(NS_STATIC_CAST(nsIStreamListener*, consumer), - contextSup); + nsCOMPtr request; + return channel->AsyncOpen(NS_STATIC_CAST(nsIStreamListener*, consumer), contextSup); } diff --git a/mozilla/netwerk/test/TestFileInput.cpp b/mozilla/netwerk/test/TestFileInput.cpp index 85a22fcbc47..1221ce872bd 100644 --- a/mozilla/netwerk/test/TestFileInput.cpp +++ b/mozilla/netwerk/test/TestFileInput.cpp @@ -110,7 +110,7 @@ public: return NS_OK; } - NS_IMETHOD OnStartRequest(nsIChannel* channel, + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports* context) { PR_EnterMonitor(mMonitor); printf("start binding\n"); @@ -119,7 +119,7 @@ public: return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIChannel* channel, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -140,7 +140,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIRequest *request, 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"); - nsIChannel* trans; + nsITransport* trans; rv = fts->CreateTransport(file, PR_RDONLY, 0, &trans); NS_ASSERTION(NS_SUCCEEDED(rv), "create failed"); - - rv = trans->AsyncRead(nsnull, listener); + nsCOMPtr request; + rv = trans->AsyncRead(nsnull, listener, 0, -1, 0, getter_AddRefs(request)); 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 cad66aa679d..0dba1849eeb 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->OpenInputStream(getter_AddRefs(inStr)); + rv = inCh->Open(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(getter_AddRefs(outStr)); - if (NS_FAILED(rv)) return rv; + //rv = outCh->OpenOutputStream(0, -1, 0, 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 015e3b175cc..1f2c5b23ded 100644 --- a/mozilla/netwerk/test/TestFileTransport.cpp +++ b/mozilla/netwerk/test/TestFileTransport.cpp @@ -21,7 +21,8 @@ */ #include "nsIFileTransportService.h" -#include "nsIChannel.h" +#include "nsITransport.h" +#include "nsIRequest.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsCOMPtr.h" @@ -58,12 +59,12 @@ class MyListener : public nsIStreamListener { public: NS_DECL_ISUPPORTS - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { PRINTF(("starting\n")); return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { PRINTF(("ending status=%0x total=%d\n", aStatus, mTotal)); if (--mStopCount == 0) @@ -71,7 +72,7 @@ public: return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { PRINTF(("receiving %d bytes\n", count)); @@ -145,7 +146,7 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length) NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsIChannel* fileTrans; + nsITransport* fileTrans; nsCOMPtr file; rv = NS_NewLocalFile(fileName, PR_FALSE, getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; @@ -160,11 +161,8 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length) if (NS_FAILED(rv)) return rv; gDone = PR_FALSE; - 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); + nsCOMPtr request; + rv = fileTrans->AsyncRead(listener, nsnull, offset, length, 0, getter_AddRefs(request)); if (NS_FAILED(rv)) return rv; while (!gDone) { @@ -194,7 +192,7 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length) nsCAutoString outFile(fileName); outFile.Append(".out"); - nsIChannel* fileTrans; + nsITransport* fileTrans; nsCOMPtr file; rv = NS_NewLocalFile(outFile, PR_FALSE, getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; @@ -218,11 +216,8 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length) if (NS_FAILED(rv)) return rv; gDone = PR_FALSE; - 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); + nsCOMPtr request; + rv = NS_AsyncWriteFromStream(getter_AddRefs(request), fileTrans, inStr, offset, length, 0, listener); if (NS_FAILED(rv)) return rv; while (!gDone) { @@ -240,18 +235,20 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length) //////////////////////////////////////////////////////////////////////////////// +#if 0 class MyOpenObserver : public nsIStreamObserver { public: NS_DECL_ISUPPORTS - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsresult rv; char* contentType; + nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetContentType(&contentType); if (NS_FAILED(rv)) return rv; PRInt32 length; - rv = channel->GetContentLength(&length); + rv = cr->GetContentLength(&length); if (NS_FAILED(rv)) return rv; PRINTF(("stream opened: content type = %s, length = %d\n", contentType, length)); @@ -259,7 +256,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { PRINTF(("stream closed: status %x\n", aStatus)); return NS_OK; @@ -270,6 +267,7 @@ public: }; NS_IMPL_ISUPPORTS1(MyOpenObserver, nsIStreamObserver); +#endif //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/test/TestProtocols.cpp b/mozilla/netwerk/test/TestProtocols.cpp index 2fa12cd6bc3..d30101f47e8 100644 --- a/mozilla/netwerk/test/TestProtocols.cpp +++ b/mozilla/netwerk/test/TestProtocols.cpp @@ -65,6 +65,8 @@ 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 { @@ -164,7 +166,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)); @@ -192,7 +194,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)); @@ -262,16 +264,17 @@ protected: NS_IMPL_ISUPPORTS1(OpenObserver, nsIStreamObserver); NS_IMETHODIMP -OpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) +OpenObserver::OnStartRequest(nsIRequest *request, nsISupports* context) { - printf("\n+++ OpenObserver::OnStartRequest +++. Context = %p\n", context); + printf("\n+++ OpenObserver::OnStartRequest +++. Context = %p\n", (void*)context); char* type; PRInt32 length = -1; nsresult rv; - rv = channel->GetContentType(&type); + nsCOMPtr pChan(do_QueryInterface(context)); + rv = pChan->GetContentType(&type); NS_ASSERTION(NS_SUCCEEDED(rv), "GetContentType failed"); - rv = channel->GetContentLength(&length); + rv = pChan->GetContentLength(&length); NS_ASSERTION(NS_SUCCEEDED(rv), "GetContentLength failed"); printf(" contentType = %s length = %d\n", type, length); nsCRT::free(type); @@ -280,12 +283,12 @@ OpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) } NS_IMETHODIMP -OpenObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, +OpenObserver::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { printf("\n+++ OpenObserver::OnStopRequest (status = %x) +++." "\tContext = %p\n", - aStatus, context); + aStatus, (void*)context); return NS_OK; } @@ -305,7 +308,7 @@ NS_IMPL_ISUPPORTS(InputTestConsumer,NS_GET_IID(nsIStreamListener)); NS_IMETHODIMP -InputTestConsumer::OnStartRequest(nsIChannel* channel, nsISupports* context) +InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context) { URLLoadInfo* info = (URLLoadInfo*)context; if (info) { @@ -333,7 +336,7 @@ InputTestConsumer::OnStartRequest(nsIChannel* channel, nsISupports* context) NS_IMETHODIMP -InputTestConsumer::OnDataAvailable(nsIChannel* channel, +InputTestConsumer::OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -367,9 +370,31 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, 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(nsIChannel* channel, nsISupports* context, +InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { URLLoadInfo* info = (URLLoadInfo*)context; @@ -385,7 +410,7 @@ InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, connectTime = (info->mConnectTime/1000.0)/1000.0; readTime = ((info->mTotalTime-info->mConnectTime)/1000.0)/1000.0; - nsCOMPtr pHTTPCon(do_QueryInterface(channel)); + nsCOMPtr pHTTPCon(do_QueryInterface(request)); if (pHTTPCon) { pHTTPCon->GetResponseStatus(&httpStatus); bHTTPURL = PR_TRUE; @@ -422,7 +447,8 @@ InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, nsCRT::free(location); } */ - gKeepRunning -= 1; + FireDecrement(); + return NS_OK; } @@ -521,9 +547,8 @@ nsresult StartLoadingURL(const char* aUrlString) return NS_ERROR_OUT_OF_MEMORY; } - - rv = pChannel->AsyncRead(listener, // IStreamListener consumer - info); // ISupports context + rv = pChannel->AsyncOpen(listener, // IStreamListener consumer + info); if (NS_SUCCEEDED(rv)) { gKeepRunning += 1; @@ -580,6 +605,19 @@ 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[]) { @@ -616,6 +654,7 @@ main(int argc, char* argv[]) if (NS_FAILED(rv)) return rv; #endif // NECKO + int i; printf("\nTrying to load:\n"); for (i=1; i @@ -203,13 +204,13 @@ public: return NS_OK; } - NS_IMETHOD OnStartRequest(nsIChannel* channel, + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports* context) { mStartTime = PR_IntervalNow(); return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIChannel* channel, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -228,7 +229,7 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { PRIntervalTime endTime; PRIntervalTime duration; @@ -305,7 +306,7 @@ TestReadStream(nsINetDataCacheRecord *record, nsITestDataStream *testDataStream, rv = reader->Init(testDataStream, expectedStreamLength); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - rv = channel->AsyncRead(0, reader); + rv = channel->AsyncOpen(0, reader); NS_ASSERTION(NS_SUCCEEDED(rv), " "); reader->Release(); @@ -547,9 +548,8 @@ TestOffsetWrites(nsINetDataCache *cache) NS_ASSERTION(NS_SUCCEEDED(rv), " "); startingOffset = streamLength ? streamLength - (randomStream->Next() % sizeof buf): 0; - rv = channel->SetTransferOffset(startingOffset); - NS_ASSERTION(NS_SUCCEEDED(rv), "SetTransferOffset failed"); - rv = channel->OpenOutputStream(getter_AddRefs(outStream)); + nsCOMPtr trans(do_QueryInterface(channel)); + rv = trans->OpenOutputStream(startingOffset, -1, 0, getter_AddRefs(outStream)); NS_ASSERTION(NS_SUCCEEDED(rv), "OpenOutputStream failed"); counterStream = new CounterStream(startingOffset); @@ -631,7 +631,8 @@ FillCache(nsINetDataCache *cache) rv = record->NewChannel(0, getter_AddRefs(channel)); NS_ASSERTION(NS_SUCCEEDED(rv), " "); - rv = channel->OpenOutputStream(getter_AddRefs(outStream)); + nsCOMPtr trans(do_QueryInterface(channel)); + rv = trans->OpenOutputStream(0, -1, 0, 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 dd9ab94afa8..32690c6f22e 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->OpenInputStream(getter_AddRefs(in)); + rv = channel->Open(getter_AddRefs(in)); if (NS_FAILED(rv)) { fprintf(stdout, "failed to OpenInputStream for %s\n", url); return NS_OK; @@ -127,9 +127,11 @@ public: Listener() { NS_INIT_REFCNT(); } virtual ~Listener() {} - NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt) { + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsresult rv; nsCOMPtr uri; + nsCOMPtr channel = do_QueryInterface(request); + rv = channel->GetURI(getter_AddRefs(uri)); if (NS_SUCCEEDED(rv)) { char* str; @@ -142,10 +144,12 @@ public: return NS_OK; } - NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStopRequest(nsIRequest *request, 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; @@ -159,7 +163,7 @@ public: return NS_OK; } - NS_IMETHOD OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { nsresult rv; @@ -205,8 +209,7 @@ TestAsyncRead(const char* url) nsCOMPtr listener = new Listener(); if (listener == nsnull) return NS_ERROR_OUT_OF_MEMORY; - - rv = channel->AsyncRead(nsnull, listener); + rv = channel->AsyncOpen(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 c3d39e784c7..772bd351936 100644 --- a/mozilla/netwerk/test/TestSocketIO.cpp +++ b/mozilla/netwerk/test/TestSocketIO.cpp @@ -34,7 +34,8 @@ #include "nsISocketTransportService.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" -#include "nsIChannel.h" +#include "nsITransport.h" +#include "nsIRequest.h" #include "nsIStreamProvider.h" #include "nsIStreamListener.h" #include "nsIPipe.h" @@ -68,54 +69,53 @@ static nsIEventQueue* gEventQ = nsnull; class TestListener : public nsIStreamListener { public: + TestListener() { NS_INIT_ISUPPORTS(); } + virtual ~TestListener() {} - TestListener() { NS_INIT_ISUPPORTS(); } - virtual ~TestListener() {} - - NS_DECL_ISUPPORTS - NS_DECL_NSISTREAMOBSERVER - NS_DECL_NSISTREAMLISTENER + NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMLISTENER }; NS_IMPL_ISUPPORTS2(TestListener, - nsIStreamObserver, - nsIStreamListener); + nsIStreamObserver, + nsIStreamListener); NS_IMETHODIMP -TestListener::OnStartRequest(nsIChannel* channel, nsISupports* context) +TestListener::OnStartRequest(nsIRequest* request, nsISupports* context) { - LOG(("TestListener::OnStartRequest\n")); - return NS_OK; + LOG(("TestListener::OnStartRequest\n")); + return NS_OK; } NS_IMETHODIMP -TestListener::OnDataAvailable(nsIChannel* channel, - nsISupports* context, - nsIInputStream *aIStream, - PRUint32 aSourceOffset, - PRUint32 aLength) +TestListener::OnDataAvailable(nsIRequest* request, + 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(nsIChannel* channel, nsISupports* context, - nsresult aStatus, const PRUnichar* aStatusArg) +TestListener::OnStopRequest(nsIRequest* request, 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,16 +127,15 @@ TestListener::OnStopRequest(nsIChannel* channel, nsISupports* context, class TestProvider : public nsIStreamProvider { public: + TestProvider(char *data); + virtual ~TestProvider(); - TestProvider(char *data); - virtual ~TestProvider(); - - NS_DECL_ISUPPORTS - NS_DECL_NSISTREAMOBSERVER - NS_DECL_NSISTREAMPROVIDER + NS_DECL_ISUPPORTS + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSISTREAMPROVIDER protected: - nsCOMPtr mData; + nsCOMPtr mData; }; NS_IMPL_ISUPPORTS2(TestProvider, @@ -145,42 +144,48 @@ 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(nsIChannel* channel, nsISupports* context) +TestProvider::OnStartRequest(nsIRequest* request, 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(nsIChannel* channel, nsISupports* context, - nsresult aStatus, const PRUnichar* aStatusArg) +TestProvider::OnStopRequest(nsIRequest* request, nsISupports* context, + nsresult aStatus, const PRUnichar* aStatusArg) { LOG(("TestProvider::OnStopRequest [status=%x]\n", aStatus)); nsCOMPtr listener = do_QueryInterface(new TestListener()); - if (NS_SUCCEEDED(aStatus)) - channel->AsyncRead(listener, nsnull); - else - gKeepRunning = 0; + 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; - return NS_OK; + return NS_OK; } NS_IMETHODIMP -TestProvider::OnDataWritable(nsIChannel *channel, nsISupports *context, - nsIOutputStream *output, PRUint32 offset, PRUint32 count) +TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context, + nsIOutputStream *output, PRUint32 offset, PRUint32 count) { LOG(("TestProvider::OnDataWritable [offset=%u, count=%u]\n", offset, count)); PRUint32 writeCount; @@ -188,7 +193,7 @@ TestProvider::OnDataWritable(nsIChannel *channel, nsISupports *context, // Zero bytes written on success indicates EOF if (NS_SUCCEEDED(rv) && (writeCount == 0)) return NS_BASE_STREAM_CLOSED; - return rv; + return rv; } // @@ -199,6 +204,7 @@ TestProvider::OnDataWritable(nsIChannel *channel, nsISupports *context, nsresult WriteRequest(nsIOutputStream *os, const char *request) { + LOG(("WriteRequest [request=%s]\n", request)); PRUint32 n; return os->Write(request, strlen(request), &n); } @@ -239,7 +245,7 @@ usage(char **argv) int main(int argc, char* argv[]) { - nsresult rv; + nsresult rv; #ifdef XP_OS2_VACPP signal(SIGSEGV, (_SigFunc)sighandler); @@ -267,8 +273,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; @@ -280,10 +286,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; @@ -301,74 +307,85 @@ 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) { - rv = transport->AsyncWrite(new TestProvider(buffer), nsnull); + nsCOMPtr request; + rv = transport->AsyncWrite(new TestProvider(buffer), nsnull, 0, 0, 0, getter_AddRefs(request)); 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; + 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; #else -#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; + 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(getter_AddRefs(os)); - if (NS_FAILED(rv)) return rv; + rv = transport->OpenOutputStream(0, 0, 0, getter_AddRefs(os)); + if (NS_FAILED(rv)) { + LOG(("OpenOutputStream failed [rv=%x]\n", rv)); + return rv; + } rv = WriteRequest(os, buffer); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) { + LOG(("WriteRequest failed [rv=%x]\n", rv)); + return rv; + } } // synchronous read { nsCOMPtr is; - rv = transport->OpenInputStream(getter_AddRefs(is)); - if (NS_FAILED(rv)) return rv; + rv = transport->OpenInputStream(0, 0, 0, getter_AddRefs(is)); + if (NS_FAILED(rv)) { + LOG(("OpenInputStream failed [rv=%x]\n", rv)); + return rv; + } rv = ReadResponse(is); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) { + LOG(("ReadResponse failed [rv=%x]\n", 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 e79e28f9946..a08e1117975 100644 --- a/mozilla/netwerk/test/TestSocketInput.cpp +++ b/mozilla/netwerk/test/TestSocketInput.cpp @@ -33,7 +33,8 @@ #include "nsISocketTransportService.h" #include "nsIEventQueueService.h" #include "nsIServiceManager.h" -#include "nsIChannel.h" +#include "nsITransport.h" +#include "nsIRequest.h" #include "nsIStreamListener.h" #include "nsIInputStream.h" @@ -53,14 +54,14 @@ public: NS_DECL_ISUPPORTS // IStreamListener interface... - NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports* context); + NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports* context); - NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports* context, + NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength); - NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports* context, + NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg); }; @@ -81,7 +82,7 @@ NS_IMPL_ISUPPORTS(InputTestConsumer,kIStreamListenerIID); NS_IMETHODIMP -InputTestConsumer::OnStartRequest(nsIChannel* channel, nsISupports* context) +InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context) { printf("+++ OnStartRequest +++\n"); return NS_OK; @@ -89,7 +90,7 @@ InputTestConsumer::OnStartRequest(nsIChannel* channel, nsISupports* context) NS_IMETHODIMP -InputTestConsumer::OnDataAvailable(nsIChannel* channel, +InputTestConsumer::OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, @@ -110,7 +111,7 @@ InputTestConsumer::OnDataAvailable(nsIChannel* channel, NS_IMETHODIMP -InputTestConsumer::OnStopRequest(nsIChannel* channel, nsISupports* context, +InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { gKeepRunning = 0; @@ -159,11 +160,12 @@ main(int argc, char* argv[]) NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsIChannel* transport; + nsITransport* transport; rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, &transport); if (NS_SUCCEEDED(rv)) { - transport->AsyncRead(nsnull, new InputTestConsumer); + nsCOMPtr request; + transport->AsyncRead(nsnull, new InputTestConsumer, 0, -1, 0, getter_AddRefs(request)); NS_RELEASE(transport); } diff --git a/mozilla/netwerk/test/TestSocketTransport.cpp b/mozilla/netwerk/test/TestSocketTransport.cpp index 8b0ed4d7e98..f49293fd66e 100644 --- a/mozilla/netwerk/test/TestSocketTransport.cpp +++ b/mozilla/netwerk/test/TestSocketTransport.cpp @@ -34,10 +34,11 @@ #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" @@ -148,13 +149,13 @@ public: return NS_NOINTERFACE; } - NS_IMETHOD OnProgress(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnProgress(nsIRequest *request, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { putc('+', stderr); return NS_OK; } - NS_IMETHOD OnStatus(nsIChannel *channel, nsISupports *ctxt, + NS_IMETHOD OnStatus(nsIRequest *request, nsISupports *ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { putc('?', stderr); return NS_OK; @@ -167,7 +168,9 @@ protected: nsIInputStream* mInStream; nsIOutputStream* mOutStream; - nsIChannel* mTransport; + nsITransport* mTransport; + nsCOMPtr mReadRequest; + nsCOMPtr mWriteRequest; PRBool mIsAsync; PRInt32 mBufferLength; @@ -199,38 +202,38 @@ protected: NS_IMPL_ISUPPORTS1(TestConnectionOpenObserver, nsIStreamObserver); NS_IMETHODIMP -TestConnectionOpenObserver::OnStartRequest(nsIChannel* channel, nsISupports* context) +TestConnectionOpenObserver::OnStartRequest(nsIRequest *request, nsISupports* context) { if (gVerbose) - printf("\n+++ TestConnectionOpenObserver::OnStartRequest +++. Context = %p\n", context); + printf("\n+++ TestConnectionOpenObserver::OnStartRequest +++. Context = %p\n", (void*)context); return NS_OK; } NS_IMETHODIMP -TestConnectionOpenObserver::OnStopRequest(nsIChannel* channel, nsISupports* context, +TestConnectionOpenObserver::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { if (gVerbose || NS_FAILED(aStatus)) printf("\n+++ TestConnectionOpenObserver::OnStopRequest (status = %x) +++." "\tContext = %p\n", - aStatus, context); + aStatus, (void*)context); return NS_OK; } //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -TestConnection::OnStartRequest(nsIChannel* channel, nsISupports* context) +TestConnection::OnStartRequest(nsIRequest *request, nsISupports* context) { if (gVerbose) - printf("\n+++ TestConnection::OnStartRequest +++. Context = %p\n", context); + printf("\n+++ TestConnection::OnStartRequest +++. Context = %p\n", (void*)context); return NS_OK; } NS_IMETHODIMP -TestConnection::OnDataAvailable(nsIChannel* channel, nsISupports* context, +TestConnection::OnDataAvailable(nsIRequest *request, nsISupports* context, nsIInputStream *aIStream, PRUint32 aSourceOffset, PRUint32 aLength) @@ -243,7 +246,7 @@ TestConnection::OnDataAvailable(nsIChannel* channel, nsISupports* context, if (gVerbose) printf("\n+++ TestConnection::OnDavaAvailable +++." "\tContext = %p length = %d\n", - context, aLength); + (void*)context, aLength); while (aLength > 0) { PRInt32 cnt = PR_MIN(TRANSFER_AMOUNT, aLength); @@ -266,13 +269,13 @@ TestConnection::OnDataAvailable(nsIChannel* channel, nsISupports* context, NS_IMETHODIMP -TestConnection::OnStopRequest(nsIChannel* channel, nsISupports* context, +TestConnection::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult aStatus, const PRUnichar* aStatusArg) { if (gVerbose || NS_FAILED(aStatus)) printf("\n+++ TestConnection::OnStopRequest (status = %x) +++." "\tContext = %p\n", - aStatus, context); + aStatus, (void*)context); return NS_OK; } @@ -304,7 +307,8 @@ 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. - rv = mTransport->SetNotificationCallbacks(this); + nsCOMPtr sink = do_GetInterface((nsIInterfaceRequestor*)this); + rv = mTransport->SetProgressEventSink(sink); } } @@ -318,8 +322,8 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort, } // Synchronous transport... else { - rv = mTransport->OpenInputStream(&mInStream); - rv = mTransport->OpenOutputStream(&mOutStream); + rv = mTransport->OpenInputStream(0, -1, 0, &mInStream); + rv = mTransport->OpenOutputStream(0, -1, 0, &mOutStream); } } } @@ -369,7 +373,7 @@ TestConnection::Run(void) // // Initiate an async read... // - rv = mTransport->AsyncRead(this, mTransport); + rv = mTransport->AsyncRead(this, mTransport, 0, -1, 0, getter_AddRefs(mReadRequest)); if (NS_FAILED(rv)) { printf("Error: AsyncRead failed..."); @@ -409,7 +413,7 @@ nsresult TestConnection::WriteBuffer(void) } if (gVerbose) - printf("\n+++ Request is: %c. Context = %p\n", mBufferChar, mTransport); + printf("\n+++ Request is: %c. Context = %p\n", mBufferChar, (void*)mTransport); // Create and fill a test buffer of data... buffer = (char*)PR_Malloc(mBufferLength + 4); @@ -430,10 +434,10 @@ nsresult TestConnection::WriteBuffer(void) // Write the buffer to the server... if (NS_SUCCEEDED(rv)) { - rv = mTransport->SetTransferCount(bytesWritten); - if (NS_SUCCEEDED(rv)) { - rv = NS_AsyncWriteFromStream(mTransport, mStream, nsnull, mTransport); - } + rv = NS_AsyncWriteFromStream( + getter_AddRefs(mWriteRequest), + mTransport, mStream, 0, bytesWritten, 0, + nsnull, mTransport); } // Wait for the write to complete... if (NS_FAILED(rv)) { @@ -495,8 +499,8 @@ nsresult TestConnection::Suspend(void) { nsresult rv; - if (mTransport) { - rv = mTransport->Suspend(); + if (mReadRequest) { + rv = mReadRequest->Suspend(); } else { rv = NS_ERROR_FAILURE; } @@ -508,8 +512,8 @@ nsresult TestConnection::Resume(void) { nsresult rv; - if (mTransport) { - rv = mTransport->Resume(); + if (mReadRequest) { + rv = mReadRequest->Resume(); } else { rv = NS_ERROR_FAILURE; } diff --git a/mozilla/netwerk/test/TestSyncHTTP.cpp b/mozilla/netwerk/test/TestSyncHTTP.cpp index f2b39ad50bd..74479e02526 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", this); } + { printf("TestContext [this=%p]\n", (void*)this); } ~TestContext() - { printf("~TestContext [this=%p]\n", this); } + { printf("~TestContext [this=%p]\n", (void*)this); } }; int @@ -78,7 +78,7 @@ main(int argc, char **argv) nsCOMPtr httpChannel = do_QueryInterface(c[i].channel); if (httpChannel) - httpChannel->SetOpenInputStreamHasEventQueue(PR_FALSE); + httpChannel->SetOpenHasEventQueue(PR_FALSE); // initialize these fields for reading c[i].bytesRead = 1; @@ -88,7 +88,7 @@ main(int argc, char **argv) for (i=0; iOpenInputStream(getter_AddRefs(c[i].inputStream)); + rv = c[i].channel->Open(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 4b57b0b0a70..50234197a3e 100644 --- a/mozilla/netwerk/test/TestWriteStream.cpp +++ b/mozilla/netwerk/test/TestWriteStream.cpp @@ -22,6 +22,7 @@ #include "nsIFileTransportService.h" #include "nsIChannel.h" +#include "nsITransport.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsCOMPtr.h" @@ -115,14 +116,12 @@ 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->SetTransferOffset(startPosition); - if (NS_FAILED(rv)) return rv; - rv = transport->OpenOutputStream(getter_AddRefs(outStream)) ; + rv = transport->OpenOutputStream(startPosition, -1, 0, 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 41be60fa94d..b425214c371 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, - nsIChannel* channel, + nsIRequest *request, nsresult aStatus) { fputs("done.\n",stdout); @@ -162,14 +162,14 @@ CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel) + nsIRequest *request) { return NS_OK; } NS_IMETHODIMP CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -178,7 +178,7 @@ CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, nsString& aMsg) { return NS_OK; @@ -186,7 +186,7 @@ CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP CStreamListener::OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest *request, nsresult aStatus) { return NS_OK; diff --git a/mozilla/parser/htmlparser/src/CParserContext.cpp b/mozilla/parser/htmlparser/src/CParserContext.cpp index c3bbaaacf78..4bafaaf0a63 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; - mChannel=0; + mRequest=0; mValidator=0; } @@ -92,7 +92,7 @@ CParserContext::CParserContext(const CParserContext &aContext) : mMimeType() { mStreamListenerState=aContext.mStreamListenerState; mMultipart=aContext.mMultipart; mContextType=aContext.mContextType; - mChannel=aContext.mChannel; + mRequest=aContext.mRequest; mParserCommand=aContext.mParserCommand; SetMimeType(aContext.mMimeType); } diff --git a/mozilla/parser/htmlparser/src/CParserContext.h b/mozilla/parser/htmlparser/src/CParserContext.h index 9e282589875..e9ac2471984 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... - nsIChannel* mChannel; // provided by necko to differnciate different input streams + nsIRequest* mRequest; // 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 995604f35a2..bdcf8d22e93 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(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) +nsParser::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult result=0; if (nsnull != mProgressEventSink) { - mProgressEventSink->OnProgress(channel, aContext, aProgress, aProgressMax); + mProgressEventSink->OnProgress(request, aContext, aProgress, aProgressMax); } return result; } @@ -2079,12 +2079,12 @@ nsParser::OnProgress(nsIChannel* channel, nsISupports* aContext, PRUint32 aProgr * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, +nsParser::OnStatus(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aStatusArg) { nsresult rv; if (nsnull != mProgressEventSink) { - rv = mProgressEventSink->OnStatus(channel, aContext, aStatus, aStatusArg); + rv = mProgressEventSink->OnStatus(request, aContext, aStatus, aStatusArg); NS_ASSERTION(NS_SUCCEEDED(rv), "dropping error result"); } return NS_OK; @@ -2102,19 +2102,22 @@ nsParser::OnStatus(nsIChannel* channel, nsISupports* aContext, * @param * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { +nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { NS_PRECONDITION((eNone==mParserContext->mStreamListenerState),kBadListenerInit); if (nsnull != mObserver) { - mObserver->OnStartRequest(channel, aContext); + mObserver->OnStartRequest(request, aContext); } mParserContext->mStreamListenerState=eOnStart; mParserContext->mAutoDetectStatus=eUnknownDetect; - mParserContext->mChannel=channel; + mParserContext->mRequest=request; 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)) { @@ -2310,7 +2313,7 @@ ParserWriteFunc(nsIInputStream* in, * @return error code (usually 0) */ -nsresult nsParser::OnDataAvailable(nsIChannel* channel, nsISupports* aContext, +nsresult nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext, nsIInputStream *pIStream, PRUint32 sourceOffset, PRUint32 aLength) { @@ -2322,12 +2325,12 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail CParserContext *theContext=mParserContext; while(theContext) { - if(theContext->mChannel!=channel && theContext->mPrevContext) + if(theContext->mRequest!=request && theContext->mPrevContext) theContext=theContext->mPrevContext; else break; } - if(theContext && theContext->mChannel==channel) { + if(theContext && theContext->mRequest==request) { theContext->mStreamListenerState=eOnDataAvail; @@ -2366,7 +2369,7 @@ NS_PRECONDITION(((eOnStart==mParserContext->mStreamListenerState)||(eOnDataAvail * @param * @return */ -nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, +nsresult nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult status, const PRUnichar* aMsg) { @@ -2398,7 +2401,7 @@ nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, // XXX Should we wait to notify our observers as well if the // parser isn't yet enabled? if (nsnull != mObserver) { - mObserver->OnStopRequest(channel, aContext, status, aMsg); + mObserver->OnStopRequest(request, aContext, status, aMsg); } #ifdef rickgdebug diff --git a/mozilla/parser/htmlparser/src/nsScanner.h b/mozilla/parser/htmlparser/src/nsScanner.h index 0ef5a3d451f..2dfbd16de95 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.h +++ b/mozilla/parser/htmlparser/src/nsScanner.h @@ -48,6 +48,7 @@ class nsScannerString : public nsSlidingString { nsScannerString(PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd); + virtual void UngetReadable(const nsAReadableString& aReadable, const nsReadingIterator& aCurrentPosition) { InsertReadable(aReadable,aCurrentPosition); } virtual void ReplaceCharacter(nsReadingIterator& aPosition, PRUnichar aChar); diff --git a/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp b/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp index 4b42cfac0d7..07a224ece41 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->AsyncRead(copier, nsnull); + rv = channel->AsyncOpen(copier, nsnull); if (NS_OK != rv) { NS_RELEASE(copier); diff --git a/mozilla/profile/Acct/nsAccount.cpp b/mozilla/profile/Acct/nsAccount.cpp index 0973d86f23a..8fa2e895586 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->OpenInputStream(&in); + ret = channel->Open(&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->OpenInputStream(&in); + ret = channel->Open(&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 ce5e96a9c81..6ceb165c92c 100644 --- a/mozilla/rdf/base/src/nsRDFContentSink.cpp +++ b/mozilla/rdf/base/src/nsRDFContentSink.cpp @@ -927,7 +927,8 @@ RDFContentSinkImpl::GetNameSpaceURI(nsIAtom* aPrefix, const char** aNameSpaceURI #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) { nsAutoString prefixStr; - aPrefix->ToString(prefixStr); + if (aPrefix) + aPrefix->ToString(prefixStr); char* prefixCStr = prefixStr.ToNewCString(); diff --git a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp index 3a4f5409bee..a289715fc85 100644 --- a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp +++ b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp @@ -609,15 +609,16 @@ RDFXMLDataSourceImpl::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; + // Null LoadGroup ? rv = NS_OpenURI(getter_AddRefs(channel), aURL, nsnull); if (NS_FAILED(rv)) return rv; - nsIInputStream* in; PRUint32 sourceOffset = 0; - rv = channel->OpenInputStream(&in); + rv = channel->Open(&in); // If we couldn't open the channel, then just return. if (NS_FAILED(rv)) return NS_OK; @@ -639,7 +640,9 @@ RDFXMLDataSourceImpl::BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer) obs->OnBeginLoad(this); } - aConsumer->OnStartRequest(channel, nsnull); + request = do_QueryInterface(channel); + + aConsumer->OnStartRequest(request, nsnull); while (PR_TRUE) { char buf[1024]; PRUint32 readCount; @@ -652,7 +655,7 @@ RDFXMLDataSourceImpl::BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer) proxy->SetBuffer(buf, readCount); - rv = aConsumer->OnDataAvailable(channel, nsnull, proxy, sourceOffset, readCount); + rv = aConsumer->OnDataAvailable(request, nsnull, proxy, sourceOffset, readCount); sourceOffset += readCount; if (NS_FAILED(rv)) break; @@ -1122,13 +1125,13 @@ RDFXMLDataSourceImpl::RemoveXMLSinkObserver(nsIRDFXMLSinkObserver* aObserver) // NS_IMETHODIMP -RDFXMLDataSourceImpl::OnStartRequest(nsIChannel *channel, nsISupports *ctxt) +RDFXMLDataSourceImpl::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { - return mParser->OnStartRequest(channel, ctxt); + return mParser->OnStartRequest(request, ctxt); } NS_IMETHODIMP -RDFXMLDataSourceImpl::OnStopRequest(nsIChannel *channel, +RDFXMLDataSourceImpl::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) @@ -1143,7 +1146,7 @@ RDFXMLDataSourceImpl::OnStopRequest(nsIChannel *channel, } nsresult rv; - rv = mParser->OnStopRequest(channel, ctxt, status, errorMsg); + rv = mParser->OnStopRequest(request, ctxt, status, errorMsg); mParser = nsnull; // release the parser @@ -1156,13 +1159,13 @@ RDFXMLDataSourceImpl::OnStopRequest(nsIChannel *channel, // NS_IMETHODIMP -RDFXMLDataSourceImpl::OnDataAvailable(nsIChannel *channel, +RDFXMLDataSourceImpl::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count) { - return mParser->OnDataAvailable(channel, ctxt, inStr, sourceOffset, count); + return mParser->OnDataAvailable(request, ctxt, inStr, sourceOffset, count); } //---------------------------------------------------------------------- diff --git a/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp b/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp index 392fb916814..9d3566b0c6d 100644 --- a/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp +++ b/mozilla/rdf/chrome/src/nsChromeProtocolHandler.cpp @@ -116,27 +116,25 @@ public: NS_DECL_ISUPPORTS // nsIRequest - NS_IMETHOD GetName(PRUnichar* *result) { - NS_NOTREACHED("nsCachedChromeChannel::GetName"); - return NS_ERROR_NOT_IMPLEMENTED; - } + NS_IMETHOD GetName(PRUnichar* *result) { 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 + +// nsIChannel NS_DECL_NSICHANNEL + }; #ifdef PR_LOGGING PRLogModuleInfo* nsCachedChromeChannel::gLog; #endif -NS_IMPL_ADDREF(nsCachedChromeChannel); -NS_IMPL_RELEASE(nsCachedChromeChannel); -NS_IMPL_QUERY_INTERFACE2(nsCachedChromeChannel, nsIRequest, nsIChannel); +NS_IMPL_ISUPPORTS2(nsCachedChromeChannel, + nsIChannel, + nsIRequest); nsresult nsCachedChromeChannel::Create(nsIURI* aURI, nsIChannel** aResult) @@ -211,7 +209,7 @@ nsCachedChromeChannel::SetURI(nsIURI* aURI) } NS_IMETHODIMP -nsCachedChromeChannel::OpenInputStream(nsIInputStream **_retval) +nsCachedChromeChannel::Open(nsIInputStream **_retval) { // NS_NOTREACHED("don't do that"); *_retval = nsnull; @@ -219,15 +217,7 @@ nsCachedChromeChannel::OpenInputStream(nsIInputStream **_retval) } NS_IMETHODIMP -nsCachedChromeChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("don't do that"); - *_retval = nsnull; - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { if (listener) { nsresult rv; @@ -237,7 +227,7 @@ nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: adding self to load group %p", this, mLoadGroup.get())); - rv = mLoadGroup->AddChannel(this, nsnull); + rv = mLoadGroup->AddRequest(this, nsnull); if (NS_FAILED(rv)) return rv; } @@ -257,7 +247,7 @@ nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) ("nsCachedChromeChannel[%p]: removing self from load group %p", this, mLoadGroup.get())); - (void) mLoadGroup->RemoveChannel(this, nsnull, nsnull, nsnull); + (void) mLoadGroup->RemoveRequest(this, nsnull, nsnull, nsnull); } return rv; @@ -271,10 +261,9 @@ nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) } NS_IMETHODIMP -nsCachedChromeChannel::AsyncWrite(nsIStreamProvider *provider, nsISupports *ctxt) +nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) { - NS_NOTREACHED("don't do that"); - return NS_ERROR_FAILURE; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -291,113 +280,6 @@ 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) { @@ -441,12 +323,34 @@ nsCachedChromeChannel::SetNotificationCallbacks(nsIInterfaceRequestor * aNotific return NS_OK; // ignored } - NS_IMETHODIMP -nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +nsCachedChromeChannel::GetContentType(char * *aContentType) { - *aSecurityInfo = nsnull; - return NS_OK; + *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; } nsresult @@ -523,12 +427,14 @@ 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(channel, channel->mContext, + (void) channel->mListener->OnStopRequest(request, channel->mContext, channel->mStatus, nsnull); if (channel->mLoadGroup) { @@ -536,7 +442,7 @@ nsCachedChromeChannel::HandleStopLoadEvent(PLEvent* aEvent) ("nsCachedChromeChannel[%p]: removing self from load group %p", channel, channel->mLoadGroup.get())); - (void) channel->mLoadGroup->RemoveChannel(channel, nsnull, nsnull, nsnull); + (void) channel->mLoadGroup->RemoveRequest(request, nsnull, nsnull, nsnull); } channel->mListener = nsnull; diff --git a/mozilla/rdf/content/src/Makefile.in b/mozilla/rdf/content/src/Makefile.in index cc53f852828..8ca70f52335 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 +REQUIRES = xpcom layout widget dom js caps locale necko timer lwbrk htmlparser xpconnect uriloader view pref docshell chrome exthandler mime CPPSRCS = \ nsElementMap.cpp \ diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 197914cc9d5..78dc8928966 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -128,6 +128,10 @@ #include "nsIDOMDocumentType.h" #include "nsIXBLService.h" #include "nsReadableUtils.h" +#include "nsCExternalHandlerService.h" +#include "nsIMIMEService.h" +#include "nsNetUtil.h" +#include "nsMimeTypes.h" //---------------------------------------------------------------------- @@ -314,19 +318,19 @@ NS_IMPL_ISUPPORTS1(nsProxyLoadStream, nsIInputStream); //---------------------------------------------------------------------- // -// PlaceholderChannel +// PlaceholderRequest // -// This is a dummy channel implementation that we add to the load +// This is a dummy request 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 PlaceholderChannel : public nsIChannel +class PlaceHolderRequest : public nsIChannel { protected: - PlaceholderChannel(); - virtual ~PlaceholderChannel(); + PlaceHolderRequest(); + virtual ~PlaceHolderRequest(); static PRInt32 gRefCnt; static nsIURI* gURI; @@ -335,13 +339,12 @@ protected: public: static nsresult - Create(nsIChannel** aResult); + Create(nsIRequest** 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; } @@ -350,63 +353,50 @@ 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 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;} + 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; } + }; -PRInt32 PlaceholderChannel::gRefCnt; -nsIURI* PlaceholderChannel::gURI; +PRInt32 PlaceHolderRequest::gRefCnt; +nsIURI* PlaceHolderRequest::gURI; -NS_IMPL_ADDREF(PlaceholderChannel); -NS_IMPL_RELEASE(PlaceholderChannel); -NS_IMPL_QUERY_INTERFACE2(PlaceholderChannel, nsIRequest, nsIChannel); +NS_IMPL_ADDREF(PlaceHolderRequest); +NS_IMPL_RELEASE(PlaceHolderRequest); +NS_IMPL_QUERY_INTERFACE2(PlaceHolderRequest, nsIRequest, nsIChannel); nsresult -PlaceholderChannel::Create(nsIChannel** aResult) +PlaceHolderRequest::Create(nsIRequest** aResult) { - PlaceholderChannel* channel = new PlaceholderChannel(); - if (! channel) + PlaceHolderRequest* request = new PlaceHolderRequest(); + if (! request) return NS_ERROR_OUT_OF_MEMORY; - *aResult = channel; + *aResult = request; NS_ADDREF(*aResult); return NS_OK; } -PlaceholderChannel::PlaceholderChannel() +PlaceHolderRequest::PlaceHolderRequest() { NS_INIT_REFCNT(); @@ -418,7 +408,7 @@ PlaceholderChannel::PlaceholderChannel() } -PlaceholderChannel::~PlaceholderChannel() +PlaceHolderRequest::~PlaceHolderRequest() { if (--gRefCnt == 0) { NS_IF_RELEASE(gURI); @@ -774,8 +764,9 @@ 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; - (void) aChannel->GetContentType(getter_Copies(contentType)); + 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 @@ -4964,16 +4955,16 @@ nsXULDocument::PrepareToWalk() // Add a dummy channel to the load group as a placeholder for the document // load - rv = PlaceholderChannel::Create(getter_AddRefs(mPlaceholderChannel)); + rv = PlaceHolderRequest::Create(getter_AddRefs(mPlaceHolderRequest)); if (NS_FAILED(rv)) return rv; nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); if (group) { - rv = mPlaceholderChannel->SetLoadGroup(group); + nsCOMPtr channel = do_QueryInterface(mPlaceHolderRequest); + rv = channel->SetLoadGroup(group); if (NS_FAILED(rv)) return rv; - - rv = group->AddChannel(mPlaceholderChannel, nsnull); + rv = group->AddRequest(mPlaceHolderRequest, nsnull); if (NS_FAILED(rv)) return rv; } } @@ -5308,10 +5299,10 @@ nsXULDocument::ResumeWalk() // docshell, and run the onload handlers, etc. nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); if (group) { - rv = group->RemoveChannel(mPlaceholderChannel, nsnull, NS_OK, nsnull); + rv = group->RemoveRequest(mPlaceHolderRequest, nsnull, NS_OK, nsnull); if (NS_FAILED(rv)) return rv; - mPlaceholderChannel = nsnull; + mPlaceHolderRequest = nsnull; } return rv; } @@ -5373,8 +5364,11 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader, { if (aLoader) { + nsCOMPtr request; nsCOMPtr channel; - aLoader->GetChannel(getter_AddRefs(channel)); + aLoader->GetRequest(getter_AddRefs(request)); + if (request) + channel = do_QueryInterface(request); if (channel) { nsCOMPtr uri; @@ -6534,14 +6528,14 @@ nsXULDocument::CachedChromeStreamListener::~CachedChromeStreamListener() NS_IMPL_ISUPPORTS2(nsXULDocument::CachedChromeStreamListener, nsIStreamObserver, nsIStreamListener); NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIChannel* aChannel, nsISupports* acontext) +nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIRequest *request, nsISupports* acontext) { return NS_OK; } NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIChannel* aChannel, +nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -6556,7 +6550,7 @@ nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIChannel* aChannel, NS_IMETHODIMP -nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIChannel* aChannel, +nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIRequest *request, nsISupports* aContext, nsIInputStream* aInStr, PRUint32 aSourceOffset, @@ -6586,14 +6580,14 @@ nsXULDocument::ParserObserver::~ParserObserver() NS_IMPL_ISUPPORTS1(nsXULDocument::ParserObserver, nsIStreamObserver); NS_IMETHODIMP -nsXULDocument::ParserObserver::OnStartRequest(nsIChannel* aChannel, +nsXULDocument::ParserObserver::OnStartRequest(nsIRequest *request, nsISupports* aContext) { return NS_OK; } NS_IMETHODIMP -nsXULDocument::ParserObserver::OnStopRequest(nsIChannel* aChannel, +nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -6605,6 +6599,10 @@ nsXULDocument::ParserObserver::OnStopRequest(nsIChannel* aChannel, // 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 0b0f120fe65..d18dbca9491 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* aChannel, + nsIChannel *channel, nsILoadGroup* aLoadGroup, nsISupports* aContainer, nsIStreamListener **aDocListener, @@ -644,7 +644,7 @@ protected: * A "dummy" channel that is used as a placeholder to signal document load * completion. */ - nsCOMPtr mPlaceholderChannel; + nsCOMPtr mPlaceHolderRequest; /** * Create a XUL template builder on the specified node if a 'datasources' diff --git a/mozilla/themes/classic/README b/mozilla/themes/classic/README index 77439387aab..9f5a75a341d 100644 --- a/mozilla/themes/classic/README +++ b/mozilla/themes/classic/README @@ -17,4 +17,3 @@ Please conform to the indentation style standard set by the Windows version of t This skin uses System Colours in the Windows version, and is slowly picking up System Colour usage in the Macintosh version as support is implemented. Please don't check in hard coded colour values into the Windows version or the Macintosh version where an appropriate System Colour exists. Send comments and questions to - diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 223b4062983..671bf44a50a 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -64,15 +64,17 @@ PRLogModuleInfo* gDocLoaderLog = nsnull; #if defined(DEBUG) -void GetURIStringFromChannel(nsIRequest *aRequest, nsXPIDLCString &aStr) +void GetURIStringFromRequest(nsIRequest* request, nsXPIDLCString &aStr) { - nsCOMPtr channel; - nsCOMPtr uri; - nsresult rv = NS_OK; + nsCOMPtr channel = do_QueryInterface(request); - channel = do_QueryInterface(aRequest, &rv); - if (NS_SUCCEEDED(rv)) - rv = channel->GetURI(getter_AddRefs(uri)); + if (!channel) { + aStr = "???"; + return; + } + + nsCOMPtr uri; + nsresult rv = channel->GetURI(getter_AddRefs(uri)); if (NS_SUCCEEDED(rv) && uri) rv = uri->GetSpec(getter_Copies(aStr)); @@ -439,7 +441,7 @@ nsDocLoaderImpl::Destroy() ClearChannelInfoList(); - mDocumentChannel = null_nsCOMPtr(); + mDocumentRequest = 0; mLoadGroup->SetGroupObserver(nsnull); @@ -447,14 +449,15 @@ nsDocLoaderImpl::Destroy() } NS_IMETHODIMP -nsDocLoaderImpl::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) +nsDocLoaderImpl::OnStartRequest(nsIRequest *request, 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; @@ -480,37 +483,39 @@ nsDocLoaderImpl::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt) if (1 == count) { // This channel is associated with the entire document... - mDocumentChannel = aChannel; - mLoadGroup->SetDefaultLoadChannel(mDocumentChannel); + mDocumentRequest = do_QueryInterface(request); + mLoadGroup->SetDefaultLoadRequest(mDocumentRequest); // Update the progress status state mProgressStateFlags = nsIWebProgressListener::STATE_START; doStartDocumentLoad(); - FireOnStartDocumentLoad(this, aChannel); + FireOnStartDocumentLoad(this, request); } else { - doStartURLLoad(aChannel); - FireOnStartURLLoad(this, aChannel); + doStartURLLoad(request); + FireOnStartURLLoad(this, request); } } else { ClearChannelInfoList(); - doStartURLLoad(aChannel); - FireOnStartURLLoad(this, aChannel); + doStartURLLoad(request); + FireOnStartURLLoad(this, request); } return NS_OK; } NS_IMETHODIMP -nsDocLoaderImpl::OnStopRequest(nsIChannel *aChannel, +nsDocLoaderImpl::OnStopRequest(nsIRequest *request, 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... @@ -543,8 +548,8 @@ nsDocLoaderImpl::OnStopRequest(nsIChannel *aChannel, // // Fire the OnStateChange(...) notification for stop request // - doStopURLLoad(aChannel, aStatus); - FireOnEndURLLoad(this, aChannel, aStatus); + doStopURLLoad(request, aStatus); + FireOnEndURLLoad(this, request, aStatus); rv = mLoadGroup->GetActiveCount(&count); if (NS_FAILED(rv)) return rv; @@ -557,8 +562,8 @@ nsDocLoaderImpl::OnStopRequest(nsIChannel *aChannel, } } else { - doStopURLLoad(aChannel, aStatus); - FireOnEndURLLoad(this, aChannel, aStatus); + doStopURLLoad(request, aStatus); + FireOnEndURLLoad(this, request, aStatus); } return NS_OK; @@ -577,7 +582,9 @@ nsresult nsDocLoaderImpl::RemoveChildGroup(nsDocLoaderImpl* aLoader) NS_IMETHODIMP nsDocLoaderImpl::GetDocumentChannel(nsIChannel ** aChannel) { - *aChannel = mDocumentChannel; + nsCOMPtr ourChannel = do_QueryInterface(mDocumentRequest); + + *aChannel = ourChannel.get(); NS_IF_ADDREF(*aChannel); return NS_OK; } @@ -598,9 +605,9 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus) PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: Is now idle...\n", this)); - nsCOMPtr docChannel(mDocumentChannel); + nsCOMPtr docRequest = mDocumentRequest; - mDocumentChannel = null_nsCOMPtr(); + mDocumentRequest = null_nsCOMPtr(); mIsLoadingDocument = PR_FALSE; // Update the progress status state - the document is done @@ -614,15 +621,15 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus) // New code to break the circular reference between // the load group and the docloader... // - mLoadGroup->SetDefaultLoadChannel(nsnull); + mLoadGroup->SetDefaultLoadRequest(nsnull); // // Do nothing after firing the OnEndDocumentLoad(...). The document // loader may be loading a *new* document - if LoadDocument() // was called from a handler! // - doStopDocumentLoad(docChannel, loadGroupStatus); - FireOnEndDocumentLoad(this, docChannel, loadGroupStatus); + doStopDocumentLoad(docRequest, loadGroupStatus); + FireOnEndDocumentLoad(this, docRequest, loadGroupStatus); if (mParent) { mParent->DocLoaderIsEmpty(loadGroupStatus); @@ -637,7 +644,7 @@ void nsDocLoaderImpl::doStartDocumentLoad(void) #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(mDocumentChannel, buffer); + GetURIStringFromRequest(mDocumentRequest, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange for start document load (...)." "\tURI: %s \n", @@ -645,10 +652,10 @@ void nsDocLoaderImpl::doStartDocumentLoad(void) #endif /* DEBUG */ // Fire an OnStatus(...) notification STATE_START. This indicates - // that the document represented by mDocumentChannel has started to + // that the document represented by mDocumentRequest has started to // load... FireOnStateChange(this, - mDocumentChannel, + mDocumentRequest, nsIWebProgressListener::STATE_START | nsIWebProgressListener::STATE_IS_DOCUMENT | nsIWebProgressListener::STATE_IS_REQUEST | @@ -656,12 +663,12 @@ void nsDocLoaderImpl::doStartDocumentLoad(void) NS_OK); } -void nsDocLoaderImpl::doStartURLLoad(nsIChannel *aChannel) +void nsDocLoaderImpl::doStartURLLoad(nsIRequest *request) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(request, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange start url load (...)." "\tURI: %s\n", @@ -669,18 +676,18 @@ void nsDocLoaderImpl::doStartURLLoad(nsIChannel *aChannel) #endif /* DEBUG */ FireOnStateChange(this, - aChannel, + request, nsIWebProgressListener::STATE_START | nsIWebProgressListener::STATE_IS_REQUEST, NS_OK); } -void nsDocLoaderImpl::doStopURLLoad(nsIChannel *aChannel, nsresult aStatus) +void nsDocLoaderImpl::doStopURLLoad(nsIRequest *request, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(request, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange for end url load (...)." "\tURI: %s status=%x\n", @@ -688,19 +695,19 @@ void nsDocLoaderImpl::doStopURLLoad(nsIChannel *aChannel, nsresult aStatus) #endif /* DEBUG */ FireOnStateChange(this, - aChannel, + request, nsIWebProgressListener::STATE_STOP | nsIWebProgressListener::STATE_IS_REQUEST, aStatus); } -void nsDocLoaderImpl::doStopDocumentLoad(nsIChannel* aChannel, +void nsDocLoaderImpl::doStopDocumentLoad(nsIRequest *request, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(request, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStateChange for end document load (...)." "\tURI: %s Status=%x\n", @@ -712,7 +719,7 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIChannel* aChannel, // current document has finished loading... // FireOnStateChange(this, - aChannel, + request, nsIWebProgressListener::STATE_STOP | nsIWebProgressListener::STATE_IS_DOCUMENT, aStatus); @@ -722,7 +729,7 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIChannel* aChannel, // current document has finished loading... // FireOnStateChange(this, - aChannel, + request, nsIWebProgressListener::STATE_STOP | nsIWebProgressListener::STATE_IS_WINDOW | nsIWebProgressListener::STATE_IS_NETWORK, @@ -733,18 +740,19 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIChannel* aChannel, void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel *aDocChannel) + nsIRequest *aDocRequest) { PRInt32 count; nsCOMPtr uri; + nsCOMPtr aChannel = do_QueryInterface(aDocRequest); - aDocChannel->GetURI(getter_AddRefs(uri)); + aChannel->GetURI(getter_AddRefs(uri)); #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aDocChannel, buffer); + GetURIStringFromRequest(aDocRequest, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStartDocumentLoad(...).\tURI: %s\n", @@ -781,19 +789,19 @@ void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, * Finally notify the parent... */ if (mParent) { - mParent->FireOnStartDocumentLoad(aLoadInitiator, aDocChannel); + mParent->FireOnStartDocumentLoad(aLoadInitiator, aDocRequest); } } void nsDocLoaderImpl::FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel *aDocChannel, + nsIRequest *aDocRequest, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aDocChannel, buffer); + GetURIStringFromRequest(aDocRequest, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnEndDocumentLoad(...)" @@ -826,25 +834,25 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, continue; } - observer->OnEndDocumentLoad(aLoadInitiator, aDocChannel, aStatus); + observer->OnEndDocumentLoad(aLoadInitiator, aDocRequest, aStatus); } /* * Next notify the parent... */ if (mParent) { - mParent->FireOnEndDocumentLoad(aLoadInitiator, aDocChannel, aStatus); + mParent->FireOnEndDocumentLoad(aLoadInitiator, aDocRequest, aStatus); } } void nsDocLoaderImpl::FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel* aChannel) + nsIRequest* aRequest) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(aRequest, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnStartURLLoad(...)" @@ -878,25 +886,25 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, continue; } - observer->OnStartURLLoad(aLoadInitiator, aChannel); + observer->OnStartURLLoad(aLoadInitiator, aRequest); } /* * Finally notify the parent... */ if (mParent) { - mParent->FireOnStartURLLoad(aLoadInitiator, aChannel); + mParent->FireOnStartURLLoad(aLoadInitiator, aRequest); } } void nsDocLoaderImpl::FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel* aChannel, nsresult aStatus) + nsIRequest *request, nsresult aStatus) { #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(request, buffer); if (aLoadInitiator == this) { PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: ++ Firing OnEndURLLoad(...)" @@ -929,14 +937,14 @@ void nsDocLoaderImpl::FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, continue; } - observer->OnEndURLLoad(aLoadInitiator, aChannel, aStatus); + observer->OnEndURLLoad(aLoadInitiator, request, aStatus); } /* * Finally notify the parent... */ if (mParent) { - mParent->FireOnEndURLLoad(aLoadInitiator, aChannel, aStatus); + mParent->FireOnEndURLLoad(aLoadInitiator, request, aStatus); } } @@ -1072,7 +1080,7 @@ nsresult nsDocLoaderImpl::GetMaxTotalProgress(PRInt32 *aMaxTotalProgress) // then turns around and makes the right web progress calls based on this information. //////////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctxt, +NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIRequest *request, nsISupports* ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { nsChannelInfo *info; @@ -1081,6 +1089,9 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctx // // 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)) { @@ -1113,7 +1124,7 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctx flags |= nsIWebProgressListener::STATE_IS_DOCUMENT; } - FireOnStateChange(this, aChannel, flags, NS_OK); + FireOnStateChange(this, request, flags, NS_OK); } // Update the current progress count... @@ -1130,7 +1141,7 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctx #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(request, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p OOPS - No Channel Info for: %s\n", this, (const char *)buffer)); @@ -1142,13 +1153,13 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctx // // Fire progress notifications out to any registered nsIWebProgressListeners // - FireOnProgressChange(this, aChannel, aProgress, aProgressMax, progressDelta, + FireOnProgressChange(this, request, aProgress, aProgressMax, progressDelta, mCurrentTotalProgress, mMaxTotalProgress); return NS_OK; } -NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIChannel* aChannel, nsISupports* ctxt, +NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIRequest* aRequest, nsISupports* ctxt, nsresult aStatus, const PRUnichar* aStatusArg) { // @@ -1161,7 +1172,7 @@ NS_IMETHODIMP nsDocLoaderImpl::OnStatus(nsIChannel* aChannel, nsISupports* ctxt, nsXPIDLString msg; rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg)); if (NS_FAILED(rv)) return rv; - FireOnStatusChange(this, aChannel, aStatus, msg); + FireOnStatusChange(this, aRequest, aStatus, msg); } return NS_OK; } @@ -1178,7 +1189,7 @@ void nsDocLoaderImpl::ClearInternalProgress() void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, - nsIChannel *aChannel, + nsIRequest *request, PRInt32 aProgress, PRInt32 aProgressMax, PRInt32 aProgressDelta, @@ -1198,7 +1209,7 @@ void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aChannel, buffer); + GetURIStringFromRequest(request, 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)); @@ -1225,7 +1236,7 @@ void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, continue; } - listener->OnProgressChange(aLoadInitiator,aChannel, + listener->OnProgressChange(aLoadInitiator,request, aProgress, aProgressMax, aTotalProgress, aMaxTotalProgress); } @@ -1234,7 +1245,7 @@ void nsDocLoaderImpl::FireOnProgressChange(nsDocLoaderImpl *aLoadInitiator, // Pass the notification up to the parent... if (mParent) { - mParent->FireOnProgressChange(aLoadInitiator, aChannel, + mParent->FireOnProgressChange(aLoadInitiator, request, aProgress, aProgressMax, aProgressDelta, aTotalProgress, aMaxTotalProgress); @@ -1266,7 +1277,7 @@ void nsDocLoaderImpl::FireOnStateChange(nsIWebProgress *aProgress, #if defined(DEBUG) nsXPIDLCString buffer; - GetURIStringFromChannel(aRequest, buffer); + GetURIStringFromRequest(aRequest, buffer); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: Status (%s): code: %x\n", this, (const char *)buffer, aStateFlags)); @@ -1470,17 +1481,17 @@ NS_IMETHODIMP nsDocLoaderImpl::OnRedirect(nsISupports * aContext, nsIURI * aNewL PRInt32 stateFlags = nsIWebProgressListener::STATE_REDIRECTING | nsIWebProgressListener::STATE_IS_REQUEST | nsIWebProgressListener::STATE_IS_NETWORK; - nsCOMPtr channel (do_QueryInterface(aContext)); + nsCOMPtr request (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 mDocumentChannel... - if (channel.get() == mDocumentChannel.get()) + // and to reset mDocumentRequest... + if (request.get() == mDocumentRequest.get()) { stateFlags |= nsIWebProgressListener::STATE_IS_DOCUMENT; - mDocumentChannel = channel; // reset the document channel + mDocumentRequest = request; // reset the document channel } - FireOnStateChange(this, channel, stateFlags, NS_OK); + FireOnStateChange(this, request, stateFlags, NS_OK); } return NS_OK; diff --git a/mozilla/uriloader/base/nsDocLoader.h b/mozilla/uriloader/base/nsDocLoader.h index 819e874b3aa..40aba8dd58a 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, - nsIChannel* aChannel); + nsIRequest *request); void FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel *aDocChannel, + nsIRequest *aDocRequest, nsresult aStatus); void FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel* channel); + nsIRequest *request); void FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIChannel* channel, nsresult aStatus); + nsIRequest *request, nsresult aStatus); void FireOnProgressChange(nsDocLoaderImpl* aLoadInitiator, - nsIChannel* aChannel, + nsIRequest *request, PRInt32 aProgress, PRInt32 aProgressMax, PRInt32 aProgressDelta, @@ -111,14 +111,14 @@ protected: PRInt32 aMaxTotalProgress); void FireOnStateChange(nsIWebProgress *aProgress, - nsIRequest* aChannel, + nsIRequest* request, PRInt32 aStateFlags, nsresult aStatus); void doStartDocumentLoad(); - void doStartURLLoad(nsIChannel *aChannel); - void doStopURLLoad(nsIChannel *aChannel, nsresult aStatus); - void doStopDocumentLoad(nsIChannel* aChannel, nsresult aStatus); + void doStartURLLoad(nsIRequest *request); + void doStopURLLoad(nsIRequest *request, nsresult aStatus); + void doStopDocumentLoad(nsIRequest *request, 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 mDocumentChannel; // [OWNER] ???compare with document + nsCOMPtr mDocumentRequest; // [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 *aChannel); - nsChannelInfo *GetChannelInfo(nsIChannel *aChannel); + nsresult AddChannelInfo(nsIChannel* channel); + nsChannelInfo *GetChannelInfo(nsIChannel* channel); 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 d03c3401252..a47ccded2c4 100644 --- a/mozilla/uriloader/base/nsIContentHandler.idl +++ b/mozilla/uriloader/base/nsIContentHandler.idl @@ -21,7 +21,7 @@ */ #include "nsISupports.idl" -interface nsIChannel; +interface nsIRequest; [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. - aChannel is an open channel whose content type is already known (aContentType) */ + aRequest is a request whose content type is already known (aContentType) */ void handleContent(in string aContentType, in string aCommand, in string aWindowTarget, in nsISupports aSourceContext, - in nsIChannel aChannel); + in nsIRequest aRequest); }; diff --git a/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl b/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl index 86c52fde5ac..75ec3a47033 100644 --- a/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl +++ b/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl @@ -28,8 +28,7 @@ interface nsIDocumentLoader; interface nsIURI; -interface nsIChannel; - +interface nsIRequest; /* we'll be phasing this interface out in place of a new improved progress sink interface */ @@ -55,7 +54,7 @@ interface nsIDocumentLoaderObserver : nsISupports /** * Notify the observer that a document has been completely loaded. */ - void onEndDocumentLoad(in nsIDocumentLoader loader, in nsIChannel aChannel, in unsigned long aStatus); + void onEndDocumentLoad(in nsIDocumentLoader loader, in nsIRequest request, in unsigned long aStatus); /** * Notify the observer that the specified nsIURI has just started to load. @@ -63,26 +62,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 nsIChannel channel); + void onStartURLLoad(in nsIDocumentLoader aLoader, in nsIRequest request); /** * Notify the observer that progress has occurred in the loading of the * specified URL... */ void onProgressURLLoad(in nsIDocumentLoader aLoader, - in nsIChannel aChannel, in unsigned long aProgress, + in nsIRequest aRequest, 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 nsIChannel channel, in nsStringRef aMsg); + [noscript] void onStatusURLLoad(in nsIDocumentLoader loader, in nsIRequest request, in nsStringRef aMsg); /** * Notify the observer that the specified nsIURI has finished loading. */ - void onEndURLLoad(in nsIDocumentLoader aLoader, in nsIChannel aChannel, in unsigned long aStatus); + void onEndURLLoad(in nsIDocumentLoader aLoader, in nsIRequest aRequest, 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 e7389c73593..b7ae95752f6 100644 --- a/mozilla/uriloader/base/nsIURIContentListener.idl +++ b/mozilla/uriloader/base/nsIURIContentListener.idl @@ -31,7 +31,7 @@ #include "nsIURILoader.idl" interface nsIProtocolHandler; -interface nsIChannel; +interface nsIRequest; interface nsIStreamListener; interface nsIURI; @@ -79,7 +79,7 @@ interface nsIURIContentListener : nsISupports void doContent(in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, - in nsIChannel aOpenedChannel, + in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); diff --git a/mozilla/uriloader/base/nsIURILoader.idl b/mozilla/uriloader/base/nsIURILoader.idl index 7a77fe69553..c901dcf682c 100644 --- a/mozilla/uriloader/base/nsIURILoader.idl +++ b/mozilla/uriloader/base/nsIURILoader.idl @@ -48,6 +48,7 @@ interface nsILoadGroup; interface nsIDocumentLoader; interface nsIProgressEventSink; interface nsIChannel; +interface nsIRequest; interface nsIStreamListener; interface nsIInputStream; @@ -115,7 +116,7 @@ interface nsIURILoader : nsISupports void dispatchContent(in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, - in nsIChannel aChannel, + in nsIRequest aRequest, in nsISupports aCtxt, in nsIURIContentListener aContentListener, in nsISupports aSrcWindowContext, diff --git a/mozilla/uriloader/base/nsURILoader.cpp b/mozilla/uriloader/base/nsURILoader.cpp index 6586a588216..03def17acaa 100644 --- a/mozilla/uriloader/base/nsURILoader.cpp +++ b/mozilla/uriloader/base/nsURILoader.cpp @@ -37,7 +37,6 @@ #include "nsIInputStream.h" #include "nsIStreamConverterService.h" #include "nsWeakReference.h" - #include "nsIHTTPChannel.h" #include "nsIDocShellTreeItem.h" @@ -83,13 +82,13 @@ public: NS_DECL_ISUPPORTS - nsresult Open(nsIChannel * aChannel, + nsresult Open(nsIChannel* channel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aWindowContext); - nsresult DispatchContent(nsIChannel * aChannel, nsISupports * aCtxt); - nsresult RetargetOutput(nsIChannel * aChannel, const char * aSrcContentType, + nsresult DispatchContent(nsIRequest *request, nsISupports * aCtxt); + nsresult RetargetOutput(nsIRequest *request, const char * aSrcContentType, const char * aOutContentType, nsIStreamListener * aStreamListener); // nsIStreamObserver methods: @@ -104,7 +103,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(nsIChannel * aChannel); + PRBool ProcessCanceledCase(nsIRequest *request); protected: nsCOMPtr m_contentListener; @@ -162,14 +161,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(nsIChannel * aChannel) +PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIRequest *request) { PRBool canceled = PR_FALSE; nsresult rv = NS_OK; - if (aChannel) + if (request) { - aChannel->GetStatus(&rv); + request->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) @@ -186,7 +185,7 @@ PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIChannel * aChannel) return canceled; } -nsresult nsDocumentOpenInfo::Open(nsIChannel * aChannel, +nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aWindowContext) @@ -204,8 +203,10 @@ nsresult nsDocumentOpenInfo::Open(nsIChannel * aChannel, mCommand = aCommand; // now just open the channel! - if (aChannel) - rv = aChannel->AsyncRead(this, nsnull); + if (aChannel){ + rv = aChannel->AsyncOpen(this, nsnull); + } + if (rv == NS_ERROR_DOM_RETVAL_UNDEFINED) { NS_WARNING("js returned no result -- not replacing window contents"); rv = NS_OK; @@ -213,7 +214,7 @@ nsresult nsDocumentOpenInfo::Open(nsIChannel * aChannel, return rv; } -NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) +NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) { nsresult rv = NS_OK; @@ -224,7 +225,7 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIChannel * aChannel, nsISuppo // content handler. Just return. This causes the request to be // ignored. // - nsCOMPtr httpChannel(do_QueryInterface(aChannel, &rv)); + nsCOMPtr httpChannel(do_QueryInterface(request, &rv)); if (NS_SUCCEEDED(rv)) { PRUint32 responseCode = 0; @@ -235,16 +236,16 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIChannel * aChannel, nsISuppo } } - if (ProcessCanceledCase(aChannel)) + if (ProcessCanceledCase(request)) return NS_OK; - rv = DispatchContent(aChannel, aCtxt); + rv = DispatchContent(request, aCtxt); if (m_targetStreamListener) - rv = m_targetStreamListener->OnStartRequest(aChannel, aCtxt); + rv = m_targetStreamListener->OnStartRequest(request, aCtxt); return rv; } -NS_IMETHODIMP nsDocumentOpenInfo::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, +NS_IMETHODIMP nsDocumentOpenInfo::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * inStr, PRUint32 sourceOffset, PRUint32 count) { // if we have retarged to the end stream listener, then forward the call.... @@ -252,26 +253,26 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnDataAvailable(nsIChannel * aChannel, nsISupp nsresult rv = NS_OK; - if (ProcessCanceledCase(aChannel)) + if (ProcessCanceledCase(request)) return NS_OK; if (m_targetStreamListener) - rv = m_targetStreamListener->OnDataAvailable(aChannel, aCtxt, inStr, sourceOffset, count); + rv = m_targetStreamListener->OnDataAvailable(request, aCtxt, inStr, sourceOffset, count); return rv; } -NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIChannel * aChannel, nsISupports *aCtxt, +NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, nsresult aStatus, const PRUnichar * errorMsg) { nsresult rv = NS_OK; - if (ProcessCanceledCase(aChannel)) + if (ProcessCanceledCase(request)) return NS_OK; if (!mOnStopFired && m_targetStreamListener) { mOnStopFired = PR_TRUE; - m_targetStreamListener->OnStopRequest(aChannel, aCtxt, aStatus, errorMsg); + m_targetStreamListener->OnStopRequest(request, aCtxt, aStatus, errorMsg); } m_targetStreamListener = 0; @@ -279,12 +280,15 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIChannel * aChannel, nsISuppor return rv; } -nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports * aCtxt) +nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, 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; @@ -302,7 +306,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports // PRBool abortDispatch = PR_FALSE; rv = pURILoader->DispatchContent(contentType, mCommand, m_windowTarget, - aChannel, aCtxt, + request, aCtxt, m_contentListener, m_originalContext, getter_Copies(desiredContentType), @@ -320,7 +324,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports // if (!contentListener) { - rv = RetargetOutput(aChannel, contentType, "*/*", nsnull); + rv = RetargetOutput(request, contentType, "*/*", nsnull); if (m_targetStreamListener) return NS_OK; } @@ -363,7 +367,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports } rv = contentListener->DoContent(contentTypeToUse, mCommand, m_windowTarget, - aChannel, getter_AddRefs(contentStreamListener), + request, getter_AddRefs(contentStreamListener), &bAbortProcess); // the listener is doing all the work from here...we are done!!! @@ -381,7 +385,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports { rv = helperAppService->DoContent(contentType, uri, m_originalContext, &abortProcess, getter_AddRefs(contentStreamListener)); if (NS_SUCCEEDED(rv) && contentStreamListener) - return RetargetOutput(aChannel, contentType, contentType, contentStreamListener); + return RetargetOutput(request, contentType, contentType, contentStreamListener); } rv = NS_ERROR_FAILURE; // this will cause us to bring up the unknown content handler dialog. } @@ -389,14 +393,14 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, 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(aChannel, contentType, desiredContentType, contentStreamListener); + rv = RetargetOutput(request, contentType, desiredContentType, contentStreamListener); m_originalContext = nsnull; // we don't need this anymore.... } } return rv; } -nsresult nsDocumentOpenInfo::RetargetOutput(nsIChannel * aChannel, const char * aSrcContentType, const char * aOutContentType, +nsresult nsDocumentOpenInfo::RetargetOutput(nsIRequest *request, const char * aSrcContentType, const char * aOutContentType, nsIStreamListener * aStreamListener) { nsresult rv = NS_OK; @@ -435,7 +439,7 @@ nsresult nsDocumentOpenInfo::RetargetOutput(nsIChannel * aChannel, const char * rv = StreamConvService->AsyncConvertData(from_w.GetUnicode(), to_w.GetUnicode(), nextLink, - aChannel, + request, getter_AddRefs(m_targetStreamListener)); NS_RELEASE(nextLink); } @@ -495,12 +499,12 @@ NS_IMETHODIMP nsURILoader::UnRegisterContentListener(nsIURIContentListener * aCo } -NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel * aChannel, +NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aWindowContext) { - return OpenURIVia(aChannel, aCommand, aWindowTarget, aWindowContext, 0 /* ip address */); + return OpenURIVia(channel, aCommand, aWindowTarget, aWindowContext, 0 /* ip address */); } // @@ -640,7 +644,7 @@ PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem, nsIDocShellTreeItem* return SameOrSubdomainOfTarget(originDocumentURI, targetPrincipalURI, documentDomainSet); } -NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel * aChannel, nsCString &aWindowTarget, +NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel *channel, nsCString &aWindowTarget, nsISupports * aWindowContext, nsISupports ** aRetargetedWindowContext) { @@ -767,7 +771,7 @@ NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel * aChannel, nsCString &aWindowTa return NS_OK; } -NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel, +NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel, nsURILoadCommand aCommand, const char * aWindowTarget, nsISupports * aOriginalWindowContext, @@ -775,19 +779,19 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel, { // 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 (!aChannel) return NS_ERROR_NULL_POINTER; + if (!channel) 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; - aChannel->GetURI(getter_AddRefs(uri)); + channel->GetURI(getter_AddRefs(uri)); if(uri) { PRBool doAbort = PR_FALSE; @@ -800,7 +804,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel, nsCAutoString windowTarget(aWindowTarget); nsCOMPtr retargetedWindowContext; - NS_ENSURE_SUCCESS(GetTarget(aChannel, windowTarget, aOriginalWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(GetTarget(channel, windowTarget, aOriginalWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE); NS_NEWXPCOM(loader, nsDocumentOpenInfo); if (!loader) return NS_ERROR_OUT_OF_MEMORY; @@ -812,7 +816,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel * aChannel, loader->Init(retargetedWindowContext, aOriginalWindowContext); // Extra Info // now instruct the loader to go ahead and open the url - rv = loader->Open(aChannel, aCommand, windowTarget, retargetedWindowContext); + rv = loader->Open(channel, aCommand, windowTarget, retargetedWindowContext); NS_RELEASE(loader); return rv; @@ -962,7 +966,7 @@ PRBool nsURILoader::ShouldHandleContent(nsIURIContentListener * aCntListener, NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIChannel * aChannel, + nsIRequest *request, nsISupports * aCtxt, nsIURIContentListener * aContentListener, nsISupports * aSrcWindowContext, @@ -971,7 +975,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType, PRBool * aAbortProcess) { NS_ENSURE_ARG(aContentType); - NS_ENSURE_ARG(aChannel); + NS_ENSURE_ARG(request); // 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 @@ -1051,7 +1055,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, aChannel); + rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aSrcWindowContext, request); *aAbortProcess = PR_TRUE; } diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index 6b58308e549..500e9e281bf 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -48,7 +48,8 @@ #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" @@ -599,7 +600,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. @@ -640,12 +641,15 @@ void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel * aCha } // if we had an http channel } -nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIChannel * aChannel) +nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIRequest *request) { // 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); @@ -668,12 +672,12 @@ nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIChannel * aChannel) origContextLoader->GetDocumentChannel(getter_AddRefs(mOriginalChannel)); if(oldLoadGroup) - oldLoadGroup->RemoveChannel(aChannel, nsnull, NS_OK, nsnull); + oldLoadGroup->RemoveRequest(request, nsnull, NS_OK, nsnull); aChannel->SetLoadGroup(newLoadGroup); nsCOMPtr req (do_QueryInterface(mLoadCookie)); aChannel->SetNotificationCallbacks(req); - rv = newLoadGroup->AddChannel(aChannel, nsnull); + rv = newLoadGroup->AddRequest(request, nsnull); return rv; } @@ -752,13 +756,16 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel) mTempFile->Append(saltedTempLeafName); // make this file unique!!! mTempFile->CreateUnique(nsnull, nsIFile::NORMAL_FILE_TYPE, 0644); - 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; + 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)); + #ifdef XP_MAC nsXPIDLCString contentType; mMimeInfo->GetMIMEType(getter_Copies(contentType)); @@ -773,24 +780,25 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel) } } #endif - } return rv; } -NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIChannel * aChannel, nsISupports * aCtxt) +NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISupports * aCtxt) { - NS_ENSURE_ARG(aChannel); + NS_ENSURE_ARG(request); // first, check to see if we've been canceled.... if (mCanceled) // then go cancel our underlying channel too - return aChannel->Cancel(NS_BINDING_ABORTED); + return request->Cancel(NS_BINDING_ABORTED); + + nsCOMPtr aChannel = do_QueryInterface(request); nsresult rv = SetUpTempFile(aChannel); // retarget all load notifcations to our docloader instead of the original window's docloader... - RetargetLoadNotifications(aChannel); + RetargetLoadNotifications(request); // ignore failure... ExtractSuggestedFileNameFromChannel(aChannel); nsCOMPtr httpChannel = do_QueryInterface( aChannel ); @@ -827,12 +835,12 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIChannel * aChannel, nsISup return NS_OK; } -NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIChannel * aChannel, nsISupports * aCtxt, +NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIRequest *request, 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 aChannel->Cancel(NS_BINDING_ABORTED); + return request->Cancel(NS_BINDING_ABORTED); // read the data out of the stream and write it to the temp file. PRUint32 numBytesRead = 0; @@ -853,7 +861,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIChannel * aChannel, nsISu return NS_OK; } -NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIChannel * aChannel, nsISupports *aCtxt, +NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, nsresult aStatus, const PRUnichar * errorMsg) { nsresult rv = NS_OK; @@ -861,7 +869,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIChannel * aChannel, nsISupp // first, check to see if we've been canceled.... if (mCanceled) // then go cancel our underlying channel too - return aChannel->Cancel(NS_BINDING_ABORTED); + return request->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 @@ -1135,7 +1143,7 @@ NS_IMETHODIMP nsExternalAppHandler::CanHandleContent(const char * aContentType, } NS_IMETHODIMP nsExternalAppHandler::DoContent(const char * aContentType, nsURILoadCommand aCommand, const char * aWindowTarget, - nsIChannel * aOpenedChannel, + nsIRequest * aRequest, nsIStreamListener ** aContentHandler,PRBool * aAbortProcess) { NS_NOTREACHED("DoContent"); diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.h b/mozilla/uriloader/exthandler/nsExternalHelperAppService.h index 0ff11d8f45e..f126f1ca16b 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(nsIChannel * aChannel); + nsresult RetargetLoadNotifications(nsIRequest *request); // 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 1141701f429..46097106ba3 100644 --- a/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -144,30 +144,18 @@ nsresult nsExtProtocolChannel::OpenURL() return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsExtProtocolChannel::OpenInputStream(nsIInputStream **_retval) +NS_IMETHODIMP nsExtProtocolChannel::Open(nsIInputStream **_retval) { OpenURL(); // force caller to abort. return NS_ERROR_FAILURE; // force caller to abort. } -NS_IMETHODIMP nsExtProtocolChannel::OpenOutputStream(nsIOutputStream **_retval) -{ - NS_NOTREACHED("OpenOutputStream"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsExtProtocolChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt) +NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen(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; @@ -202,83 +190,6 @@ 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 989bb3492a4..7275d73c198 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2097,7 +2097,7 @@ nsBrowserWindow::OnStartDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest* request, nsresult aStatus) { return NS_OK; @@ -2105,14 +2105,14 @@ nsBrowserWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel) + nsIRequest* request) { return NS_OK; } NS_IMETHODIMP nsBrowserWindow::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest* request, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -2121,7 +2121,7 @@ nsBrowserWindow::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest* request, nsString& aMsg) { return NS_OK; @@ -2129,19 +2129,20 @@ nsBrowserWindow::OnStatusURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsBrowserWindow::OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest* request, nsresult aStatus) { return NS_OK; } NS_IMETHODIMP -nsBrowserWindow::OnProgress(nsIChannel* channel, nsISupports *ctxt, +nsBrowserWindow::OnProgress(nsIRequest* request, 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; @@ -2167,7 +2168,7 @@ nsBrowserWindow::OnProgress(nsIChannel* channel, nsISupports *ctxt, } NS_IMETHODIMP -nsBrowserWindow::OnStatus(nsIChannel* channel, nsISupports *ctxt, +nsBrowserWindow::OnStatus(nsIRequest* request, 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 866e25121a9..9736af8cc85 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, - nsIChannel* channel, + nsIRequest* request, nsresult aStatus) { nsresult rv; @@ -356,6 +356,7 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, } nsCOMPtr aURL; + nsCOMPtr channel = do_QueryInterface(request); rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) { return rv; @@ -458,14 +459,14 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsWebCrawler::OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel) + nsIRequest* request) { return NS_OK; } NS_IMETHODIMP nsWebCrawler::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest* request, PRUint32 aProgress, PRUint32 aProgressMax) { @@ -474,14 +475,14 @@ nsWebCrawler::OnProgressURLLoad(nsIDocumentLoader* loader, NS_IMETHODIMP nsWebCrawler::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, + nsIRequest* request, nsString& aMsg) { return NS_OK; } NS_IMETHODIMP -nsWebCrawler::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, +nsWebCrawler::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest* request, nsresult aStatus) { return NS_OK; diff --git a/mozilla/widget/src/gtk/nsGtkMozRemoteHelper.cpp b/mozilla/widget/src/gtk/nsGtkMozRemoteHelper.cpp index 6011c9ee8df..8a7acabba73 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, - nsIChannel *aOpenedChannel, + nsIRequest *aOpenedRequest, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { diff --git a/mozilla/widget/src/gtk/nsSound.cpp b/mozilla/widget/src/gtk/nsSound.cpp index 4b77484fac8..8642de78f4c 100644 --- a/mozilla/widget/src/gtk/nsSound.cpp +++ b/mozilla/widget/src/gtk/nsSound.cpp @@ -116,15 +116,19 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, // print a load error on bad status if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr channel; - aLoader->GetChannel(getter_AddRefs(channel)); - if (channel) { + nsCOMPtr request; + aLoader->GetRequest(getter_AddRefs(request)); + if (request) { nsCOMPtr uri; - channel->GetURI(getter_AddRefs(uri)); - if (uri) { - char* uriSpec; - uri->GetSpec(&uriSpec); - printf("Failed to load %s\n", uriSpec ? uriSpec : ""); + 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); + } } } } diff --git a/mozilla/widget/src/os2/nsSound.cpp b/mozilla/widget/src/os2/nsSound.cpp index e95bcb5130c..e5e50aad1dd 100644 --- a/mozilla/widget/src/os2/nsSound.cpp +++ b/mozilla/widget/src/os2/nsSound.cpp @@ -61,15 +61,19 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, // print a load error on bad status if (NS_FAILED(aStatus)) { if (aLoader) { - nsCOMPtr channel; - aLoader->GetChannel(getter_AddRefs(channel)); - if (channel) { + nsCOMPtr request; + aLoader->GetRequest(getter_AddRefs(request)); + if (request) { nsCOMPtr uri; - channel->GetURI(getter_AddRefs(uri)); - if (uri) { - char* uriSpec; - uri->GetSpec(&uriSpec); - printf("Failed to load %s\n", uriSpec ? uriSpec : ""); + 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); + } } } } diff --git a/mozilla/widget/src/windows/nsSound.cpp b/mozilla/widget/src/windows/nsSound.cpp index 3ce8b749c0d..ed70430cfd2 100644 --- a/mozilla/widget/src/windows/nsSound.cpp +++ b/mozilla/widget/src/windows/nsSound.cpp @@ -95,8 +95,11 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader, // print a load error on bad status if (NS_FAILED(aStatus)) { if (aLoader) { + nsCOMPtr request; nsCOMPtr channel; - aLoader->GetChannel(getter_AddRefs(channel)); + aLoader->GetRequest(getter_AddRefs(request)); + if (request) + channel = do_QueryInterface(request); if (channel) { nsCOMPtr uri; channel->GetURI(getter_AddRefs(uri)); diff --git a/mozilla/xpcom/tests/PropertiesTest.cpp b/mozilla/xpcom/tests/PropertiesTest.cpp index 581a52d9637..ae35b483d89 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->OpenInputStream(&in); + ret = channel->Open(&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 d1f351baa0c..2c7fa02b378 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.openOutputStream(); + var outStream = this.fileChannel.open(); 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.openInputStream(); + var inStream = this.fileChannel.open(); this.inputStream.init(inStream); diff --git a/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl b/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl index 905ed94d91f..9e843cd5311 100644 --- a/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl +++ b/mozilla/xpfe/appshell/public/nsIXULBrowserWindow.idl @@ -28,7 +28,7 @@ * it's ui. */ -interface nsIChannel; +interface nsIRequest; [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 nsIChannel aChannel, in unsigned long aProgressStateFlags); + void onStateChange(in nsIRequest aRequest, 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 nsIChannel aChannel, in long aCurrentProgress, in long aMaxProgress); + void onProgress (in nsIRequest aRequest, in long aCurrentProgress, in long aMaxProgress); /* Tells the browser window that a new status message is available. */ - void onStatus(in nsIChannel aChannel, in nsresult aStatus, in wstring aMsg); + void onStatus(in nsIRequest aRequest, in nsresult aStatus, in wstring aMsg); }; diff --git a/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl b/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl index 905ed94d91f..9e843cd5311 100644 --- a/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl +++ b/mozilla/xpfe/browser/public/nsIXULBrowserWindow.idl @@ -28,7 +28,7 @@ * it's ui. */ -interface nsIChannel; +interface nsIRequest; [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 nsIChannel aChannel, in unsigned long aProgressStateFlags); + void onStateChange(in nsIRequest aRequest, 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 nsIChannel aChannel, in long aCurrentProgress, in long aMaxProgress); + void onProgress (in nsIRequest aRequest, in long aCurrentProgress, in long aMaxProgress); /* Tells the browser window that a new status message is available. */ - void onStatus(in nsIChannel aChannel, in nsresult aStatus, in wstring aMsg); + void onStatus(in nsIRequest aRequest, 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 a25d6b87cc2..41086f57cf4 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -193,9 +193,9 @@ nsXULBrowserWindow.prototype = statusTextFld.setAttribute("value", text); }, - onProgress : function (channel, current, max) + onProgress : function (request, current, max) { - if (!this.useRealProgressFlag && channel) + if (!this.useRealProgressFlag && request) return; if (!statusMeter) @@ -214,7 +214,7 @@ nsXULBrowserWindow.prototype = } }, - onStateChange : function(channel, state) + onStateChange : function(request, state) { const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; @@ -260,9 +260,9 @@ nsXULBrowserWindow.prototype = if (!this.useRealProgressFlag) this.onProgress(null, this.finishedRequests, this.totalRequests); } - if (state & nsIWebProgressListener.STATE_IS_NETWORK) { - var location = channel.URI.spec; + var channel = request.QueryInterface(Components.interfaces.nsIChannel); + var location = channel.URI.spec; var msg = ""; if (location != "about:blank") { // Record page loading time. @@ -287,7 +287,8 @@ nsXULBrowserWindow.prototype = } else if (state & nsIWebProgressListener.STATE_TRANSFERRING) { if (state & nsIWebProgressListener.STATE_IS_DOCUMENT) { - var ctype=channel.contentType; + var channel = request.QueryInterface(Components.interfaces.nsIChannel); + var ctype=channel.contentType; if (ctype != "text/html") this.useRealProgressFlag = true; @@ -317,7 +318,7 @@ nsXULBrowserWindow.prototype = UpdateBackForwardButtons(); }, - onStatus : function(channel, status, msg) + onStatus : function(request, 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 342ecd52f0b..29117cdc5e2 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, - nsIChannel *aChannel) + nsIRequest *request) { nsresult rv; @@ -911,6 +911,9 @@ 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; @@ -958,11 +961,14 @@ nsresult nsBrowserInstance::StartDocumentLoad(nsIDOMWindow *aDOMWindow, } nsresult nsBrowserInstance::EndDocumentLoad(nsIDOMWindow *aDOMWindow, - nsIChannel *aChannel, + nsIRequest *request, 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; @@ -1090,7 +1096,7 @@ nsBrowserInstance::GetProtocolHandler(nsIURI * /* aURI */, nsIProtocolHandler ** NS_IMETHODIMP nsBrowserInstance::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, - nsIChannel *aChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) + nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) { nsCOMPtr docShell; GetContentAreaDocShell(getter_AddRefs(docShell)); @@ -1098,7 +1104,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, aChannel, aContentHandler, aAbortProcess); + return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, request, aContentHandler, aAbortProcess); return NS_OK; } @@ -1211,13 +1217,7 @@ nsBrowserInstance::OnProgressChange(nsIWebProgress* aWebProgress, { EnsureXULBrowserWindow(); if(mXULBrowserWindow) { - nsresult rv; - nsCOMPtr channel; - - channel = do_QueryInterface(aRequest, &rv); - if (NS_SUCCEEDED(rv)) { - mXULBrowserWindow->OnProgress(channel, aCurTotalProgress, aMaxTotalProgress); - } + mXULBrowserWindow->OnProgress(aRequest, aCurTotalProgress, aMaxTotalProgress); } return NS_OK; } @@ -1229,12 +1229,11 @@ 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 (!channel) { + if (!aRequest) { return NS_OK; } @@ -1244,16 +1243,16 @@ nsBrowserInstance::OnStateChange(nsIWebProgress* aWebProgress, rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow)); if (NS_SUCCEEDED(rv)) { if (aStateFlags & nsIWebProgressListener::STATE_START) { - rv = StartDocumentLoad(domWindow, channel); + rv = StartDocumentLoad(domWindow, aRequest); } else if (aStateFlags & nsIWebProgressListener::STATE_STOP) { - rv = EndDocumentLoad(domWindow, channel, aStatus); + rv = EndDocumentLoad(domWindow, aRequest, aStatus); } } } if(mXULBrowserWindow) { - mXULBrowserWindow->OnStateChange(channel, aStateFlags); + mXULBrowserWindow->OnStateChange(aRequest, aStateFlags); } return NS_OK; } @@ -1282,13 +1281,7 @@ nsBrowserInstance::OnStatusChange(nsIWebProgress* aWebProgress, { EnsureXULBrowserWindow(); if(mXULBrowserWindow) { - nsresult rv; - nsCOMPtr channel; - - channel = do_QueryInterface(aRequest, &rv); - if (NS_SUCCEEDED(rv)) { - mXULBrowserWindow->OnStatus(channel, aStatus, aMessage); - } + mXULBrowserWindow->OnStatus(aRequest, aStatus, aMessage); } return NS_OK; } @@ -1499,11 +1492,11 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, - nsIChannel * aChannel) + nsIRequest * aRequest) { // 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(aChannel); + NS_ENSURE_ARG(aRequest); nsCOMPtr parentWindow; JSContext* jsContext = nsnull; @@ -1533,6 +1526,10 @@ 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); @@ -1563,7 +1560,7 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType, JS_PopArguments(jsContext, mark); // now abort the current channel load... - aChannel->Cancel(NS_BINDING_ABORTED); + aRequest->Cancel(NS_BINDING_ABORTED); return NS_OK; } diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.h b/mozilla/xpfe/browser/src/nsBrowserInstance.h index 56558bfe75e..3dcd839dce7 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, - nsIChannel *aChannel); + nsIRequest *request); nsresult EndDocumentLoad(nsIDOMWindow *aDOMWindow, - nsIChannel *aChannel, + nsIRequest *request, nsresult aResult); PRBool mIsClosed; diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp index bd50e2f8cb6..d8d71924650 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -1994,13 +1994,12 @@ 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->AsyncRead(bmks, nsnull))) + if (NS_SUCCEEDED(rv = channel->AsyncOpen(bmks, nsnull))) { bmks->busySchedule = PR_TRUE; } @@ -2036,7 +2035,7 @@ else NS_IMETHODIMP -nsBookmarksService::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +nsBookmarksService::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { return(NS_OK); } @@ -2044,7 +2043,7 @@ nsBookmarksService::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) NS_IMETHODIMP -nsBookmarksService::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *aIStream, +nsBookmarksService::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { // calculate html page size if server doesn't tell us in headers @@ -2056,7 +2055,7 @@ nsBookmarksService::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsII NS_IMETHODIMP -nsBookmarksService::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsresult rv; @@ -2068,7 +2067,7 @@ nsBookmarksService::OnStopRequest(nsIChannel* channel, 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 52527dea130..6e6b7b56750 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(nsIChannel* aChannel, nsISupports* aContext) +nsHTTPIndexParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { nsresult rv; @@ -356,6 +356,8 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, 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)); @@ -386,7 +388,7 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) NS_IMETHODIMP -nsHTTPIndexParser::OnStopRequest(nsIChannel* aChannel, +nsHTTPIndexParser::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus, const PRUnichar* aErrorMsg) @@ -425,7 +427,7 @@ nsHTTPIndexParser::OnStopRequest(nsIChannel* aChannel, NS_IMETHODIMP -nsHTTPIndexParser::OnDataAvailable(nsIChannel* aChannel, +nsHTTPIndexParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext, nsIInputStream* aStream, PRUint32 aSourceOffset, @@ -1325,7 +1327,7 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure) } if (NS_SUCCEEDED(rv) && (listener)) { - rv = channel->AsyncRead(listener, aSource); + rv = channel->AsyncOpen(listener, aSource); } } } @@ -1694,7 +1696,7 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, aDocViewerResult); if (NS_FAILED(rv)) return rv; - rv = channel->AsyncRead(listener, nsnull); + rv = channel->AsyncOpen(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 61fc53d716b..88094d9c69b 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(nsIChannel* channel, nsISupports *ctxt) +RelatedLinksStreamListener::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { nsAutoString trueStr; trueStr.AssignWithConversion("true"); nsIRDFLiteral *literal = nsnull; @@ -255,7 +255,7 @@ RelatedLinksStreamListener::OnStartRequest(nsIChannel* channel, nsISupports *ctx NS_IMETHODIMP -RelatedLinksStreamListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +RelatedLinksStreamListener::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsAutoString trueStr; trueStr.AssignWithConversion("true"); @@ -276,7 +276,7 @@ RelatedLinksStreamListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt NS_IMETHODIMP -RelatedLinksStreamListener::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +RelatedLinksStreamListener::OnDataAvailable(nsIRequest *request, 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 f1a212a8e26..8dd6c286f48 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -632,8 +632,7 @@ InternetSearchDataSource::FireTimer(nsITimer* aTimer, void* aClosure) { httpChannel->SetRequestMethod(headAtom); } - - if (NS_SUCCEEDED(rv = channel->AsyncRead(search, engineContext))) + if (NS_SUCCEEDED(rv = channel->AsyncOpen(search, engineContext))) { search->busySchedule = PR_TRUE; @@ -2202,8 +2201,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->AsyncRead(this, engineContext))) + + if (NS_FAILED(rv = engineChannel->AsyncOpen(this, engineContext))) return(rv); // download icon @@ -2222,8 +2221,7 @@ 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->AsyncRead(this, iconContext))) + if (NS_FAILED(rv = iconChannel->AsyncOpen(this, iconContext))) return(rv); } return(NS_OK); @@ -2804,18 +2802,18 @@ InternetSearchDataSource::Stop() // cancel any outstanding connections if (mLoadGroup) { - nsCOMPtr channels; - if (NS_SUCCEEDED(rv = mLoadGroup->GetChannels(getter_AddRefs(channels)))) + nsCOMPtr requests; + if (NS_SUCCEEDED(rv = mLoadGroup->GetRequests(getter_AddRefs(requests)))) { PRBool more; - while (NS_SUCCEEDED(rv = channels->HasMoreElements(&more)) && (more == PR_TRUE)) + while (NS_SUCCEEDED(rv = requests->HasMoreElements(&more)) && (more == PR_TRUE)) { nsCOMPtr isupports; - if (NS_FAILED(rv = channels->GetNext(getter_AddRefs(isupports)))) + if (NS_FAILED(rv = requests->GetNext(getter_AddRefs(isupports)))) break; - nsCOMPtr channel = do_QueryInterface(isupports); - if (!channel) continue; - channel->Cancel(NS_BINDING_ABORTED); + nsCOMPtr request = do_QueryInterface(isupports); + if (!request) continue; + request->Cancel(NS_BINDING_ABORTED); } } mLoadGroup->Cancel(NS_BINDING_ABORTED); @@ -3566,7 +3564,8 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin } } - if (NS_SUCCEEDED(rv = channel->AsyncRead(this, context))) + nsCOMPtr request; + if (NS_SUCCEEDED(rv = channel->AsyncOpen(this, context))) { } } @@ -4290,7 +4289,7 @@ InternetSearchDataSource::GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult NS_IMETHODIMP -InternetSearchDataSource::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +InternetSearchDataSource::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { #ifdef DEBUG_SEARCH_OUTPUT printf("InternetSearchDataSourceCallback::OnStartRequest entered.\n"); @@ -4301,7 +4300,7 @@ InternetSearchDataSource::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) NS_IMETHODIMP -InternetSearchDataSource::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +InternetSearchDataSource::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *aIStream, PRUint32 sourceOffset, PRUint32 aLength) { if (!ctxt) return(NS_ERROR_NO_INTERFACE); @@ -4394,11 +4393,13 @@ InternetSearchDataSource::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt NS_IMETHODIMP -InternetSearchDataSource::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +InternetSearchDataSource::OnStopRequest(nsIRequest *request, 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 dbe656395bb..a08eab1f153 100644 --- a/mozilla/xpfe/components/ucth/public/nsIUnkContentTypeHandler.idl +++ b/mozilla/xpfe/components/ucth/public/nsIUnkContentTypeHandler.idl @@ -24,6 +24,8 @@ #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 | @@ -43,7 +45,7 @@ [scriptable, uuid(a6cf90ef-15b3-11d2-932e-00805f8add32)] interface nsIUnknownContentTypeHandler : nsIAppShellComponent { - void HandleUnknownContentType( in nsIChannel aURL, + void HandleUnknownContentType( in nsIRequest request, 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 f55fc2edf31..843e94555a1 100644 --- a/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp +++ b/mozilla/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp @@ -87,15 +87,20 @@ 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( nsIChannel *aChannel, +nsUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request, const char *aContentType, nsIDOMWindowInternal *aWindow ) { nsresult rv = NS_OK; + nsCOMPtr aChannel; nsCOMPtr channel; nsCAutoString contentDisp; + + + if ( request ) { + + aChannel = do_QueryInterface(request); - if ( aChannel ) { // Need root nsISupports for later JS_PushArguments call. channel = do_QueryInterface( aChannel ); @@ -103,7 +108,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIChannel *aChannel, nsCOMPtr httpChannel = do_QueryInterface( aChannel ); if ( httpChannel ) { // Get content-disposition response header. - nsCOMPtr atom = NS_NewAtom( "content-disposition" ); + nsCOMPtr atom = dont_AddRef(NS_NewAtom( "content-disposition" )); if ( atom ) { nsXPIDLCString disp; rv = httpChannel->GetResponseHeader( atom, getter_Copies( disp ) ); @@ -114,7 +119,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIChannel *aChannel, } // Cancel input channel now. - rv = aChannel->Cancel(NS_BINDING_ABORTED); + rv = request->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 2c82e0328c1..5ad21e898e1 100644 --- a/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp +++ b/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp @@ -80,10 +80,15 @@ 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 b75f8de9516..fc02caaa5a6 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 ), - mOutputChannel( 0 ), + mOutputTransport( 0 ), mOutputStream( 0 ), mOutputFile( target ), mObserver( 0 ), @@ -168,22 +168,23 @@ nsStreamXferOp::Start( void ) { nsresult rv = NS_OK; if ( mInputChannel ) { - if ( !mOutputChannel ) { + if ( !mOutputTransport ) { // 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( mOutputChannel ) ); + getter_AddRefs( mOutputTransport ) ); if ( NS_SUCCEEDED( rv ) ) { #ifdef USE_ASYNC_READ // Read the input channel (with ourself as the listener). - rv = mInputChannel->AsyncRead(this, nsnull); + rv = mInputChannel->AsyncOpen(this, nsnull); if ( NS_FAILED( rv ) ) { this->OnError( kOpAsyncRead, rv ); } @@ -198,7 +199,7 @@ nsStreamXferOp::Start( void ) { // get the input stream from the channel. nsCOMPtr inStream; - rv = mInputChannel->OpenInputStream(getter_AddRefs(inStream)); + rv = mInputChannel->Open(getter_AddRefs(inStream)); if (NS_FAILED(rv)) { this->OnError(0, rv); return rv; @@ -206,7 +207,10 @@ 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. - rv = NS_AsyncWriteFromStream(mOutputChannel, inStream, NS_STATIC_CAST(nsIStreamObserver*,this), nsnull); + nsCOMPtr dummyRequest; + rv = NS_AsyncWriteFromStream(getter_AddRefs(dummyRequest), + mOutputTransport, inStream, 0, -1, 0, + NS_STATIC_CAST(nsIStreamObserver*, this)); if ( NS_FAILED( rv ) ) { this->OnError( kOpAsyncWrite, rv ); } @@ -246,7 +250,8 @@ nsStreamXferOp::Stop( void ) { nsCOMPtr channel = mInputChannel; mInputChannel = 0; // Now cancel it. - rv = channel->Cancel(NS_BINDING_ABORTED); + if (channel) + rv = channel->Cancel(NS_BINDING_ABORTED); if ( NS_FAILED( rv ) ) { this->OnError( kOpInputCancel, rv ); } @@ -266,7 +271,7 @@ nsStreamXferOp::Stop( void ) { } // Cancel output channel. - mOutputChannel = 0; + mOutputTransport = 0; return rv; } @@ -275,13 +280,19 @@ nsStreamXferOp::Stop( void ) { // // We also open the output stream at this point. NS_IMETHODIMP -nsStreamXferOp::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { - nsresult rv = NS_ERROR_FAILURE; +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 #ifdef USE_ASYNC_READ if ( !mOutputStream ) { // Open output stream. - rv = mOutputChannel->OpenOutputStream( getter_AddRefs( mOutputStream ) ); + rv = mOutputTransport->OpenOutputStream(0,-1,0,getter_AddRefs( mOutputStream ) ); + if ( NS_FAILED( rv ) ) { // Give up all hope. this->OnError( kOpOpenOutputStream, rv ); @@ -296,7 +307,7 @@ nsStreamXferOp::OnStartRequest(nsIChannel* channel, nsISupports* aContext) { #ifdef USE_ASYNC_READ // Process the data by writing it to the output channel. NS_IMETHODIMP -nsStreamXferOp::OnDataAvailable( nsIChannel *channel, +nsStreamXferOp::OnDataAvailable( nsIRequest* request, nsISupports *aContext, nsIInputStream *aIStream, PRUint32 offset, @@ -359,11 +370,13 @@ nsStreamXferOp::OnDataAvailable( nsIChannel *channel, } else { // Fake OnProgress. mBytesProcessed += aLength; - if ( mContentLength == 0 && channel ) { + if ( mContentLength == 0 && request ) { // Get content length from input channel. + nsCOMPtr channel = do_QueryInterface(request); + if (!channel) return NS_ERROR_FAILURE; channel->GetContentLength( &mContentLength ); } - this->OnProgress( mOutputChannel, 0, mBytesProcessed, mContentLength ); + this->OnProgress( request, 0, mBytesProcessed, mContentLength ); } return rv; @@ -383,12 +396,14 @@ nsStreamXferOp::GetInterface(const nsIID &anIID, void **aResult ) { // expected. // NS_IMETHODIMP -nsStreamXferOp::OnProgress(nsIChannel* channel, nsISupports* aContext, +nsStreamXferOp::OnProgress(nsIRequest *request, nsISupports* aContext, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; if (mContentLength < 1) { - NS_ASSERTION(channel, "should have a channel"); + NS_ASSERTION(request, "should have a request"); + nsCOMPtr channel = do_QueryInterface(request); + if (!channel) return NS_ERROR_FAILURE; rv = channel->GetContentLength(&mContentLength); if (NS_FAILED(rv)) return rv; } @@ -412,7 +427,7 @@ nsStreamXferOp::OnProgress(nsIChannel* channel, nsISupports* aContext, // "subject", the topic is the component contractid (plus ";onStatus"), and // the data is the status text. NS_IMETHODIMP -nsStreamXferOp::OnStatus( nsIChannel *channel, +nsStreamXferOp::OnStatus( nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar *aStatusArg) { @@ -439,7 +454,7 @@ nsStreamXferOp::OnStatus( nsIChannel *channel, // This is called when the end of input is reached on the input channel. NS_IMETHODIMP -nsStreamXferOp::OnStopRequest( nsIChannel *channel, +nsStreamXferOp::OnStopRequest( nsIRequest *request, nsISupports *aContext, nsresult aStatus, const PRUnichar *aMsg ) { @@ -462,7 +477,7 @@ nsStreamXferOp::OnStopRequest( nsIChannel *channel, // Unhook input/output channels (don't need to cancel 'em). mInputChannel = 0; - mOutputChannel = 0; + mOutputTransport = 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 61d0ad0c4f9..5f93815573a 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 mOutputChannel; + nsCOMPtr mOutputTransport; 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 0e5797e8c14..8e937b1f159 100644 --- a/mozilla/xpinstall/src/nsInstallTrigger.cpp +++ b/mozilla/xpinstall/src/nsInstallTrigger.cpp @@ -110,13 +110,14 @@ nsInstallTrigger::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports* aWindowContext, - nsIChannel * aChannel) + nsIRequest* request) { nsresult rv = NS_OK; - if (!aChannel) return NS_ERROR_NULL_POINTER; + if (!request) 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 32f23a902a5..79e2fbb9b06 100644 --- a/mozilla/xpinstall/src/nsXPInstallManager.cpp +++ b/mozilla/xpinstall/src/nsXPInstallManager.cpp @@ -32,6 +32,7 @@ #include "nsIURL.h" +#include "nsITransport.h" #include "nsIFileTransportService.h" #include "nsIOutputStream.h" #include "nsNetUtil.h" @@ -455,7 +456,7 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext() if (NS_SUCCEEDED(rv)) { - rv = channel->AsyncRead(this, nsnull); + rv = channel->AsyncOpen(this, nsnull); } } } @@ -692,7 +693,7 @@ nsXPInstallManager::GetDestinationFile(nsString& url, nsILocalFile* *file) NS_IMETHODIMP -nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) +nsXPInstallManager::OnStartRequest(nsIRequest* request, nsISupports *ctxt) { nsresult rv = NS_ERROR_FAILURE; @@ -706,7 +707,7 @@ nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) if (NS_SUCCEEDED(rv) && !mItem->mOutStream) { - nsCOMPtr outChannel; + nsCOMPtr outChannel; rv = fts->CreateTransport(mItem->mFile, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, @@ -716,7 +717,7 @@ nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) if (NS_SUCCEEDED(rv)) { // Open output stream. - rv = outChannel->OpenOutputStream( getter_AddRefs( mItem->mOutStream ) ); + rv = outChannel->OpenOutputStream(0, -1, 0, getter_AddRefs( mItem->mOutStream ) ); } } } @@ -724,7 +725,7 @@ nsXPInstallManager::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) } NS_IMETHODIMP -nsXPInstallManager::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, +nsXPInstallManager::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { nsresult rv; @@ -780,7 +781,7 @@ nsXPInstallManager::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, NS_IMETHODIMP -nsXPInstallManager::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, +nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *pIStream, PRUint32 sourceOffset, PRUint32 length) @@ -820,7 +821,7 @@ nsXPInstallManager::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, } NS_IMETHODIMP -nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) +nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; @@ -828,6 +829,7 @@ nsXPInstallManager::OnProgress(nsIChannel *channel, 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 +842,7 @@ nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 } NS_IMETHODIMP -nsXPInstallManager::OnStatus(nsIChannel *channel, nsISupports *ctxt, +nsXPInstallManager::OnStatus(nsIRequest* request, nsISupports *ctxt, nsresult aStatus, const PRUnichar *aStatusArg) { nsresult rv;