Bug 1103036 - Use kill timer when shutting down ContentParent in shutdown observer; r=billm
authorJim Chen <nchen@mozilla.com>
Sat, 10 Jan 2015 13:45:58 -0500
changeset 248964 19017193859ab2cedee889654d106745f5f8f4a8
parent 248963 66083ac0f3c069c5b0bb4908b50cffb15d7d2eb6
child 248965 a55f093defe1023db222cbd5be3a65f1bb963e39
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1103036
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1103036 - Use kill timer when shutting down ContentParent in shutdown observer; r=billm
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
--- 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;