Bug 1103036 - Use kill timer when shutting down ContentParent in shutdown observer; r=billm
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1501,16 +1501,18 @@ void
ContentParent::ShutDownProcess(ShutDownMethod aMethod)
{
// Shutting down by sending a shutdown message works differently than the
// other methods. We first call Shutdown() in the child. After the child is
// ready, it calls FinishShutdown() on us. Then we close the channel.
if (aMethod == SEND_SHUTDOWN_MESSAGE) {
if (mIPCOpen && !mShutdownPending && SendShutdown()) {
mShutdownPending = true;
+ // Start the force-kill timer if we haven't already.
+ StartForceKillTimer();
}
// If call was not successful, the channel must have been broken
// somehow, and we will clean up the error in ActorDestroy.
return;
}
using mozilla::dom::quota::QuotaManager;
@@ -1918,18 +1920,26 @@ ContentParent::NotifyTabDestroying(PBrow
++mNumDestroyingTabs;
if (mNumDestroyingTabs != numLiveTabs) {
return;
}
// We're dying now, so prevent this content process from being
// recycled during its shutdown procedure.
MarkAsDead();
-
- MOZ_ASSERT(!mForceKillTimer);
+ StartForceKillTimer();
+}
+
+void
+ContentParent::StartForceKillTimer()
+{
+ if (mForceKillTimer || !mIPCOpen) {
+ return;
+ }
+
int32_t timeoutSecs =
Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
if (timeoutSecs > 0) {
mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
MOZ_ASSERT(mForceKillTimer);
mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback,
this,
timeoutSecs * 1000,
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -460,16 +460,19 @@ private:
* is an abnormal shutdown (e.g. a crash).
*/
void ShutDownProcess(ShutDownMethod aMethod);
// Perform any steps necesssary to gracefully shtudown the message
// manager and null out mMessageManager.
void ShutDownMessageManager();
+ // Start the force-kill timer on shutdown.
+ void StartForceKillTimer();
+
static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
PCompositorParent*
AllocPCompositorParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
PImageBridgeParent*
AllocPImageBridgeParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) MOZ_OVERRIDE;