mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
bug 321932 r=bz sr=darin
Better handle the case where channels don't implement isPending correctly
This commit is contained in:
parent
6fdafae9b3
commit
463712374b
@ -869,6 +869,7 @@ NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
|
||||
nsresult rv = OpenChannel(channel,
|
||||
aIsContentPreferred ? IS_CONTENT_PREFERRED : 0,
|
||||
aWindowContext,
|
||||
PR_FALSE,
|
||||
getter_AddRefs(loader));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -893,10 +894,11 @@ NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURILoader::OpenChannel(nsIChannel* channel,
|
||||
PRUint32 aFlags,
|
||||
nsIInterfaceRequestor* aWindowContext,
|
||||
nsIStreamListener** aListener)
|
||||
nsresult nsURILoader::OpenChannel(nsIChannel* channel,
|
||||
PRUint32 aFlags,
|
||||
nsIInterfaceRequestor* aWindowContext,
|
||||
PRBool aChannelIsOpen,
|
||||
nsIStreamListener** aListener)
|
||||
{
|
||||
NS_ASSERTION(channel, "Trying to open a null channel!");
|
||||
NS_ASSERTION(aWindowContext, "Window context must not be null");
|
||||
@ -961,20 +963,17 @@ NS_IMETHODIMP nsURILoader::OpenChannel(nsIChannel* channel,
|
||||
|
||||
// If the channel is pending, then we need to remove it from its current
|
||||
// loadgroup
|
||||
PRBool pending;
|
||||
if (NS_SUCCEEDED(channel->IsPending(&pending)) && pending) {
|
||||
if (aChannelIsOpen) {
|
||||
nsCOMPtr<nsILoadGroup> oldGroup;
|
||||
channel->GetLoadGroup(getter_AddRefs(oldGroup));
|
||||
if (oldGroup) {
|
||||
oldGroup->RemoveRequest(channel, nsnull, NS_BINDING_RETARGETED);
|
||||
}
|
||||
} else {
|
||||
pending = PR_FALSE;
|
||||
}
|
||||
|
||||
channel->SetLoadGroup(loadGroup);
|
||||
|
||||
if (pending) {
|
||||
if (aChannelIsOpen) {
|
||||
loadGroup->AddRequest(channel, nsnull);
|
||||
}
|
||||
|
||||
@ -985,6 +984,19 @@ NS_IMETHODIMP nsURILoader::OpenChannel(nsIChannel* channel,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURILoader::OpenChannel(nsIChannel* channel,
|
||||
PRUint32 aFlags,
|
||||
nsIInterfaceRequestor* aWindowContext,
|
||||
nsIStreamListener** aListener)
|
||||
{
|
||||
PRBool pending;
|
||||
if (NS_FAILED(channel->IsPending(&pending))) {
|
||||
pending = PR_FALSE;
|
||||
}
|
||||
|
||||
return OpenChannel(channel, aFlags, aWindowContext, pending, aListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURILoader::Stop(nsISupports* aLoadCookie)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -65,6 +65,16 @@ public:
|
||||
~nsURILoader();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Equivalent to nsIURILoader::openChannel, but allows specifying whether the
|
||||
* channel is opened already.
|
||||
*/
|
||||
NS_HIDDEN_(nsresult) OpenChannel(nsIChannel* channel,
|
||||
PRUint32 aFlags,
|
||||
nsIInterfaceRequestor* aWindowContext,
|
||||
PRBool aChannelOpen,
|
||||
nsIStreamListener** aListener);
|
||||
|
||||
/**
|
||||
* we shouldn't need to have an owning ref count on registered
|
||||
* content listeners because they are supposed to unregister themselves
|
||||
|
Loading…
Reference in New Issue
Block a user