mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1596845
- Pass new DNS record to OnLookupComplete to be able to get effectiveTRRMode and skip reason r=necko-reviewers,kershaw
Depends on D164857 Differential Revision: https://phabricator.services.mozilla.com/D164346
This commit is contained in:
parent
21d7e0ba7e
commit
c816e991b4
@ -269,7 +269,7 @@ NS_IMETHODIMP
|
||||
NetworkConnectivityService::OnLookupComplete(nsICancelable* aRequest,
|
||||
nsIDNSRecord* aRecord,
|
||||
nsresult aStatus) {
|
||||
ConnectivityState state = aRecord ? OK : NOT_AVAILABLE;
|
||||
ConnectivityState state = NS_SUCCEEDED(aStatus) ? OK : NOT_AVAILABLE;
|
||||
|
||||
if (aRequest == mDNSv4Request) {
|
||||
mDNSv4 = state;
|
||||
|
@ -75,21 +75,16 @@ nsresult nsDNSPrefetch::Prefetch(nsIDNSService::DNSFlags flags) {
|
||||
mOriginAttributes, getter_AddRefs(tmpOutstanding));
|
||||
}
|
||||
|
||||
nsresult nsDNSPrefetch::PrefetchLow(bool refreshDNS) {
|
||||
return Prefetch(nsIDNSService::RESOLVE_PRIORITY_LOW |
|
||||
(refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE
|
||||
: nsIDNSService::RESOLVE_DEFAULT_FLAGS));
|
||||
nsresult nsDNSPrefetch::PrefetchLow(nsIDNSService::DNSFlags aFlags) {
|
||||
return Prefetch(nsIDNSService::RESOLVE_PRIORITY_LOW | aFlags);
|
||||
}
|
||||
|
||||
nsresult nsDNSPrefetch::PrefetchMedium(bool refreshDNS) {
|
||||
return Prefetch(nsIDNSService::RESOLVE_PRIORITY_MEDIUM |
|
||||
(refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE
|
||||
: nsIDNSService::RESOLVE_DEFAULT_FLAGS));
|
||||
nsresult nsDNSPrefetch::PrefetchMedium(nsIDNSService::DNSFlags aFlags) {
|
||||
return Prefetch(nsIDNSService::RESOLVE_PRIORITY_MEDIUM | aFlags);
|
||||
}
|
||||
|
||||
nsresult nsDNSPrefetch::PrefetchHigh(bool refreshDNS) {
|
||||
return Prefetch(refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE
|
||||
: nsIDNSService::RESOLVE_DEFAULT_FLAGS);
|
||||
nsresult nsDNSPrefetch::PrefetchHigh(nsIDNSService::DNSFlags aFlags) {
|
||||
return Prefetch(aFlags);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -45,9 +45,12 @@ class nsDNSPrefetch final : public nsIDNSListener {
|
||||
static nsresult Shutdown();
|
||||
|
||||
// Call one of the following methods to start the Prefetch.
|
||||
nsresult PrefetchHigh(bool refreshDNS = false);
|
||||
nsresult PrefetchMedium(bool refreshDNS = false);
|
||||
nsresult PrefetchLow(bool refreshDNS = false);
|
||||
nsresult PrefetchHigh(
|
||||
nsIDNSService::DNSFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS);
|
||||
nsresult PrefetchMedium(
|
||||
nsIDNSService::DNSFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS);
|
||||
nsresult PrefetchLow(
|
||||
nsIDNSService::DNSFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS);
|
||||
|
||||
nsresult FetchHTTPSSVC(
|
||||
bool aRefreshDNS, bool aPrefetch,
|
||||
|
@ -498,7 +498,8 @@ void nsDNSAsyncRequest::OnResolveHostComplete(nsHostResolver* resolver,
|
||||
// the caller to be able to addref/release multiple times without
|
||||
// destroying the record prematurely.
|
||||
nsCOMPtr<nsIDNSRecord> rec;
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
if (NS_SUCCEEDED(status) ||
|
||||
mFlags & nsIDNSService::RESOLVE_WANT_RECORD_ON_ERROR) {
|
||||
MOZ_ASSERT(hostRecord, "no host record");
|
||||
if (hostRecord->type != nsDNSService::RESOLVE_TYPE_DEFAULT) {
|
||||
rec = new nsDNSByTypeRecord(hostRecord);
|
||||
|
@ -90,9 +90,12 @@ interface nsIDNSService : nsISupports
|
||||
RESOLVE_IP_HINT = (1 << 14),
|
||||
// If set, do not use ODoH for resolving the host name.
|
||||
RESOLVE_DISABLE_ODOH = (1 << 15),
|
||||
// If set, the DNS service will pass a DNS record to
|
||||
// OnLookupComplete even when there was a resolution error.
|
||||
RESOLVE_WANT_RECORD_ON_ERROR = (1 << 16),
|
||||
|
||||
// Bitflag containing all possible flags.
|
||||
ALL_DNSFLAGS_BITS = ((1 << 16) - 1),
|
||||
ALL_DNSFLAGS_BITS = ((1 << 17) - 1),
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -779,7 +779,12 @@ void TRRServiceChannel::MaybeStartDNSPrefetch() {
|
||||
mDNSPrefetch =
|
||||
new nsDNSPrefetch(mURI, originAttributes, nsIRequest::GetTRRMode(), this,
|
||||
LoadTimingEnabled());
|
||||
mDNSPrefetch->PrefetchHigh(mCaps & NS_HTTP_REFRESH_DNS);
|
||||
nsIDNSService::DNSFlags dnsFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS;
|
||||
if (mCaps & NS_HTTP_REFRESH_DNS) {
|
||||
dnsFlags |= nsIDNSService::RESOLVE_BYPASS_CACHE;
|
||||
}
|
||||
nsresult rv = mDNSPrefetch->PrefetchHigh(dnsFlags);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -6413,7 +6413,12 @@ nsresult nsHttpChannel::MaybeStartDNSPrefetch() {
|
||||
mDNSPrefetch =
|
||||
new nsDNSPrefetch(mURI, originAttributes, nsIRequest::GetTRRMode(),
|
||||
this, LoadTimingEnabled());
|
||||
nsresult rv = mDNSPrefetch->PrefetchHigh(mCaps & NS_HTTP_REFRESH_DNS);
|
||||
nsIDNSService::DNSFlags dnsFlags =
|
||||
nsIDNSService::RESOLVE_WANT_RECORD_ON_ERROR;
|
||||
if (mCaps & NS_HTTP_REFRESH_DNS) {
|
||||
dnsFlags |= nsIDNSService::RESOLVE_BYPASS_CACHE;
|
||||
}
|
||||
nsresult rv = mDNSPrefetch->PrefetchHigh(dnsFlags);
|
||||
|
||||
if (dnsStrategy & DNS_BLOCK_ON_ORIGIN_RESOLVE) {
|
||||
LOG((" blocking on prefetching origin"));
|
||||
|
Loading…
Reference in New Issue
Block a user