зеркало из https://github.com/mozilla/pjs.git
bug 321932 r=bz sr=darin
Better handle the case where channels don't implement isPending correctly
This commit is contained in:
Родитель
c206358879
Коммит
a12fe095b9
|
@ -869,6 +869,7 @@ NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
|
||||||
nsresult rv = OpenChannel(channel,
|
nsresult rv = OpenChannel(channel,
|
||||||
aIsContentPreferred ? IS_CONTENT_PREFERRED : 0,
|
aIsContentPreferred ? IS_CONTENT_PREFERRED : 0,
|
||||||
aWindowContext,
|
aWindowContext,
|
||||||
|
PR_FALSE,
|
||||||
getter_AddRefs(loader));
|
getter_AddRefs(loader));
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
@ -893,10 +894,11 @@ NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsURILoader::OpenChannel(nsIChannel* channel,
|
nsresult nsURILoader::OpenChannel(nsIChannel* channel,
|
||||||
PRUint32 aFlags,
|
PRUint32 aFlags,
|
||||||
nsIInterfaceRequestor* aWindowContext,
|
nsIInterfaceRequestor* aWindowContext,
|
||||||
nsIStreamListener** aListener)
|
PRBool aChannelIsOpen,
|
||||||
|
nsIStreamListener** aListener)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(channel, "Trying to open a null channel!");
|
NS_ASSERTION(channel, "Trying to open a null channel!");
|
||||||
NS_ASSERTION(aWindowContext, "Window context must not be null");
|
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
|
// If the channel is pending, then we need to remove it from its current
|
||||||
// loadgroup
|
// loadgroup
|
||||||
PRBool pending;
|
if (aChannelIsOpen) {
|
||||||
if (NS_SUCCEEDED(channel->IsPending(&pending)) && pending) {
|
|
||||||
nsCOMPtr<nsILoadGroup> oldGroup;
|
nsCOMPtr<nsILoadGroup> oldGroup;
|
||||||
channel->GetLoadGroup(getter_AddRefs(oldGroup));
|
channel->GetLoadGroup(getter_AddRefs(oldGroup));
|
||||||
if (oldGroup) {
|
if (oldGroup) {
|
||||||
oldGroup->RemoveRequest(channel, nsnull, NS_BINDING_RETARGETED);
|
oldGroup->RemoveRequest(channel, nsnull, NS_BINDING_RETARGETED);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pending = PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->SetLoadGroup(loadGroup);
|
channel->SetLoadGroup(loadGroup);
|
||||||
|
|
||||||
if (pending) {
|
if (aChannelIsOpen) {
|
||||||
loadGroup->AddRequest(channel, nsnull);
|
loadGroup->AddRequest(channel, nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,6 +984,19 @@ NS_IMETHODIMP nsURILoader::OpenChannel(nsIChannel* channel,
|
||||||
return rv;
|
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)
|
NS_IMETHODIMP nsURILoader::Stop(nsISupports* aLoadCookie)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
|
@ -65,6 +65,16 @@ public:
|
||||||
~nsURILoader();
|
~nsURILoader();
|
||||||
|
|
||||||
protected:
|
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
|
* we shouldn't need to have an owning ref count on registered
|
||||||
* content listeners because they are supposed to unregister themselves
|
* content listeners because they are supposed to unregister themselves
|
||||||
|
|
Загрузка…
Ссылка в новой задаче