Bug 1576714 - Part 5: Delay canceling original document channel during process switch, r=mattwoodrow

This delays when the DocumentChannelChild is canceled during a process switch to
be after the switch has been completed, to prevent the load event firing too
early in the original content process.

Differential Revision: https://phabricator.services.mozilla.com/D47312

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-10-01 18:09:12 +00:00
Родитель 5a6a1b3307
Коммит 1084aa67a3
2 изменённых файлов: 12 добавлений и 23 удалений

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

@ -144,36 +144,22 @@ void DocumentChannelParent::ActorDestroy(ActorDestroyReason why) {
}
}
void DocumentChannelParent::CancelChildForProcessSwitch() {
MOZ_ASSERT(!mDoingProcessSwitch, "Already in the middle of switching?");
MOZ_ASSERT(NS_IsMainThread());
mDoingProcessSwitch = true;
if (CanSend()) {
Unused << SendCancelForProcessSwitch();
}
}
bool DocumentChannelParent::RecvCancel(const nsresult& aStatusCode) {
if (mDoingProcessSwitch) {
return IPC_OK();
}
if (mChannel) {
if (mChannel && !mDoingProcessSwitch) {
mChannel->Cancel(aStatusCode);
}
return true;
}
bool DocumentChannelParent::RecvSuspend() {
if (mChannel) {
if (mChannel && !mDoingProcessSwitch) {
mChannel->Suspend();
}
return true;
}
bool DocumentChannelParent::RecvResume() {
if (mChannel) {
if (mChannel && !mDoingProcessSwitch) {
mChannel->Resume();
}
return true;
@ -221,6 +207,10 @@ DocumentChannelParent::ReadyToVerify(nsresult aResultCode) {
void DocumentChannelParent::FinishReplacementChannelSetup(bool aSucceeded) {
nsresult rv;
if (mDoingProcessSwitch && CanSend()) {
Unused << SendCancelForProcessSwitch();
}
nsCOMPtr<nsIParentChannel> redirectChannel;
if (mRedirectChannelId) {
nsCOMPtr<nsIRedirectChannelRegistrar> registrar =
@ -360,7 +350,11 @@ void DocumentChannelParent::FinishReplacementChannelSetup(bool aSucceeded) {
void DocumentChannelParent::TriggerCrossProcessSwitch() {
MOZ_ASSERT(mRedirectContentProcessIdPromise);
CancelChildForProcessSwitch();
MOZ_ASSERT(!mDoingProcessSwitch, "Already in the middle of switching?");
MOZ_ASSERT(NS_IsMainThread());
mDoingProcessSwitch = true;
RefPtr<DocumentChannelParent> self = this;
mRedirectContentProcessIdPromise->Then(
GetMainThreadSerialEventTarget(), __func__,

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

@ -94,11 +94,6 @@ class DocumentChannelParent : public nsIInterfaceRequestor,
virtual void ActorDestroy(ActorDestroyReason why) override;
// Notify the DocumentChannelChild that we're switching
// to a different process and that it can notify listeners
// that it's finished.
void CancelChildForProcessSwitch();
private:
virtual ~DocumentChannelParent() = default;