зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1562769 - Clean up ContentParent destruction. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D36555 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4d1a8ed239
Коммит
910a046a52
|
@ -1554,8 +1554,7 @@ void ContentParent::ProcessingError(Result aCode, const char* aReason) {
|
|||
}
|
||||
|
||||
void ContentParent::ActorDestroy(ActorDestroyReason why) {
|
||||
RefPtr<ContentParent> kungFuDeathGrip(mSelfRef.forget());
|
||||
MOZ_RELEASE_ASSERT(kungFuDeathGrip);
|
||||
MOZ_RELEASE_ASSERT(mSelfRef);
|
||||
|
||||
if (mForceKillTimer) {
|
||||
mForceKillTimer->Cancel();
|
||||
|
@ -1667,16 +1666,6 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
|
|||
}
|
||||
}
|
||||
|
||||
// IPDL rules require actors to live on past ActorDestroy, but it
|
||||
// may be that the kungFuDeathGrip above is the last reference to
|
||||
// |this|. If so, when we go out of scope here, we're deleted and
|
||||
// all hell breaks loose.
|
||||
//
|
||||
// This runnable ensures that a reference to |this| lives on at
|
||||
// least until after the current task finishes running.
|
||||
NS_DispatchToCurrentThread(NS_NewRunnableFunction(
|
||||
"DelayedReleaseContentParent", [kungFuDeathGrip] {}));
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
nsTArray<ContentParentId> childIDArray =
|
||||
cpm->GetAllChildProcessById(this->ChildID());
|
||||
|
@ -1715,6 +1704,8 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
|
|||
MOZ_DIAGNOSTIC_ASSERT(mGroups.IsEmpty());
|
||||
}
|
||||
|
||||
void ContentParent::ActorDealloc() { mSelfRef = nullptr; }
|
||||
|
||||
bool ContentParent::TryToRecycle() {
|
||||
// This life time check should be replaced by a memory health check (memory
|
||||
// usage + fragmentation).
|
||||
|
@ -2134,7 +2125,7 @@ void ContentParent::LaunchSubprocessInternal(
|
|||
return LaunchPromise::CreateAndReject(err, __func__);
|
||||
};
|
||||
|
||||
// See also ActorDestroy.
|
||||
// See also ActorDealloc.
|
||||
mSelfRef = this;
|
||||
|
||||
// Lifetime note: the GeckoChildProcessHost holds a strong reference
|
||||
|
|
|
@ -646,7 +646,8 @@ class ContentParent final : public PContentParent,
|
|||
protected:
|
||||
void OnChannelConnected(int32_t pid) override;
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason why) override;
|
||||
void ActorDestroy(ActorDestroyReason why) override;
|
||||
void ActorDealloc() override;
|
||||
|
||||
bool ShouldContinueFromReplyTimeout() override;
|
||||
|
||||
|
@ -1214,7 +1215,7 @@ class ContentParent final : public PContentParent,
|
|||
static bool ShouldSyncPreference(const char16_t* aData);
|
||||
|
||||
private:
|
||||
// Released in ActorDestroy; deliberately not exposed to the CC.
|
||||
// Released in ActorDealloc; deliberately not exposed to the CC.
|
||||
RefPtr<ContentParent> mSelfRef;
|
||||
|
||||
// If you add strong pointers to cycle collected objects here, be sure to
|
||||
|
|
Загрузка…
Ссылка в новой задаче