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.

The full details of the change on written up in the netlib newsgroup.

r=darin@netscape.com
sr=rpotts@netscape.com
This commit is contained in:
dougt@netscape.com
2001-02-10 00:16:26 +00:00
parent b762af79b0
commit a70fce6f87
218 changed files with 5596 additions and 6769 deletions

View File

@@ -953,7 +953,7 @@ public:
private:
nsresult SetUpCache(nsIURI* aURL);
nsresult SetUpStreamListener(nsIChannel *channel, nsIURI* aURL);
nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL);
nsIURI *mURL;
nsIPluginInstanceOwner *mOwner;
@@ -1014,13 +1014,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)
@@ -1043,7 +1043,7 @@ nsPluginCacheListener::OnDataAvailable(nsIChannel* channel, nsISupports* ctxt,
}
NS_IMETHODIMP
nsPluginCacheListener::OnStopRequest(nsIChannel* channel,
nsPluginCacheListener::OnStopRequest(nsIRequest *request,
nsISupports* aContext,
nsresult aStatus,
const PRUnichar* aMsg)
@@ -1211,10 +1211,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<nsIChannel> channel = do_QueryInterface(request);
if (!channel)
return NS_ERROR_FAILURE;
char* aContentType = nsnull;
rv = channel->GetContentType(&aContentType);
if (NS_FAILED(rv)) return rv;
@@ -1287,14 +1292,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)
@@ -1303,7 +1308,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)
@@ -1311,7 +1316,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,
@@ -1319,6 +1324,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIChannel* channel,
{
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> aURL;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (!channel) return NS_ERROR_FAILURE;
rv = channel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
@@ -1340,7 +1348,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
{
@@ -1353,13 +1361,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<nsIURI> aURL;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (!channel) return NS_ERROR_FAILURE;
rv = channel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
@@ -1367,7 +1377,11 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIChannel* channel,
{
char* urlString;
nsCOMPtr<nsIFile> localFile;
rv = channel->GetLocalFile(getter_AddRefs(localFile));
nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(channel);
if (fileChannel)
rv = fileChannel->GetFile(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv) && localFile)
{
char* pathAndFilename;
@@ -1422,7 +1436,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;
@@ -1454,6 +1468,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel,
nsCOMPtr<nsIHTTPHeaderListener> headerListener =
do_QueryInterface(mPStreamListener);
if (headerListener) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
if (httpChannel) {
ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener);
@@ -1465,6 +1481,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIChannel* channel,
mPluginStreamInfo->SetSeekable(PR_FALSE);
// get Last-Modified header for plugin info
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIHTTPChannel> theHTTPChannel = do_QueryInterface(channel);
if (theHTTPChannel) {
char * lastModified;
@@ -3806,8 +3824,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
}
}
rv = channel->AsyncRead(listenerPeer, nsnull);
rv = channel->AsyncOpen(listenerPeer, nsnull);
}
NS_RELEASE(listenerPeer);