Skip to content

Commit

Permalink
Bug 1873521: Code cleanup r=valentin,necko-reviewers,kershaw
Browse files Browse the repository at this point in the history
  • Loading branch information
jesup committed Jan 16, 2024
1 parent 1549cd5 commit f83e54c
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions netwerk/dns/DNSRequestChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,32 +395,30 @@ DNSRequestSender::Cancel(nsresult reason) {
return NS_ERROR_NOT_AVAILABLE;
}

if (mIPCActor->CanSend()) {
// We can only do IPDL on the main thread
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(runnable.forget());
}
// 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(runnable.forget());
return NS_OK;
}

void DNSRequestSender::StartRequest() {
// we can only do IPDL on the main thread
// we can only do IPC on the MainThread
if (!NS_IsMainThread()) {
SchedulerGroup::Dispatch(
NewRunnableMethod("net::DNSRequestSender::StartRequest", this,
Expand Down

0 comments on commit f83e54c

Please sign in to comment.