42767. AsyncOpen (dead code) removal.

This commit is contained in:
valeski%netscape.com 2000-06-16 14:39:19 +00:00
Родитель 121e558454
Коммит c9ce86137e
28 изменённых файлов: 162 добавлений и 583 удалений

Просмотреть файл

@ -221,13 +221,6 @@ nsCachedChromeChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports *ctxt)
{
NS_NOTREACHED("don't do that");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{

Просмотреть файл

@ -479,21 +479,6 @@ nsLDAPChannel::OpenOutputStream(nsIOutputStream* *result)
return NS_ERROR_NOT_IMPLEMENTED;
}
// Opens the channel asynchronously. The nsIStreamObserver's OnStartRequest
// method is called back when the channel actually becomes open, providing
// the content type. Its OnStopRequest method is called when the channel
// becomes closed.
//
// void asyncOpen(in nsIStreamObserver observer,
// in nsISupports ctxt);
NS_IMETHODIMP
nsLDAPChannel::AsyncOpen(nsIStreamObserver* observer,
nsISupports* ctxt)
{
NS_NOTYETIMPLEMENTED("nsLDAPChannel::AsyncOpen");
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.

Просмотреть файл

@ -173,24 +173,6 @@ nsDateTimeChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);
if (NS_FAILED(rv)) return rv;
return channel->AsyncOpen(observer, ctxt);
}
NS_IMETHODIMP
nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener,
nsISupports *ctxt)

Просмотреть файл

@ -219,12 +219,6 @@ nsFingerChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt)
{

Просмотреть файл

@ -367,13 +367,6 @@ NS_IMETHODIMP nsMsgProtocol::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgProtocol::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
// we already know the content type...
observer->OnStartRequest(this, ctxt);
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
// set the stream listener and then load the url

Просмотреть файл

@ -340,13 +340,6 @@ NS_IMETHODIMP nsMailtoChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMailtoChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
// we already know the content type...
observer->OnStartRequest(this, ctxt);
return NS_OK;
}
NS_IMETHODIMP nsMailtoChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
return listener->OnStartRequest(this, ctxt);

Просмотреть файл

@ -6617,13 +6617,6 @@ NS_IMETHODIMP nsImapMockChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsImapMockChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
// we already know the content type...
observer->OnStartRequest(this, ctxt);
return NS_OK;
}
NS_IMETHODIMP nsImapMockChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
nsCOMPtr<nsICachedNetData> cacheEntry;

Просмотреть файл

