Bug 1871048 - Don't call OnDataFinished on main thread, r=jesup,necko-reviewers,valentin,sunil

Differential Revision: https://phabricator.services.mozilla.com/D197141
This commit is contained in:
Kershaw Chang 2024-01-10 16:33:22 +00:00
parent c05e35171b
commit 39bd8d1622
3 changed files with 12 additions and 12 deletions

View File

@ -816,6 +816,11 @@ void HttpChannelChild::DoOnDataAvailable(nsIRequest* aRequest,
void HttpChannelChild::SendOnDataFinished(const nsresult& aChannelStatus) {
LOG(("HttpChannelChild::SendOnDataFinished [this=%p]\n", this));
if (MOZ_UNLIKELY(NS_IsMainThread())) {
MOZ_ASSERT(false, "SendOnDataFinished should not be called on main thread");
return;
}
if (mCanceled) return;
// we need to ensure we OnDataFinished only after all the progress
@ -893,7 +898,8 @@ void HttpChannelChild::ProcessOnStopRequest(
RefPtr<RecordStopRequestDelta> timing;
TimeStamp start = TimeStamp::Now();
if (StaticPrefs::network_send_OnDataFinished()) {
if (StaticPrefs::network_send_OnDataFinished() &&
mOMTResult == LABELS_HTTP_CHILD_OMT_STATS::success) {
timing = new RecordStopRequestDelta;
mEventQ->RunOrEnqueue(new ChannelFunctionEvent(
[self = UnsafePtr<HttpChannelChild>(this)]() {
@ -1166,7 +1172,8 @@ void HttpChannelChild::CollectOMTTelemetry() {
nsAutoCString key(
NS_CP_ContentTypeName(mLoadInfo->InternalContentPolicyType()));
Telemetry::AccumulateCategoricalKeyed(key, mOMTResult);
Telemetry::AccumulateCategoricalKeyed(
key, static_cast<LABELS_HTTP_CHILD_OMT_STATS>(mOMTResult));
}
void HttpChannelChild::CollectMixedContentTelemetry() {

View File

@ -312,8 +312,8 @@ class HttpChannelChild final : public PHttpChannelChild,
// The result of RetargetDeliveryTo for this channel.
// |notRequested| represents OMT is not requested by the channel owner.
LABELS_HTTP_CHILD_OMT_STATS mOMTResult =
LABELS_HTTP_CHILD_OMT_STATS::notRequested;
Atomic<LABELS_HTTP_CHILD_OMT_STATS, mozilla::Relaxed> mOMTResult{
LABELS_HTTP_CHILD_OMT_STATS::notRequested};
uint32_t mCacheKey{0};
int32_t mCacheFetchCount{0};

View File

@ -619,14 +619,7 @@ nsIndexedToHTML::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInput,
NS_IMETHODIMP
nsIndexedToHTML::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP