Backed out 2 changesets (bug 1535913) for Hazzard failure

Backed out changeset 1675ff18e322 (bug 1535913)
Backed out changeset fbcd65f308c2 (bug 1535913)
This commit is contained in:
Dorel Luca
2021-05-20 01:33:36 +03:00
parent 203f5830eb
commit d1b3de3fb7
9 changed files with 39 additions and 113 deletions

View File

@@ -816,6 +816,22 @@ void BrowsingContext::Detach(bool aFromIPC) {
mGroup->Toplevels().RemoveElement(this);
}
auto callSendDiscard = [&](auto* aActor) {
// Hold a strong reference to ourself, and keep our BrowsingContextGroup
// alive, until the responses comes back to ensure we don't die while
// messages relating to this context are in-flight.
//
// When the callback is called, the keepalive on our group will be
// destroyed, and the reference to the BrowsingContext will be dropped,
// which may cause it to be fully destroyed.
mGroup->AddKeepAlive();
auto callback = [self = RefPtr{this}](auto) {
self->mGroup->RemoveKeepAlive();
};
aActor->SendDiscardBrowsingContext(this, callback, callback);
};
if (XRE_IsParentProcess()) {
Group()->EachParent([&](ContentParent* aParent) {
// Only the embedder process is allowed to initiate a BrowsingContext
@@ -827,25 +843,11 @@ void BrowsingContext::Detach(bool aFromIPC) {
// destroyed.
if (!Canonical()->IsEmbeddedInProcess(aParent->ChildID()) &&
!Canonical()->IsOwnedByProcess(aParent->ChildID())) {
// Hold a strong reference to ourself, and keep our BrowsingContextGroup
// alive, until the responses comes back to ensure we don't die while
// messages relating to this context are in-flight.
//
// When the callback is called, the keepalive on our group will be
// destroyed, and the reference to the BrowsingContext will be dropped,
// which may cause it to be fully destroyed.
mGroup->AddKeepAlive();
auto callback = [self = RefPtr{this}](auto) {
self->mGroup->RemoveKeepAlive();
};
aParent->SendDiscardBrowsingContext(this, callback, callback);
callSendDiscard(aParent);
}
});
} else if (!aFromIPC) {
auto callback = [](auto) {};
ContentChild::GetSingleton()->SendDiscardBrowsingContext(this, callback,
callback);
callSendDiscard(ContentChild::GetSingleton());
}
mGroup->Unregister(this);