Bug 1103036 - Use nsITimer for ContentParent shutdown timer (r=bent)

This commit is contained in:
Bill McCloskey 2015-01-06 21:42:23 -08:00
Родитель 331965edcd
Коммит 92aaff8d7f
2 изменённых файлов: 25 добавлений и 13 удалений

Просмотреть файл

@ -116,6 +116,7 @@
#include "nsISpellChecker.h"
#include "nsIStyleSheet.h"
#include "nsISupportsPrimitives.h"
#include "nsITimer.h"
#include "nsIURIFixup.h"
#include "nsIWindowWatcher.h"
#include "nsIXULRuntime.h"
@ -1768,9 +1769,9 @@ struct DelayedDeleteContentParentTask : public nsRunnable
void
ContentParent::ActorDestroy(ActorDestroyReason why)
{
if (mForceKillTask) {
mForceKillTask->Cancel();
mForceKillTask = nullptr;
if (mForceKillTimer) {
mForceKillTimer->Cancel();
mForceKillTimer = nullptr;
}
// Signal shutdown completion regardless of error state,
@ -1922,14 +1923,16 @@ ContentParent::NotifyTabDestroying(PBrowserParent* aTab)
// recycled during its shutdown procedure.
MarkAsDead();
MOZ_ASSERT(!mForceKillTask);
MOZ_ASSERT(!mForceKillTimer);
int32_t timeoutSecs =
Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
if (timeoutSecs > 0) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
mForceKillTask = NewRunnableMethod(this, &ContentParent::KillHard),
timeoutSecs * 1000);
mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
MOZ_ASSERT(mForceKillTimer);
mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback,
this,
timeoutSecs * 1000,
nsITimer::TYPE_ONE_SHOT);
}
}
@ -1989,7 +1992,6 @@ ContentParent::InitializeMembers()
mSubprocess = nullptr;
mChildID = gContentChildID++;
mGeolocationWatchID = -1;
mForceKillTask = nullptr;
mNumDestroyingTabs = 0;
mIsAlive = true;
mSendPermissionUpdates = false;
@ -2167,8 +2169,8 @@ ContentParent::ContentParent(ContentParent* aTemplate,
ContentParent::~ContentParent()
{
if (mForceKillTask) {
mForceKillTask->Cancel();
if (mForceKillTimer) {
mForceKillTimer->Cancel();
}
if (OtherProcess())
@ -3159,6 +3161,13 @@ ContentParent::DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParen
return true;
}
/* static */ void
ContentParent::ForceKillTimerCallback(nsITimer* aTimer, void* aClosure)
{
auto self = static_cast<ContentParent*>(aClosure);
self->KillHard();
}
void
ContentParent::KillHard()
{
@ -3169,7 +3178,7 @@ ContentParent::KillHard()
return;
}
mCalledKillHard = true;
mForceKillTask = nullptr;
mForceKillTimer = nullptr;
#if defined(MOZ_CRASHREPORTER) && !defined(MOZ_B2G)
if (ManagedPCrashReporterParent().Length() > 0) {

Просмотреть файл

@ -33,6 +33,7 @@ class nsICycleCollectorLogSink;
class nsIDOMBlob;
class nsIDumpGCAndCCLogsCallback;
class nsIMemoryReporter;
class nsITimer;
class ParentIdleListener;
namespace mozilla {
@ -464,6 +465,8 @@ private:
// manager and null out mMessageManager.
void ShutDownMessageManager();
static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
PCompositorParent*
AllocPCompositorParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
@ -790,7 +793,7 @@ private:
// that even content processes that are 100% blocked (say from
// SIGSTOP), are still killed eventually. This task enforces that
// timer.
CancelableTask* mForceKillTask;
nsCOMPtr<nsITimer> mForceKillTimer;
// How many tabs we're waiting to finish their destruction
// sequence. Precisely, how many TabParents have called
// NotifyTabDestroying() but not called NotifyTabDestroyed().