зеркало из https://github.com/mozilla/pjs.git
r=dougt. part of 18007. FTP now notifies the consumer of failures even if the data channel is never used.
This commit is contained in:
Родитель
03421f54cf
Коммит
02f19e060e
|
@ -67,7 +67,7 @@ nsFtpConnectionThread::nsFtpConnectionThread() {
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
// bool init
|
// bool init
|
||||||
mAsyncOpened = mConnected = mResetMode = mList = mRetryPass = mCachedConn = mSentStart = PR_FALSE;
|
mAsyncOpened = mConnected = mResetMode = mList = mRetryPass = mCachedConn = mSentStart = PR_FALSE;
|
||||||
mUsePasv = mBin = mKeepRunning = mAnonymous = PR_TRUE;
|
mFireCallbacks = mUsePasv = mBin = mKeepRunning = mAnonymous = PR_TRUE;
|
||||||
|
|
||||||
mAction = GET;
|
mAction = GET;
|
||||||
mState = FTP_COMMAND_CONNECT;
|
mState = FTP_COMMAND_CONNECT;
|
||||||
|
@ -143,11 +143,18 @@ nsFtpConnectionThread::Process() {
|
||||||
|
|
||||||
// get the output stream so we can write to the server
|
// get the output stream so we can write to the server
|
||||||
rv = mCPipe->OpenOutputStream(0, getter_AddRefs(mCOutStream));
|
rv = mCPipe->OpenOutputStream(0, getter_AddRefs(mCOutStream));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
mInternalError = rv;
|
||||||
|
mState = FTP_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
rv = mCPipe->OpenInputStream(0, -1, getter_AddRefs(mCInStream));
|
rv = mCPipe->OpenInputStream(0, -1, getter_AddRefs(mCInStream));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
mInternalError = rv;
|
||||||
|
mState = FTP_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
// cache this stuff.
|
// cache this stuff.
|
||||||
mConn = new nsConnectionCacheObj(mCPipe, mCInStream, mCOutStream);
|
mConn = new nsConnectionCacheObj(mCPipe, mCInStream, mCOutStream);
|
||||||
if (!mConn) return NS_ERROR_OUT_OF_MEMORY;
|
if (!mConn) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -270,10 +277,7 @@ nsFtpConnectionThread::Process() {
|
||||||
|
|
||||||
case FTP_ERROR:
|
case FTP_ERROR:
|
||||||
{
|
{
|
||||||
// if something went wrong, delete this connection entry and don't
|
if (mConn) delete mConn;
|
||||||
// bother putting it in the cache.
|
|
||||||
NS_ASSERTION(mConn, "we should have created the conn obj upon Init()");
|
|
||||||
delete mConn;
|
|
||||||
|
|
||||||
if (mResponseCode == 421) {
|
if (mResponseCode == 421) {
|
||||||
// The command channel dropped for some reason. Fire it back up.
|
// The command channel dropped for some reason. Fire it back up.
|
||||||
|
@ -1359,7 +1363,7 @@ nsFtpConnectionThread::S_list() {
|
||||||
mDPipe,
|
mDPipe,
|
||||||
mListenerContext);
|
mListenerContext);
|
||||||
if (!event) return NS_ERROR_OUT_OF_MEMORY;
|
if (!event) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
mFireCallbacks = PR_FALSE; // listener callbacks will be handled by the transport.
|
||||||
return event->Fire(mUIEventQ);
|
return event->Fire(mUIEventQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1404,7 +1408,7 @@ nsFtpConnectionThread::S_retr() {
|
||||||
mDPipe,
|
mDPipe,
|
||||||
mListenerContext);
|
mListenerContext);
|
||||||
if (!event) return NS_ERROR_OUT_OF_MEMORY;
|
if (!event) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
mFireCallbacks = PR_FALSE; // listener callbacks will be handled by the transport.
|
||||||
return event->Fire(mUIEventQ);
|
return event->Fire(mUIEventQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1458,7 +1462,7 @@ nsFtpConnectionThread::S_stor() {
|
||||||
mDPipe,
|
mDPipe,
|
||||||
mObserverContext);
|
mObserverContext);
|
||||||
if (!event) return NS_ERROR_OUT_OF_MEMORY;
|
if (!event) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
mFireCallbacks = PR_FALSE; // observer callbacks will be handled by the transport.
|
||||||
return event->Fire(mUIEventQ);
|
return event->Fire(mUIEventQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1934,6 +1938,36 @@ nsFtpConnectionThread::StopProcessing() {
|
||||||
rv = mObserver->OnStopRequest(mChannel, mObserverContext, mInternalError, errorMsg);
|
rv = mObserver->OnStopRequest(mChannel, mObserverContext, mInternalError, errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mFireCallbacks) {
|
||||||
|
// we never got to the point that the transport would be
|
||||||
|
// taking over notifications. we'll handle them our selves.
|
||||||
|
if (mObserver && !mAsyncOpened) {
|
||||||
|
rv = mObserver->OnStartRequest(mChannel, mObserverContext);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = mObserver->OnStopRequest(mChannel, mObserverContext, mInternalError, errorMsg);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mListener) {
|
||||||
|
NS_WITH_SERVICE(nsIProxyObjectManager, pIProxyObjectManager, kProxyObjectManagerCID, &rv);
|
||||||
|
if(NS_FAILED(rv)) return rv;
|
||||||
|
nsCOMPtr<nsIStreamListener> listener;
|
||||||
|
rv = pIProxyObjectManager->GetProxyObject(NS_UI_THREAD_EVENTQ,
|
||||||
|
NS_GET_IID(nsIStreamListener),
|
||||||
|
mListener,
|
||||||
|
PROXY_ASYNC | PROXY_ALWAYS,
|
||||||
|
getter_AddRefs(listener));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = listener->OnStartRequest(mChannel, mListenerContext);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = listener->OnStopRequest(mChannel, mListenerContext, mInternalError, errorMsg);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,9 @@ private:
|
||||||
nsCOMPtr<nsIEventQueue>mUIEventQ;
|
nsCOMPtr<nsIEventQueue>mUIEventQ;
|
||||||
PLEvent *mAsyncReadEvent;
|
PLEvent *mAsyncReadEvent;
|
||||||
nsCOMPtr<nsIInputStream> mWriteStream; // This stream is written to the server.
|
nsCOMPtr<nsIInputStream> mWriteStream; // This stream is written to the server.
|
||||||
PRUint32 mWriteCount; // The amount of data to write to the server.
|
PRUint32 mWriteCount; // The amount of data to write to the server.
|
||||||
PRBool mAsyncOpened; // This is set when the consumer wants AsyncOpen info.
|
PRBool mAsyncOpened; // This is set when the consumer wants AsyncOpen info.
|
||||||
|
PRBool mFireCallbacks; // Fire the listener callbacks.
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NS_FTP_BUFFER_READ_SIZE (8*1024)
|
#define NS_FTP_BUFFER_READ_SIZE (8*1024)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче