Implement the nsIRequest interface for nsHTTPChannel. This allows channels that are cancelled from a LoadGroup to *actually* get removed...

This commit is contained in:
rpotts%netscape.com 1999-08-09 07:07:08 +00:00
Родитель eabc748ec0
Коммит 04a3d364ce
3 изменённых файлов: 110 добавлений и 7 удалений

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

@ -110,25 +110,45 @@ NS_IMPL_RELEASE(nsHTTPChannel);
NS_IMETHODIMP NS_IMETHODIMP
nsHTTPChannel::IsPending(PRBool *result) nsHTTPChannel::IsPending(PRBool *result)
{ {
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->IsPending(result);
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTTPChannel::Cancel(void) nsHTTPChannel::Cancel(void)
{ {
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->Cancel();
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTTPChannel::Suspend(void) nsHTTPChannel::Suspend(void)
{ {
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->Suspend();
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTTPChannel::Resume(void) nsHTTPChannel::Resume(void)
{ {
return NS_ERROR_NOT_IMPLEMENTED; nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pRequest) {
rv = m_pRequest->Resume();
}
return rv;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

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

@ -74,7 +74,80 @@ nsHTTPRequest::~nsHTTPRequest()
*/ */
} }
NS_IMPL_ISUPPORTS(nsHTTPRequest, nsCOMTypeInfo<nsIStreamObserver>::GetIID()) NS_IMPL_ADDREF(nsHTTPRequest);
NS_IMPL_RELEASE(nsHTTPRequest);
NS_IMETHODIMP
nsHTTPRequest::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = NULL;
if (aIID.Equals(nsCOMTypeInfo<nsIStreamObserver>::GetIID()) ||
aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) {
*aInstancePtr = NS_STATIC_CAST(nsIStreamObserver*, this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsCOMTypeInfo<nsIRequest>::GetIID())) {
*aInstancePtr = NS_STATIC_CAST(nsIRequest*, this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////////////
// nsIRequest methods:
NS_IMETHODIMP
nsHTTPRequest::IsPending(PRBool *result)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->IsPending(result);
}
return rv;
}
NS_IMETHODIMP
nsHTTPRequest::Cancel(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->Cancel();
}
return rv;
}
NS_IMETHODIMP
nsHTTPRequest::Suspend(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->Suspend();
}
return rv;
}
NS_IMETHODIMP
nsHTTPRequest::Resume(void)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (m_pTransport) {
rv = m_pTransport->Resume();
}
return rv;
}
// Finally our own methods... // Finally our own methods...
@ -413,3 +486,5 @@ nsresult nsHTTPRequest::GetHeaderEnumerator(nsISimpleEnumerator** aResult)
{ {
return mHeaders.GetEnumerator(aResult); return mHeaders.GetEnumerator(aResult);
} }

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

@ -23,6 +23,7 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIStreamObserver.h" #include "nsIStreamObserver.h"
#include "nsIURL.h" #include "nsIURL.h"
#include "nsIRequest.h"
#include "nsHTTPHeaderArray.h" #include "nsHTTPHeaderArray.h"
#include "nsHTTPEnums.h" #include "nsHTTPEnums.h"
@ -53,7 +54,8 @@ class nsHTTPChannel;
-Gagan Saksena 03/29/99 -Gagan Saksena 03/29/99
*/ */
class nsHTTPRequest : public nsIStreamObserver class nsHTTPRequest : public nsIStreamObserver,
public nsIRequest
{ {
public: public:
@ -71,6 +73,12 @@ public:
nsresult aStatus, nsresult aStatus,
const PRUnichar* aMsg); const PRUnichar* aMsg);
// nsIRequest methods:
NS_IMETHOD IsPending(PRBool *result);
NS_IMETHOD Cancel();
NS_IMETHOD Suspend();
NS_IMETHOD Resume();
// Finally our own methods... // Finally our own methods...
/* /*
Set or Get a header on the request. Note that for the first iteration Set or Get a header on the request. Note that for the first iteration