Bug 1747445 - Do not record time stamps for InterceptedHttpChannel if AsyncOpen() is never called. r=dom-worker-reviewers,smaug

It  is an edge case that InterceptedHttpChannel::Cancel() could be called before calling AsyncOpenInternal().
In the case, mTimeStamp status would be Created and we should not record any time stamp for InterceptedHttpChannel.

Differential Revision: https://phabricator.services.mozilla.com/D134775
This commit is contained in:
Eden Chuang
2021-12-30 05:54:39 +00:00
parent ae8e398ee1
commit cb755eb094

View File

@@ -1371,23 +1371,26 @@ void InterceptedHttpChannel::InterceptionTimeStamps::RecordTime(
// That means it is canceled after other operation is done, ex. synthesized.
MOZ_ASSERT(mStatus == Initialized || aStatus == Canceled);
if (mStatus == Initialized) {
mStatus = aStatus;
} else {
switch (mStatus) {
case Synthesized:
mStatus = CanceledAfterSynthesized;
break;
case Reset:
mStatus = CanceledAfterReset;
break;
case Redirected:
mStatus = CanceledAfterRedirected;
break;
default:
MOZ_ASSERT(false);
break;
}
switch (mStatus) {
case Initialized:
mStatus = aStatus;
break;
case Synthesized:
mStatus = CanceledAfterSynthesized;
break;
case Reset:
mStatus = CanceledAfterReset;
break;
case Redirected:
mStatus = CanceledAfterRedirected;
break;
// Channel is cancelled before calling AsyncOpenInternal(), no need to
// record the cancel time stamp.
case Created:
return;
default:
MOZ_ASSERT(false);
break;
}
RecordTimeInternal(std::move(aTimeStamp));