@ -348,13 +348,6 @@ nsJARChannel::OpenOutputStream(nsIOutputStream* *result)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsJARChannel::AsyncOpen(nsIStreamObserver* observer, nsISupports* ctxt)
{
NS_NOTREACHED("nsJARChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
static nsresult
ReadJARElement(nsJARChannel* jarChannel, void* closure)
{

Просмотреть файл

@ -298,19 +298,6 @@ interface nsIChannel : nsIRequest
*/
nsIOutputStream openOutputStream();
/**
* !!WARNING!!: this interface method has become obsolete....I don't believe
* anyone actually implements this anymore. Just go ahead and call AsyncRead
* directly.
*
* Opens the channel asynchronously. The nsIStreamObserver's OnStartRequest
* method is called back when the channel actually becomes open, providing
* the content type. Its OnStopRequest method is called when the channel
* becomes closed.
*/
void asyncOpen(in nsIStreamObserver observer,
in nsISupports ctxt);
/**
* Reads asynchronously from the URL's specified source. Notifications
* are provided to the stream listener on the thread of the specified

Просмотреть файл

@ -355,39 +355,6 @@ nsFileTransport::OpenOutputStream(nsIOutputStream **result)
#endif
}
NS_IMETHODIMP
nsFileTransport::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
nsAutoMonitor mon(mMonitor);
nsresult rv = NS_OK;
if (mState != CLOSED)
return NS_ERROR_IN_PROGRESS;
NS_ASSERTION(observer, "need to supply an nsIStreamObserver");
rv = NS_NewAsyncStreamObserver(getter_AddRefs(mOpenObserver),
observer, NS_CURRENT_EVENTQ);
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(mOpenContext == nsnull, "context not released");
mOpenContext = ctxt;
mState = OPENING;
NS_ASSERTION(mCommand == NONE, "out of sync");
PR_LOG(gFileTransportLog, PR_LOG_DEBUG,
("nsFileTransport: AsyncOpen [this=%x %s]",
this, mStreamName.GetBuffer()));
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->DispatchRequest(this);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
NS_IMETHODIMP
nsFileTransport::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
@ -509,9 +476,6 @@ nsFileTransport::Process(void)
("nsFileTransport: OPENING [this=%x %s]",
this, mStreamName.GetBuffer()));
mStatus = mStreamIO->Open(&mContentType, &mTotalAmount);
if (mOpenObserver) {
mStatus = mOpenObserver->OnStartRequest(this, mOpenContext);
}
switch (mCommand) {
case INITIATE_READ:
mState = NS_FAILED(mStatus) ? END_READ : START_READ;
@ -849,12 +813,6 @@ nsFileTransport::DoClose(void)
("nsFileTransport: CLOSING [this=%x %s] status=%x",
this, mStreamName.GetBuffer(), mStatus));
if (mOpenObserver) {
(void)mOpenObserver->OnStopRequest(this, mOpenContext,
mStatus, nsnull); // XXX fix error message
mOpenObserver = null_nsCOMPtr();
mOpenContext = null_nsCOMPtr();
}
if (mStreamIO) {
nsresult rv = mStreamIO->Close(mStatus);
NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected Close failure");

Просмотреть файл

@ -101,9 +101,6 @@ protected:
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
nsCOMPtr<nsIStreamObserver> mOpenObserver;
nsCOMPtr<nsISupports> mOpenContext;
nsCOMPtr<nsISupports> mContext;
State mState;
Command mCommand;

Просмотреть файл

@ -256,30 +256,6 @@ nsStreamIOChannel::SetURI(nsIURI* aURI)
return NS_OK;
}
NS_IMETHODIMP
nsStreamIOChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
if (mFileTransport)
return NS_ERROR_IN_PROGRESS;
nsresult rv;
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransportFromStreamIO(mStreamIO, getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) return rv;
if (mBufferSegmentSize > 0) {
rv = mFileTransport->SetBufferSegmentSize(mBufferSegmentSize);
if (NS_FAILED(rv)) return rv;
}
if (mBufferMaxSize > 0) {
rv = mFileTransport->SetBufferMaxSize(mBufferMaxSize);
if (NS_FAILED(rv)) return rv;
}
return mFileTransport->AsyncOpen(observer, ctxt);
}
NS_IMETHODIMP
nsStreamIOChannel::OpenInputStream(nsIInputStream **result)
{

Просмотреть файл

@ -572,14 +572,6 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags)
case eSocketState_WaitConnect:
mStatus = doConnection(aSelectFlags);
if (NS_SUCCEEDED(mStatus) && mOpenObserver) {
mOpenObserver->OnStartRequest(this, mOpenContext);
NS_ASSERTION(mOperation == eSocketOperation_Connect, "bad state");
mCurrentState = gStateTable[mOperation][mCurrentState];
mOperation = eSocketOperation_None;
done = PR_TRUE;
continue;
}
break;
case eSocketState_WaitReadWrite:
@ -1311,16 +1303,6 @@ nsresult nsSocketTransport::CloseConnection (PRBool bNow)
if (NS_SUCCEEDED(rv))
mCurrentState = eSocketState_Closed;
if (mOpenObserver)
{
nsresult rv2 = mOpenObserver -> OnStopRequest (this, mOpenContext, rv, nsnull); // XXX need error message
if (NS_SUCCEEDED(rv))
rv = rv2;
mOpenObserver = null_nsCOMPtr ();
mOpenContext = null_nsCOMPtr ();
}
return rv;
}
@ -1776,47 +1758,6 @@ nsSocketTransport::SetURI(nsIURI* aURL)
return SetOriginalURI(aURL);
}
NS_IMETHODIMP
nsSocketTransport::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
nsresult rv = NS_OK;
// Enter the socket transport lock...
nsAutoMonitor mon(mMonitor);
PR_LOG(gSocketLog, PR_LOG_DEBUG,
("+++ Entering nsSocketTransport::AsyncOpen() [%s:%d %x]\n",
mHostName, mPort, this));
// If a read is already in progress then fail...
if (GetReadType() != eSocketRead_None) {
rv = NS_ERROR_IN_PROGRESS;
}
// Create a marshalling open observer to receive notifications...
if (NS_SUCCEEDED(rv)) {
rv = NS_NewAsyncStreamObserver(getter_AddRefs(mOpenObserver),
observer, NS_CURRENT_EVENTQ);
}
if (NS_SUCCEEDED(rv)) {
// Store the context used for this read...
mOpenContext = ctxt;
mOperation = eSocketOperation_Connect;
SetReadType(eSocketRead_None);
mLastActiveTime = PR_IntervalNow ();
rv = mService->AddToWorkQ(this);
}
PR_LOG(gSocketLog, PR_LOG_DEBUG,
("--- Leaving nsSocketTransport::AsyncOpen() [%s:%d %x]. rv = %x.\n",
mHostName, mPort, this, rv));
return rv;
}
NS_IMETHODIMP
nsSocketTransport::AsyncRead(nsIStreamListener* aListener,
nsISupports* aContext)

Просмотреть файл

@ -217,8 +217,6 @@ protected:
PRUint32 mLoadAttributes;
PRMonitor* mMonitor;
PRNetAddr mNetAddress;
nsCOMPtr<nsISupports> mOpenContext;
nsCOMPtr<nsIStreamObserver> mOpenObserver;
nsSocketOperation mOperation;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsISupports> mSecurityInfo;

Просмотреть файл

@ -316,14 +316,6 @@ nsDiskCacheRecordChannel::OpenOutputStream(nsIOutputStream* *aResult)
return WriteStreamWrapper::Create(this, outputStream, aResult);
}
NS_IMETHODIMP
nsDiskCacheRecordChannel::AsyncOpen(nsIStreamObserver *observer,
nsISupports *ctxt)
{
NS_NOTREACHED("nsDiskCacheRecordChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDiskCacheRecordChannel::AsyncRead(nsIStreamListener *aListener,
nsISupports *aContext)

Просмотреть файл

@ -445,14 +445,6 @@ nsMemCacheChannel::OpenOutputStream(nsIOutputStream* *aResult)
return MemCacheWriteStreamWrapper::Create(this, outputStream, aResult);
}
NS_IMETHODIMP
nsMemCacheChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports *ctxt)
{
// Not required
NS_NOTREACHED("nsMemCacheChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMemCacheChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *aContext)
{

Просмотреть файл

@ -315,13 +315,6 @@ nsDataChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDataChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
NS_NOTREACHED("nsDataChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDataChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt)
{

Просмотреть файл

@ -173,24 +173,6 @@ nsDateTimeChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsISocketTransportService, socketService, kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = socketService->CreateTransport(mHost, mPort, nsnull, 0, 32, 32, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->SetNotificationCallbacks(mCallbacks);
if (NS_FAILED(rv)) return rv;
return channel->AsyncOpen(observer, ctxt);
}
NS_IMETHODIMP
nsDateTimeChannel::AsyncRead(nsIStreamListener *aListener,
nsISupports *ctxt)

Просмотреть файл

@ -280,13 +280,6 @@ nsFileChannel::OpenOutputStream(nsIOutputStream **result)
return rv;
}
NS_IMETHODIMP
nsFileChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
NS_NOTREACHED("nsFileChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFileChannel::AsyncRead(nsIStreamListener *listener,
nsISupports *ctxt)

Просмотреть файл

@ -219,12 +219,6 @@ nsFingerChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::AsyncRead(nsIStreamListener *aListener, nsISupports *ctxt)
{

Просмотреть файл

@ -281,13 +281,6 @@ nsFTPChannel::OpenOutputStream(nsIOutputStream **result)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFTPChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
NS_NOTREACHED("nsFTPChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{

Просмотреть файл

@ -185,11 +185,6 @@ nsHTTPChannel::Cancel(nsresult status)
fl -> FireNotifications ();
}
if (mOpenObserver && !mFiredOpenOnStopRequest)
{
mFiredOpenOnStopRequest = PR_TRUE;
mOpenObserver->OnStopRequest(this, mOpenContext, status, nsnull);
}
return rv;
}
@ -273,24 +268,6 @@ nsHTTPChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHTTPChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
{
nsresult rv = NS_OK;
// parameter validation
if (!observer) return NS_ERROR_NULL_POINTER;
if (mResponseDataListener) {
rv = NS_ERROR_IN_PROGRESS;
}
mOpenObserver = observer;
mOpenContext = ctxt;
return Open();
}
NS_IMETHODIMP
nsHTTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *aContext)
{
@ -311,22 +288,13 @@ nsHTTPChannel::AsyncRead(nsIStreamListener *listener, nsISupports *aContext)
mResponseContext = aContext;
if (!mOpenObserver)
Open();
Open();
// If the data in the cache hasn't expired, then there's no need to talk
// with the server. Create a stream from the cache, synthesizing all the
// various channel-related events.
if (mCachedContentIsValid) {
ReadFromCache();
} else if (mOpenObserver) {
// we were AsyncOpen()'d
NS_ASSERTION(mHTTPServerListener, "ResponseListener was not set!.");
if (mHTTPServerListener) {
rv = mHTTPServerListener->FireSingleOnData(listener, aContext);
} else {
rv = NS_ERROR_NULL_POINTER;
}
}
return rv;
@ -1297,10 +1265,7 @@ nsHTTPChannel::Open(PRBool bIgnoreCache)
// The channel is being restarted by the HTTP protocol handler
// and the cache data is usable, so start pumping the data from
// the cache...
if (!mOpenObserver) {
rv = ReadFromCache();
}
return NS_OK;
return ReadFromCache();
}
}
@ -1611,7 +1576,6 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation,
// for the original URL...
//
mResponseDataListener = 0;
mOpenObserver = 0;
*aResult = channel;
NS_ADDREF(*aResult);
@ -1677,14 +1641,6 @@ nsresult nsHTTPChannel::ResponseCompleted(
if (mLoadGroup)
mLoadGroup->RemoveChannel(this, nsnull, aStatus, nsnull);
//
// Finally, notify the OpenObserver that the request has completed.
//
if (mOpenObserver && !mFiredOpenOnStopRequest)
{
mFiredOpenOnStopRequest = PR_TRUE;
mOpenObserver->OnStopRequest(this, mOpenContext, aStatus, aMsg);
}
// Null out pointers that are no longer needed...
@ -1734,7 +1690,6 @@ nsresult nsHTTPChannel::Abort()
// for the original URL...
//
mResponseDataListener = 0;
mOpenObserver = 0;
return NS_OK;
}
@ -1967,17 +1922,6 @@ nsHTTPChannel::FinishedResponseHeaders(void)
("nsHTTPChannel::FinishedResponseHeaders [this=%x].\n",
this));
if (mOpenObserver && !mFiredOpenOnStartRequest) {
rv = mOpenObserver->OnStartRequest(this, mOpenContext);
mFiredOpenOnStartRequest = PR_TRUE;
// We want to defer header completion notification until the
// caller actually does an AsyncRead();
if (!mResponseDataListener)
return rv;
}
// Notify the consumer that headers are available...
OnHeadersAvailable();
mFiredOnHeadersAvailable = PR_TRUE;

Просмотреть файл

@ -125,8 +125,6 @@ protected:
public:
nsHTTPResponse* mResponse;
nsCOMPtr<nsIStreamObserver> mOpenObserver;
nsCOMPtr<nsISupports> mOpenContext;
nsHTTPHandler* mHandler;
nsHTTPRequest* mRequest;

Просмотреть файл

@ -436,197 +436,186 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel,
// an AsyncRead, we just want to pass the OnData() notifications
// straight through to the consumer.
//
// .... otherwise...
if (mSimpleResponse && mHeaderBuffer.Length ())
{
const char * cp = mHeaderBuffer.GetBuffer ();
nsCOMPtr<nsIByteArrayInputStream> is;
nsresult rv1 =
NS_NewByteArrayInputStream (getter_AddRefs (is), strdup (cp), mHeaderBuffer.Length ());
if (NS_SUCCEEDED (rv1))
mResponseDataListener -> OnDataAvailable (mChannel,
mChannel -> mResponseContext, is, 0, mHeaderBuffer.Length ());
mSimpleResponse = PR_FALSE;
}
//
// if we were AsyncOpened, we want to increment our internal byte count
// so when we finally push the stream to the consumer via AsyncRead,
// we're sure to pass him all the data that has queued up.
// Abort the connection if the consumer has been released. This will
// happen if a redirect has been processed...
//
if (!mResponseDataListener) {
// XXX: What should the return code be?
rv = NS_BINDING_ABORTED;
}
if (mChannel->mOpenObserver && !mResponseDataListener) {
mBytesReceived += i_Length;
mDataStream = i_pStream;
} else {
if (NS_SUCCEEDED(rv)) {
if (i_Length) {
if (mSimpleResponse && mHeaderBuffer.Length ())
{
if (!mCompressHeaderChecked)
{
nsXPIDLCString compressHeader;
rv = mResponse -> GetHeader (nsHTTPAtoms::Content_Encoding, getter_Copies (compressHeader));
mCompressHeaderChecked = PR_TRUE;
const char * cp = mHeaderBuffer.GetBuffer ();
nsCOMPtr<nsIByteArrayInputStream> is;
nsresult rv1 =
NS_NewByteArrayInputStream (getter_AddRefs (is), strdup (cp), mHeaderBuffer.Length ());
if (NS_SUCCEEDED (rv1))
mResponseDataListener -> OnDataAvailable (mChannel,
mChannel -> mResponseContext, is, 0, mHeaderBuffer.Length ());
mSimpleResponse = PR_FALSE;
}
//
// Abort the connection if the consumer has been released. This will
// happen if a redirect has been processed...
//
if (!mResponseDataListener) {
// XXX: What should the return code be?
rv = NS_BINDING_ABORTED;
}
if (NS_SUCCEEDED(rv)) {
if (i_Length) {
if (!mCompressHeaderChecked)
if (NS_SUCCEEDED (rv) && compressHeader)
{
nsXPIDLCString compressHeader;
rv = mResponse -> GetHeader (nsHTTPAtoms::Content_Encoding, getter_Copies (compressHeader));
mCompressHeaderChecked = PR_TRUE;
NS_WITH_SERVICE (nsIStreamConverterService,
StreamConvService, kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (NS_SUCCEEDED (rv) && compressHeader)
nsString fromStr; fromStr.AssignWithConversion ( compressHeader );
nsString toStr; toStr.AssignWithConversion ( "uncompressed" );
nsCOMPtr<nsIStreamListener> converterListener;
rv = StreamConvService->AsyncConvertData(
fromStr.GetUnicode(),
toStr.GetUnicode(),
mResponseDataListener,
channel,
getter_AddRefs (converterListener));
if (NS_FAILED(rv)) return rv;
mResponseDataListener = converterListener;
}
}
if (!mChunkHeaderChecked)
{
mChunkHeaderChecked = PR_TRUE;
nsXPIDLCString chunkHeader;
rv = mResponse -> GetHeader (nsHTTPAtoms::Transfer_Encoding, getter_Copies (chunkHeader));
nsXPIDLCString trailerHeader;
rv = mResponse -> GetHeader (nsHTTPAtoms::Trailer, getter_Copies (trailerHeader));
if (NS_SUCCEEDED (rv) && chunkHeader)
{
NS_WITH_SERVICE (nsIStreamConverterService,
StreamConvService, kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsString fromStr; fromStr.AssignWithConversion ( chunkHeader );
nsString toStr; toStr.AssignWithConversion ( "unchunked" );
mChunkHeaderCtx.SetEOF (PR_FALSE);
if (trailerHeader)
{
NS_WITH_SERVICE (nsIStreamConverterService,
StreamConvService, kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCString ts (trailerHeader);
ts.StripWhitespace ();
nsString fromStr; fromStr.AssignWithConversion ( compressHeader );
nsString toStr; toStr.AssignWithConversion ( "uncompressed" );
nsCOMPtr<nsIStreamListener> converterListener;
rv = StreamConvService->AsyncConvertData(
fromStr.GetUnicode(),
toStr.GetUnicode(),
mResponseDataListener,
channel,
getter_AddRefs (converterListener));
if (NS_FAILED(rv)) return rv;
mResponseDataListener = converterListener;
char *cp = ts;
while (*cp)
{
char * pp = PL_strchr (cp , ',');
if (pp == NULL)
{
mChunkHeaderCtx.AddTrailerHeader (cp);
break;
}
else
{
*pp = 0;
mChunkHeaderCtx.AddTrailerHeader (cp);
*pp = ',';
cp = pp + 1;
}
}
}
nsCOMPtr<nsIStreamListener> converterListener;
rv = StreamConvService->AsyncConvertData(
fromStr.GetUnicode(),
toStr.GetUnicode(),
mResponseDataListener,
mChunkHeaderEOF,
getter_AddRefs (converterListener));
if (NS_FAILED(rv)) return rv;
mResponseDataListener = converterListener;
}
}
rv = mResponseDataListener -> OnDataAvailable (mChannel, mChannel -> mResponseContext, i_pStream, 0, i_Length);
PRInt32 cl = -1;
mResponse -> GetContentLength (&cl);
mBodyBytesReceived += i_Length;
// Report progress
rv = mChannel->ReportProgress(mBodyBytesReceived, cl);
if (NS_FAILED(rv)) return rv;
PRBool eof = mChunkHeaderCtx.GetEOF ();
if (mPipelinedRequest
&& (cl != -1 && cl - mBodyBytesReceived == 0 || eof))
{
if (eof && mResponse)
{
nsVoidArray *mh = mChunkHeaderCtx.GetAllHeaders ();
for (int i = mh -> Count () - 1; i >= 0; i--)
{
nsHTTPChunkConvHeaderEntry *he = (nsHTTPChunkConvHeaderEntry *) mh -> ElementAt (i);
if (he)
{
nsCOMPtr<nsIAtom> hAtom = dont_AddRef (NS_NewAtom (he -> mName));
mResponse -> SetHeader (hAtom, he -> mValue);
}
}
}
nsresult rv1 = mPipelinedRequest -> AdvanceToNextRequest ();
if (!mChunkHeaderChecked)
if (NS_FAILED (rv1))
{
mChunkHeaderChecked = PR_TRUE;
nsXPIDLCString chunkHeader;
rv = mResponse -> GetHeader (nsHTTPAtoms::Transfer_Encoding, getter_Copies (chunkHeader));
nsXPIDLCString trailerHeader;
rv = mResponse -> GetHeader (nsHTTPAtoms::Trailer, getter_Copies (trailerHeader));
mHandler -> ReleasePipelinedRequest (mPipelinedRequest);
mPipelinedRequest = nsnull;
if (NS_SUCCEEDED (rv) && chunkHeader)
{
NS_WITH_SERVICE (nsIStreamConverterService,
StreamConvService, kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISocketTransport> trans = do_QueryInterface (channel, &rv1);
nsString fromStr; fromStr.AssignWithConversion ( chunkHeader );
nsString toStr; toStr.AssignWithConversion ( "unchunked" );
// XXX/ruslan: will be replaced with the new Cancel (code)
if (NS_SUCCEEDED (rv1))
trans -> SetBytesExpected (0);
mChunkHeaderCtx.SetEOF (PR_FALSE);
if (trailerHeader)
{
nsCString ts (trailerHeader);
ts.StripWhitespace ();
char *cp = ts;
while (*cp)
{
char * pp = PL_strchr (cp , ',');
if (pp == NULL)
{
mChunkHeaderCtx.AddTrailerHeader (cp);
break;
}
else
{
*pp = 0;
mChunkHeaderCtx.AddTrailerHeader (cp);
*pp = ',';
cp = pp + 1;
}
}
}
nsCOMPtr<nsIStreamListener> converterListener;
rv = StreamConvService->AsyncConvertData(
fromStr.GetUnicode(),
toStr.GetUnicode(),
mResponseDataListener,
mChunkHeaderEOF,
getter_AddRefs (converterListener));
if (NS_FAILED(rv)) return rv;
mResponseDataListener = converterListener;
}
}
rv = mResponseDataListener -> OnDataAvailable (mChannel, mChannel -> mResponseContext, i_pStream, 0, i_Length);
PRInt32 cl = -1;
mResponse -> GetContentLength (&cl);
mBodyBytesReceived += i_Length;
// Report progress
rv = mChannel->ReportProgress(mBodyBytesReceived, cl);
if (NS_FAILED(rv)) return rv;
PRBool eof = mChunkHeaderCtx.GetEOF ();
if (mPipelinedRequest
&& (cl != -1 && cl - mBodyBytesReceived == 0 || eof))
}
else
{
if (eof && mResponse)
PRUint32 status = 0;
if (mResponse)
mResponse -> GetStatus(&status);
if (status != 304 || !mChannel -> mCachedResponse)
{
nsVoidArray *mh = mChunkHeaderCtx.GetAllHeaders ();
for (int i = mh -> Count () - 1; i >= 0; i--)
{
nsHTTPChunkConvHeaderEntry *he = (nsHTTPChunkConvHeaderEntry *) mh -> ElementAt (i);
if (he)
{
nsCOMPtr<nsIAtom> hAtom = dont_AddRef (NS_NewAtom (he -> mName));
mResponse -> SetHeader (hAtom, he -> mValue);
}
}
mChannel -> ResponseCompleted (mResponseDataListener, NS_OK, nsnull);
mChannel -> mHTTPServerListener = 0;
}
nsresult rv1 = mPipelinedRequest -> AdvanceToNextRequest ();
if (NS_FAILED (rv1))
{
mHandler -> ReleasePipelinedRequest (mPipelinedRequest);
mPipelinedRequest = nsnull;
OnStartRequest (nsnull, nsnull);
PRUint32 streamLen = 0;
i_pStream -> Available (&streamLen);
nsCOMPtr<nsISocketTransport> trans = do_QueryInterface (channel, &rv1);
// XXX/ruslan: will be replaced with the new Cancel (code)
if (NS_SUCCEEDED (rv1))
trans -> SetBytesExpected (0);
}
else
{
PRUint32 status = 0;
if (mResponse)
mResponse -> GetStatus(&status);
if (status != 304 || !mChannel -> mCachedResponse)
{
mChannel -> ResponseCompleted (mResponseDataListener, NS_OK, nsnull);
mChannel -> mHTTPServerListener = 0;
}
OnStartRequest (nsnull, nsnull);
PRUint32 streamLen = 0;
i_pStream -> Available (&streamLen);
if (streamLen > 0)
OnDataAvailable (channel, context, i_pStream, 0, streamLen);
}
}
}
}
} // end !mChannel->mOpenObserver
if (streamLen > 0)
OnDataAvailable (channel, context, i_pStream, 0, streamLen);
}
}
}
}
return rv;
}

Просмотреть файл

@ -348,13 +348,6 @@ nsJARChannel::OpenOutputStream(nsIOutputStream* *result)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsJARChannel::AsyncOpen(nsIStreamObserver* observer, nsISupports* ctxt)
{
NS_NOTREACHED("nsJARChannel::AsyncOpen");
return NS_ERROR_NOT_IMPLEMENTED;
}
static nsresult
ReadJARElement(nsJARChannel* jarChannel, void* closure)
{

Просмотреть файл

@ -364,55 +364,6 @@ nsResChannel::OpenOutputStream(nsIOutputStream **result)
return rv;
}
NS_IMETHODIMP
nsResChannel::AsyncOpen(nsIStreamObserver *observer, 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;
mState = ASYNC_OPEN;
break;
case ASYNC_OPEN:
break;
default:
return NS_ERROR_IN_PROGRESS;
}
NS_ASSERTION(mState == ASYNC_OPEN, "wrong state");
mUserObserver = observer;
mUserContext = ctxt;
do {
rv = EnsureNextResolvedChannel();
if (NS_FAILED(rv)) break;
if (mResolvedChannel)
rv = mResolvedChannel->AsyncOpen(this, nsnull);
// Later, this AsyncOpen will call back our OnStopRequest
// method. The action resumes there...
} while (NS_FAILED(rv));
if (NS_FAILED(rv)) {
(void)EndRequest(rv, nsnull); // XXX need error message
}
return rv;
}
NS_IMETHODIMP
nsResChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{
@ -434,10 +385,6 @@ nsResChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
if (NS_FAILED(rv)) return rv;
// fall through
case ASYNC_OPEN:
mState = ASYNC_READ;
// fall through
case ASYNC_READ:
break;
@ -489,10 +436,6 @@ nsResChannel::AsyncWrite(nsIInputStream *fromStream,
if (NS_FAILED(rv)) return rv;
// fall through
case ASYNC_OPEN:
mState = ASYNC_READ;
// fall through
case ASYNC_READ:
break;
@ -743,8 +686,6 @@ nsResChannel::OnStopRequest(nsIChannel* transportChannel, nsISupports* context,
if (NS_FAILED(aStatus) && aStatus != NS_BINDING_ABORTED) {
// if we failed to process this channel, then try the next one:
switch (mState) {
case ASYNC_OPEN:
return AsyncOpen(mUserObserver, mUserContext);
case ASYNC_READ:
return AsyncRead(GetUserListener(), mUserContext);
case ASYNC_WRITE:

Просмотреть файл

@ -77,7 +77,6 @@ protected:
enum State {
QUIESCENT,
ASYNC_OPEN,
ASYNC_READ,
ASYNC_WRITE
};

Просмотреть файл

@ -221,13 +221,6 @@ nsCachedChromeChannel::OpenOutputStream(nsIOutputStream **_retval)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports *ctxt)
{
NS_NOTREACHED("don't do that");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
{