Bug 565223 - e10s: Don't send IPDL msgs if the child has died. r=jduell

This commit is contained in:
Josh Matthews 2010-05-11 22:53:25 -04:00
parent 0dcda12066
commit d7ff2902a5
2 changed files with 15 additions and 13 deletions

View File

@ -51,6 +51,7 @@ namespace net {
// C++ file contents
HttpChannelParent::HttpChannelParent()
: mIPCClosed(false)
{
// Ensure gHttpHandler is initialized: we need the atom table up and running.
nsIHttpProtocolHandler* handler;
@ -63,6 +64,14 @@ HttpChannelParent::~HttpChannelParent()
gHttpHandler->Release();
}
void
HttpChannelParent::ActorDestroy(ActorDestroyReason why)
{
// We may still have refcount>0 if nsHttpChannel hasn't called OnStopRequest
// yet, but we must not send any more msgs to child.
mIPCClosed = true;
}
//-----------------------------------------------------------------------------
// HttpChannelParent::nsISupports
//-----------------------------------------------------------------------------
@ -163,12 +172,8 @@ HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
nsHttpResponseHead *responseHead = chan->GetResponseHead();
NS_ABORT_IF_FALSE(responseHead, "Missing HTTP responseHead!");
if (!SendOnStartRequest(*responseHead)) {
// IPDL error--child dead/dying & our own destructor will be called
// automatically
// -- TODO: verify that that's the case :)
if (mIPCClosed || !SendOnStartRequest(*responseHead))
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
@ -180,11 +185,8 @@ HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
LOG(("HttpChannelParent::OnStopRequest: [this=%x status=%ul]\n",
this, aStatusCode));
if (!SendOnStopRequest(aStatusCode)) {
// IPDL error--child dead/dying & our own destructor will be called
// automatically
if (mIPCClosed || !SendOnStopRequest(aStatusCode))
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
@ -213,11 +215,8 @@ HttpChannelParent::OnDataAvailable(nsIRequest *aRequest,
return rv; // TODO: figure out error handling
}
if (!SendOnDataAvailable(data, aOffset, bytesRead)) {
// IPDL error--child dead/dying & our own destructor will be called
// automatically
if (mIPCClosed || !SendOnDataAvailable(data, aOffset, bytesRead))
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}

View File

@ -79,7 +79,10 @@ protected:
virtual bool RecvSetPriority(const PRUint16& priority);
virtual void ActorDestroy(ActorDestroyReason why);
nsCOMPtr<nsIChannel> mChannel;
bool mIPCClosed; // PHttpChannel actor has been Closed()
};
} // namespace net