network/module/nsIRefreshUrl.h
Extended the nsIRefreshUrl interface to include a cancel method. network/module/nsNetService.cpp 1. Added code to hook the nsConnectionInfo object up to the nsISupports pointer in the url being loaded. 2. Removed the redirect logic in bam_exit_routine(). The backend dependency on the front end is gone. network/module/nsNetStream.cpp Added initialization/destruction of the nsISupports pointer in the nsConnectionInfo. network/module/nsNetStream.h Added the nsISupports member declaration to nsConnectionInfo, and remvoed the redirect member variable. network/module/nsNetStubs.cpp FE_SetRefreshURLTimer() routine has been modified so it no longer relies on the pConsumer (i.e. nsDocumentBindInfo) which was causing us to leak it. Now we use the nsISupports pointer in the nsConnectionInfo object to access the nsIRefreshURL interface so we can reload the url. network/module/nsStubContext.cpp Modified stub_complete() so we no longer pay attention to the redirect member of the nsConnectionInfo object. network/module/nsIURL.h 1. Added GetContainer() method to nsIURL which returns the nsISupports pointer of the container for this url. 2. created a new NS_NewURL() routine which takes an nsISupports pointer as a parameter. network/module/nsURL.cpp 1. Added a new nsURL constructor that takes a nsISupports pointer as a param. 2. Added GetContainer() method and nsISupports pointer initialization/destruction. git-svn-id: svn://10.0.0.236/trunk@8163 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
182ab83bed
commit
a192f6bdd0
@ -40,6 +40,11 @@ struct nsIRefreshUrl : public nsISupports
|
||||
* @param repeat Do you want the url to be repeatedly refreshed every millis milliseconds.
|
||||
*/
|
||||
NS_IMETHOD RefreshURL(nsIURL *url, PRInt32 millis, PRBool repeat) = 0;
|
||||
|
||||
/**
|
||||
* Cancels all timer loads.
|
||||
*/
|
||||
NS_IMETHOD CancelRefreshURLTimers(void) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIRefreshUrl_h___ */
|
||||
|
||||
@ -70,6 +70,8 @@ public:
|
||||
|
||||
/** @return ref part of the URL */
|
||||
virtual PRInt32 GetPort() const = 0;
|
||||
|
||||
virtual nsISupports* GetContainer() const = 0;
|
||||
//@}
|
||||
|
||||
/** Write the URL to aString, overwriting previous contents. */
|
||||
@ -85,6 +87,11 @@ extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
|
||||
const nsIURL* aURL,
|
||||
const nsString& aSpec);
|
||||
|
||||
/** Create a new URL from aSpec, set it's mWebShell field to webshell. */
|
||||
extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
|
||||
const nsString& aSpec,
|
||||
nsISupports* container);
|
||||
|
||||
/**
|
||||
* Utility routine to take a url (may be nsnull) and a base url (may
|
||||
* be empty), and a url spec and combine them properly into a new
|
||||
|
||||
@ -123,7 +123,6 @@ nsNetlibService::nsNetlibService(nsINetContainerApplication *aContainerApp)
|
||||
NET_ChunkedDecoderStream);
|
||||
|
||||
mPollingTimer = nsnull;
|
||||
|
||||
RL_Init();
|
||||
|
||||
mContainer = aContainerApp;
|
||||
@ -179,7 +178,7 @@ nsNetlibService::~nsNetlibService()
|
||||
m_stubContext = NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
NS_IF_RELEASE(mPollingTimer);
|
||||
NS_IF_RELEASE(mContainer);
|
||||
NET_ShutdownNetLib();
|
||||
@ -205,6 +204,14 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl,
|
||||
}
|
||||
pConn->AddRef();
|
||||
|
||||
/* We've got a nsConnectionInfo(), now hook it up
|
||||
* to the nsISupports of the nsIContentViewerContainer
|
||||
*/
|
||||
pConn->pContainer = aUrl->GetContainer();
|
||||
if(pConn->pContainer) {
|
||||
NS_ADDREF(pConn->pContainer);
|
||||
}
|
||||
|
||||
/* Create the URLStruct... */
|
||||
URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD);
|
||||
if (NULL == URL_s) {
|
||||
@ -299,6 +306,14 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl,
|
||||
}
|
||||
pConn->AddRef();
|
||||
|
||||
/* We've got a nsConnectionInfo(), now hook it up
|
||||
* to the nsISupports of the nsIContentViewerContainer
|
||||
*/
|
||||
pConn->pContainer = aUrl->GetContainer();
|
||||
if(pConn->pContainer) {
|
||||
NS_ADDREF(pConn->pContainer);
|
||||
}
|
||||
|
||||
/* Create the URLStruct... */
|
||||
URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD);
|
||||
if (NULL == URL_s) {
|
||||
@ -457,7 +472,6 @@ nsNetlibService::SetCookieString(nsIURL *aURL, const nsString& aCookie)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void nsNetlibService::SchedulePollingTimer()
|
||||
{
|
||||
// If a timer is already active, then do not create another...
|
||||
@ -582,19 +596,7 @@ static void bam_exit_routine(URL_Struct *URL_s, int status, MWContext *window_id
|
||||
*/
|
||||
if (pConn->pConsumer) {
|
||||
nsAutoString status;
|
||||
|
||||
/* If we were redirected, the Data Consumer will still be
|
||||
* around (not released in the stream completion routine.
|
||||
* In this case we want to notify the consumer that the
|
||||
* binding completed. This leaves a hole: when we're
|
||||
* redirected, and we're in this if statement because
|
||||
* the stream was never "competed". */
|
||||
if (pConn->redirect) {
|
||||
pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_SUCCEEDED, status);
|
||||
} else {
|
||||
pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_FAILED, status);
|
||||
}
|
||||
|
||||
pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_FAILED, status);
|
||||
pConn->pConsumer->Release();
|
||||
pConn->pConsumer = NULL;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ nsConnectionInfo::nsConnectionInfo(nsIURL *aURL,
|
||||
pURL = aURL;
|
||||
pNetStream = aStream;
|
||||
pConsumer = aNotify;
|
||||
redirect = PR_FALSE;
|
||||
pContainer = nsnull;
|
||||
|
||||
if (NULL != pURL) {
|
||||
pURL->AddRef();
|
||||
@ -79,9 +79,14 @@ nsConnectionInfo::~nsConnectionInfo()
|
||||
pConsumer->Release();
|
||||
}
|
||||
|
||||
if (nsnull != pContainer) {
|
||||
NS_RELEASE(pContainer);
|
||||
}
|
||||
|
||||
pURL = NULL;
|
||||
pNetStream = NULL;
|
||||
pConsumer = NULL;
|
||||
pContainer = nsnull;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
nsIURL *pURL;
|
||||
nsNetlibStream *pNetStream;
|
||||
nsIStreamListener *pConsumer;
|
||||
PRBool redirect;
|
||||
nsISupports *pContainer;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -383,18 +383,21 @@ void FE_SetRefreshURLTimer(MWContext *pContext, uint32 seconds, char *pRefreshUR
|
||||
// modular_data points to a URL_Struct.
|
||||
pConn = (nsConnectionInfo*) pContext->modular_data->fe_data;
|
||||
|
||||
NS_PRECONDITION((pConn->pConsumer != nsnull), "Null pointer...");
|
||||
NS_PRECONDITION((pConn != nsnull), "Null pointer...");
|
||||
|
||||
if (pConn->pConsumer) {
|
||||
|
||||
rv = pConn->pConsumer->QueryInterface(kRefreshURLIID, (void**)&IRefreshURL);
|
||||
if (pConn) {
|
||||
/* Get the pointer to the nsIRefreshURL from the nsISupports
|
||||
* of the nsIContentViewerContainer the nsConnnectionInfo holds.
|
||||
*/
|
||||
rv = pConn->pContainer->QueryInterface(kRefreshURLIID, (void**)&IRefreshURL);
|
||||
|
||||
if(rv == NS_OK) {
|
||||
nsIURL* aURL;
|
||||
rv = NS_NewURL(&aURL, refreshURL);
|
||||
if(rv == NS_OK) {
|
||||
IRefreshURL->RefreshURL(aURL, seconds*1000, FALSE);
|
||||
if (rv == NS_OK) {
|
||||
rv = IRefreshURL->RefreshURL(aURL, seconds*1000, FALSE);
|
||||
NS_RELEASE(IRefreshURL);
|
||||
NS_RELEASE(aURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,15 +495,9 @@ void stub_complete(NET_StreamClass *stream)
|
||||
/* Notify the Data Consumer that the Binding has completed... */
|
||||
if (pConn->pConsumer) {
|
||||
nsAutoString status;
|
||||
|
||||
/* If we're redirecting, we don't want to release/null the pConsumer. */
|
||||
if (URL_s->refresh_url) {
|
||||
pConn->redirect = PR_TRUE;
|
||||
} else {
|
||||
pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_SUCCEEDED, status);
|
||||
pConn->pConsumer->Release();
|
||||
pConn->pConsumer = NULL;
|
||||
}
|
||||
pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_SUCCEEDED, status);
|
||||
pConn->pConsumer->Release();
|
||||
pConn->pConsumer = NULL;
|
||||
}
|
||||
|
||||
/* Release the URL_Struct hanging off of the data_object */
|
||||
|
||||
@ -36,6 +36,7 @@ char *mangleResourceIntoFileURL(const char* aResourceFileName);
|
||||
class URLImpl : public nsIURL {
|
||||
public:
|
||||
URLImpl(const nsString& aSpec);
|
||||
URLImpl(const nsString& aSpec, nsISupports* container);
|
||||
URLImpl(const nsIURL* aURL, const nsString& aSpec);
|
||||
virtual ~URLImpl();
|
||||
|
||||
@ -54,6 +55,7 @@ public:
|
||||
virtual const char* GetSearch() const;
|
||||
virtual const char* GetSpec() const;
|
||||
virtual PRInt32 GetPort() const;
|
||||
virtual nsISupports* GetContainer() const;
|
||||
|
||||
virtual void ToString(nsString& aString) const;
|
||||
|
||||
@ -63,6 +65,7 @@ public:
|
||||
char* mFile;
|
||||
char* mRef;
|
||||
char* mSearch;
|
||||
nsISupports* mContainer;
|
||||
PRInt32 mPort;
|
||||
PRBool mOK;
|
||||
|
||||
@ -84,6 +87,29 @@ URLImpl::URLImpl(const nsString& aSpec)
|
||||
mSearch = nsnull;
|
||||
mPort = -1;
|
||||
mSpec = nsnull;
|
||||
mContainer = nsnull;
|
||||
|
||||
ParseURL(nsnull, aSpec);
|
||||
}
|
||||
|
||||
URLImpl::URLImpl(const nsString& aSpec, nsISupports* container)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mProtocolUrl = nsnull;
|
||||
|
||||
mProtocol = nsnull;
|
||||
mHost = nsnull;
|
||||
mFile = nsnull;
|
||||
mRef = nsnull;
|
||||
mSearch = nsnull;
|
||||
mPort = -1;
|
||||
mSpec = nsnull;
|
||||
if (container) {
|
||||
mContainer = container;
|
||||
NS_ADDREF(container);
|
||||
} else {
|
||||
mContainer = nsnull;
|
||||
}
|
||||
|
||||
ParseURL(nsnull, aSpec);
|
||||
}
|
||||
@ -100,6 +126,7 @@ URLImpl::URLImpl(const nsIURL* aURL, const nsString& aSpec)
|
||||
mSearch = nsnull;
|
||||
mPort = -1;
|
||||
mSpec = nsnull;
|
||||
mContainer = nsnull;
|
||||
|
||||
ParseURL(aURL, aSpec);
|
||||
}
|
||||
@ -138,6 +165,7 @@ nsresult URLImpl::QueryInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
URLImpl::~URLImpl()
|
||||
{
|
||||
NS_IF_RELEASE(mProtocolUrl);
|
||||
NS_IF_RELEASE(mContainer);
|
||||
|
||||
PR_FREEIF(mSpec);
|
||||
PR_FREEIF(mProtocol);
|
||||
@ -196,6 +224,10 @@ PRInt32 URLImpl::GetPort() const
|
||||
return mPort;
|
||||
}
|
||||
|
||||
nsISupports* URLImpl::GetContainer() const
|
||||
{
|
||||
return mContainer;
|
||||
}
|
||||
|
||||
void URLImpl::ToString(nsString& aString) const
|
||||
{
|
||||
@ -592,6 +624,17 @@ NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
|
||||
return it->QueryInterface(kURLIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult,
|
||||
const nsString& aSpec,
|
||||
nsISupports* container)
|
||||
{
|
||||
URLImpl* it = new URLImpl(aSpec, container);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kURLIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL,
|
||||
const nsString& aBaseURL,
|
||||
const nsString& aSpec,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user