Backed out changeset da5a6d4882c2 (bug 1872744) for bustage

This commit is contained in:
Ryan VanderMeulen 2024-09-12 23:32:14 -04:00
parent c828faedcc
commit 38c1338f67

View File

@ -391,27 +391,29 @@ void DNSRequestSender::OnRecvCancelDNSRequest(
NS_IMETHODIMP
DNSRequestSender::Cancel(nsresult reason) {
if (!mIPCActor || !mIPCActor->CanSend()) {
// Really a failure, but we won't be able to tell anyone about it anyways
return NS_OK;
if (!mIPCActor) {
return NS_ERROR_NOT_AVAILABLE;
}
// we can only do IPC on the MainThread
if (!NS_IsMainThread()) {
SchedulerGroup::Dispatch(
NewRunnableMethod<nsresult>("net::DNSRequestSender::Cancel", this,
&DNSRequestSender::Cancel, reason));
return NS_OK;
}
if (DNSRequestChild* child = mIPCActor->AsDNSRequestChild()) {
Unused << child->SendCancelDNSRequest(mHost, mTrrServer, mPort, mType,
mOriginAttributes, mFlags, reason);
} else if (DNSRequestParent* parent = mIPCActor->AsDNSRequestParent()) {
Unused << parent->SendCancelDNSRequest(mHost, mTrrServer, mPort, mType,
mOriginAttributes, mFlags, reason);
}
// We can only do IPC on the MainThread
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction(
"net::CancelDNSRequestEvent",
[actor(mIPCActor), host(mHost), trrServer(mTrrServer), port(mPort),
type(mType), originAttributes(mOriginAttributes), flags(mFlags),
reason]() {
if (!actor->CanSend()) {
return;
}
if (DNSRequestChild* child = actor->AsDNSRequestChild()) {
Unused << child->SendCancelDNSRequest(
host, trrServer, port, type, originAttributes, flags, reason);
} else if (DNSRequestParent* parent = actor->AsDNSRequestParent()) {
Unused << parent->SendCancelDNSRequest(
host, trrServer, port, type, originAttributes, flags, reason);
}
});
SchedulerGroup::Dispatch(TaskCategory::Other, runnable.forget());
return NS_OK;
}