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
This commit is contained in:
@@ -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<nsIInputStream> 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<nsIChannel> dummyChannel;
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsIURI> 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<p>Please stand by... <p>\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;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user