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

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

@ -94,11 +94,6 @@ class DocumentChannelParent : public nsIInterfaceRequestor,
virtual void ActorDestroy(ActorDestroyReason why) override; 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: private:
virtual ~DocumentChannelParent() = default; virtual ~DocumentChannelParent() = default;