fixes bug 102743 "Crash pressing Back or Forward on O'Reilly website"

r=gagan, sr=rpotts
This commit is contained in:
darin%netscape.com 2001-10-18 10:37:04 +00:00
Родитель 69ba58ac9c
Коммит 1bbb7d1f24
6 изменённых файлов: 44 добавлений и 18 удалений

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

@ -445,6 +445,13 @@ ProxyListener::~ProxyListener()
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
NS_IMETHODIMP ProxyListener::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt)
{
// if the request has been redirected, then we'll get another pair
// of OnStartRequest/OnStopRequest from the new request.
nsresult status = 0;
aRequest->GetStatus(&status);
if (status == NS_BINDING_REDIRECTED)
return NS_OK;
if (!mDestListener)
return NS_ERROR_FAILURE;
@ -483,6 +490,11 @@ NS_IMETHODIMP ProxyListener::OnStartRequest(nsIRequest *aRequest, nsISupports *c
/* void onStopRequest (in nsIRequest request, in nsISupports ctxt, in nsresult status); */
NS_IMETHODIMP ProxyListener::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt, nsresult status)
{
// if the request has been redirected, then we'll get another pair
// of OnStartRequest/OnStopRequest from the new request.
if (status == NS_BINDING_REDIRECTED)
return NS_OK;
if (!mDestListener)
return NS_ERROR_FAILURE;

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

@ -80,7 +80,8 @@ interface nsIRequestObserver : nsISupports
#define NS_BINDING_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 1)
#define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
// The binding has been moved to another request in the same load group:
// The binding has been moved to another request in the same load group;
// the request observer should expect another On{Start/Stop}Request pair:
#define NS_BINDING_REDIRECTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 3)
// The binding has been moved to another request in a different load group:

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

@ -128,6 +128,11 @@ NS_IMETHODIMP
nsDownloader::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
nsresult aStatus)
{
// if the request has been redirected, then we'll get another pair
// of OnStartRequest/OnStopRequest from the new request.
if (aStatus == NS_BINDING_REDIRECTED)
return NS_OK;
nsCOMPtr<nsIFile> file;
if (NS_SUCCEEDED(aStatus))
{

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

@ -111,9 +111,9 @@ nsStreamLoader::GetNumBytesRead(PRUint32* aNumBytes)
/* readonly attribute nsIRequest request; */
NS_IMETHODIMP
nsStreamLoader::GetRequest(nsIRequest * *aRequest)
nsStreamLoader::GetRequest(nsIRequest **aRequest)
{
NS_IF_ADDREF(*aRequest=mRequest);
NS_IF_ADDREF(*aRequest = mRequest);
return NS_OK;
}
@ -128,14 +128,19 @@ NS_IMETHODIMP
nsStreamLoader::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
nsresult aStatus)
{
nsresult rv;
mRequest = request;
if (mObserver) {
rv = mObserver->OnStreamComplete(this, mContext, aStatus,
mData.Length(),
mData.get());
// if the request has been redirected, then we'll get another pair
// of OnStartRequest/OnStopRequest from the new request.
if ((aStatus != NS_BINDING_REDIRECTED) && mObserver) {
// provide nsIStreamLoader::request during call to OnStreamComplete
mRequest = request;
mObserver->OnStreamComplete(this, mContext, aStatus,
mData.Length(), mData.get());
// done.. cleanup
mRequest = 0;
mObserver = 0;
mContext = 0;
}
return rv;
return NS_OK;
}
#define BUF_SIZE 1024

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

@ -177,9 +177,13 @@ NS_IMETHODIMP nsURIChecker::SetLoadFlags(nsLoadFlags aLoadFlags)
NS_IMETHODIMP
nsURIChecker::OnStartRequest(nsIRequest *aRequest, nsISupports *aCtxt)
{
// DNS errors and other obvious problems will return failure status
nsresult status;
nsresult rv = aRequest->GetStatus(&status);
// if the request has been redirected, then we'll get another pair
// of OnStartRequest/OnStopRequest from the new request.
if (status == NS_BINDING_REDIRECTED)
return NS_OK;
// DNS errors and other obvious problems will return failure status
if (NS_FAILED(rv) || NS_FAILED(status)) {
SetStatusAndCallBack(NS_BINDING_FAILED);
return NS_OK;

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

@ -116,8 +116,6 @@ nsHttpChannel::Init(nsIURI *uri,
mOriginalURI = uri;
mCapabilities = caps;
LOG(("uri=%s\n", mSpec.get()));
//
// Construct connection info object
//
@ -155,6 +153,8 @@ nsHttpChannel::Init(nsIURI *uri,
rv = mURI->GetSpec(getter_Copies(mSpec));
if (NS_FAILED(rv)) return rv;
LOG(("uri=%s\n", mSpec.get()));
mConnectionInfo = new nsHttpConnectionInfo(host, port,
proxyInfo, usingSSL);
if (!mConnectionInfo)
@ -1231,12 +1231,11 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
// close down this transaction (null if processing a cached redirect)
if (mTransaction) {
mStatus = NS_BINDING_REDIRECTED;
mTransaction->Cancel(NS_BINDING_REDIRECTED);
// disconnect from our listener
mListener = 0;
mListenerContext = 0;
mListener->OnStartRequest(this, mListenerContext);
}
return NS_OK;
}
@ -1692,7 +1691,7 @@ NS_IMETHODIMP
nsHttpChannel::GetName(PRUnichar **aName)
{
NS_ENSURE_ARG_POINTER(aName);
*aName = ToNewUnicode(NS_ConvertASCIItoUCS2(mSpec));
*aName = ToNewUnicode(mSpec);
return NS_OK;
}