diff --git a/dom/html/HTMLDNSPrefetch.cpp b/dom/html/HTMLDNSPrefetch.cpp index 2c3562b39e5b..a4043195fed1 100644 --- a/dom/html/HTMLDNSPrefetch.cpp +++ b/dom/html/HTMLDNSPrefetch.cpp @@ -96,7 +96,7 @@ class DeferredDNSPrefetches final : public nsIWebProgressListener, DeferredDNSPrefetches(); void Activate(); - nsresult Add(uint32_t flags, SupportsDNSPrefetch&, Element&); + nsresult Add(nsIDNSService::DNSFlags flags, SupportsDNSPrefetch&, Element&); void RemoveUnboundLinks(); @@ -105,7 +105,7 @@ class DeferredDNSPrefetches final : public nsIWebProgressListener, void Flush(); void SubmitQueue(); - void SubmitQueueEntry(Element&, uint32_t aFlags); + void SubmitQueueEntry(Element&, nsIDNSService::DNSFlags aFlags); uint16_t mHead; uint16_t mTail; @@ -119,7 +119,7 @@ class DeferredDNSPrefetches final : public nsIWebProgressListener, static const int sMaxDeferredMask = (sMaxDeferred - 1); struct deferred_entry { - uint32_t mFlags; + nsIDNSService::DNSFlags mFlags; // SupportsDNSPrefetch clears this raw pointer in Destroyed(). Element* mElement; } mEntries[sMaxDeferred]; @@ -184,25 +184,26 @@ bool HTMLDNSPrefetch::IsAllowed(Document* aDocument) { return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow(); } -static uint32_t GetDNSFlagsFromElement(Element& aElement) { +static nsIDNSService::DNSFlags GetDNSFlagsFromElement(Element& aElement) { nsIChannel* channel = aElement.OwnerDoc()->GetChannel(); if (!channel) { - return 0; + return nsIDNSService::RESOLVE_DEFAULT_FLAGS; } return nsIDNSService::GetFlagsFromTRRMode(channel->GetTRRMode()); } -uint32_t HTMLDNSPrefetch::PriorityToDNSServiceFlags(Priority aPriority) { +nsIDNSService::DNSFlags HTMLDNSPrefetch::PriorityToDNSServiceFlags( + Priority aPriority) { switch (aPriority) { case Priority::Low: - return uint32_t(nsIDNSService::RESOLVE_PRIORITY_LOW); + return nsIDNSService::RESOLVE_PRIORITY_LOW; case Priority::Medium: - return uint32_t(nsIDNSService::RESOLVE_PRIORITY_MEDIUM); + return nsIDNSService::RESOLVE_PRIORITY_MEDIUM; case Priority::High: - return 0u; + return nsIDNSService::RESOLVE_DEFAULT_FLAGS; } MOZ_ASSERT_UNREACHABLE("Unknown priority"); - return 0u; + return nsIDNSService::RESOLVE_DEFAULT_FLAGS; } nsresult HTMLDNSPrefetch::Prefetch(SupportsDNSPrefetch& aSupports, @@ -219,7 +220,7 @@ nsresult HTMLDNSPrefetch::Prefetch(SupportsDNSPrefetch& aSupports, nsresult HTMLDNSPrefetch::Prefetch( const nsAString& hostname, bool isHttps, const OriginAttributes& aPartitionedPrincipalOriginAttributes, - uint32_t flags) { + nsIDNSService::DNSFlags flags) { if (IsNeckoChild()) { // We need to check IsEmpty() because net_IsValidHostName() // considers empty strings to be valid hostnames @@ -276,7 +277,7 @@ nsresult HTMLDNSPrefetch::CancelPrefetch(SupportsDNSPrefetch& aSupports, return NS_ERROR_NOT_AVAILABLE; } - uint32_t flags = + nsIDNSService::DNSFlags flags = GetDNSFlagsFromElement(aElement) | PriorityToDNSServiceFlags(aPriority); nsIURI* uri = aSupports.GetURIForDNSPrefetch(aElement); @@ -301,7 +302,7 @@ nsresult HTMLDNSPrefetch::CancelPrefetch(SupportsDNSPrefetch& aSupports, nsresult HTMLDNSPrefetch::CancelPrefetch( const nsAString& hostname, bool isHttps, const OriginAttributes& aPartitionedPrincipalOriginAttributes, - uint32_t flags, nsresult aReason) { + nsIDNSService::DNSFlags flags, nsresult aReason) { // Forward this request to Necko Parent if we're a child process if (IsNeckoChild()) { // We need to check IsEmpty() because net_IsValidHostName() @@ -409,7 +410,7 @@ void DeferredDNSPrefetches::Flush() { } } -nsresult DeferredDNSPrefetches::Add(uint32_t flags, +nsresult DeferredDNSPrefetches::Add(nsIDNSService::DNSFlags flags, SupportsDNSPrefetch& aSupports, Element& aElement) { // The FIFO has no lock, so it can only be accessed on main thread @@ -460,7 +461,7 @@ void DeferredDNSPrefetches::SubmitQueue() { } void DeferredDNSPrefetches::SubmitQueueEntry(Element& aElement, - uint32_t aFlags) { + nsIDNSService::DNSFlags aFlags) { auto& supports = ToSupportsDNSPrefetch(aElement); supports.ClearIsInDNSPrefetch(); diff --git a/dom/html/HTMLDNSPrefetch.h b/dom/html/HTMLDNSPrefetch.h index 38ea8177de5d..5820a6ecb2f9 100644 --- a/dom/html/HTMLDNSPrefetch.h +++ b/dom/html/HTMLDNSPrefetch.h @@ -10,6 +10,7 @@ #include "nsCOMPtr.h" #include "nsIRequest.h" #include "nsString.h" +#include "nsIDNSService.h" class nsITimer; class nsIURI; @@ -68,16 +69,16 @@ class HTMLDNSPrefetch { static void ElementDestroyed(Element&, SupportsDNSPrefetch&); private: - static uint32_t PriorityToDNSServiceFlags(Priority); + static nsIDNSService::DNSFlags PriorityToDNSServiceFlags(Priority); static nsresult Prefetch( const nsAString& host, bool isHttps, const OriginAttributes& aPartitionedPrincipalOriginAttributes, - uint32_t flags); + nsIDNSService::DNSFlags flags); static nsresult CancelPrefetch( const nsAString& hostname, bool isHttps, const OriginAttributes& aPartitionedPrincipalOriginAttributes, - uint32_t flags, nsresult aReason); + nsIDNSService::DNSFlags flags, nsresult aReason); friend class net::NeckoParent; }; diff --git a/dom/media/webrtc/transport/nriceresolver.cpp b/dom/media/webrtc/transport/nriceresolver.cpp index 00553270b68e..e1737e0e651a 100644 --- a/dom/media/webrtc/transport/nriceresolver.cpp +++ b/dom/media/webrtc/transport/nriceresolver.cpp @@ -147,7 +147,7 @@ int NrIceResolver::resolve(nr_resolver_resource* resource, MOZ_ASSERT(allocated_resolvers_ > 0); ASSERT_ON_THREAD(sts_thread_); RefPtr pr; - uint32_t resolve_flags = 0; + nsIDNSService::DNSFlags resolve_flags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; OriginAttributes attrs; if (resource->transport_protocol != IPPROTO_UDP && @@ -162,10 +162,10 @@ int NrIceResolver::resolve(nr_resolver_resource* resource, switch (resource->address_family) { case AF_INET: - resolve_flags |= nsIDNSService::RESOLVE_DISABLE_IPV6; + resolve_flags = nsIDNSService::RESOLVE_DISABLE_IPV6; break; case AF_INET6: - resolve_flags |= nsIDNSService::RESOLVE_DISABLE_IPV4; + resolve_flags = nsIDNSService::RESOLVE_DISABLE_IPV4; break; default: ABORT(R_BAD_ARGS); diff --git a/netwerk/base/Dashboard.cpp b/netwerk/base/Dashboard.cpp index c512aa0642a0..56f3171942f6 100644 --- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -943,7 +943,8 @@ Dashboard::RequestDNSLookup(const nsACString& aHost, helper->mEventTarget = GetCurrentEventTarget(); OriginAttributes attrs; rv = mDnsService->AsyncResolveNative( - aHost, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0, nullptr, helper.get(), + aHost, nsIDNSService::RESOLVE_TYPE_DEFAULT, + nsIDNSService::RESOLVE_DEFAULT_FLAGS, nullptr, helper.get(), NS_GetCurrentThread(), attrs, getter_AddRefs(helper->mCancel)); return rv; } @@ -966,7 +967,8 @@ Dashboard::RequestDNSHTTPSRRLookup(const nsACString& aHost, helper->mEventTarget = GetCurrentEventTarget(); OriginAttributes attrs; rv = mDnsService->AsyncResolveNative( - aHost, nsIDNSService::RESOLVE_TYPE_HTTPSSVC, 0, nullptr, helper.get(), + aHost, nsIDNSService::RESOLVE_TYPE_HTTPSSVC, + nsIDNSService::RESOLVE_DEFAULT_FLAGS, nullptr, helper.get(), NS_GetCurrentThread(), attrs, getter_AddRefs(helper->mCancel)); return rv; } diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 487cf8921884..9113a683f8a2 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -239,7 +239,7 @@ bool ProxyAutoConfig::ResolveAddress(const nsACString& aHostName, // When the PAC script attempts to resolve a domain, we must make sure we // don't use TRR, otherwise the TRR channel might also attempt to resolve // a name and we'll have a deadlock. - uint32_t flags = + nsIDNSService::DNSFlags flags = nsIDNSService::RESOLVE_PRIORITY_MEDIUM | nsIDNSService::GetFlagsFromTRRMode(nsIRequest::TRR_DISABLED_MODE); diff --git a/netwerk/base/nsDNSPrefetch.cpp b/netwerk/base/nsDNSPrefetch.cpp index b19a2e3e9f52..bd5ce0429fdd 100644 --- a/netwerk/base/nsDNSPrefetch.cpp +++ b/netwerk/base/nsDNSPrefetch.cpp @@ -53,7 +53,7 @@ nsDNSPrefetch::nsDNSPrefetch(nsIURI* aURI, aURI->GetAsciiHost(mHostname); } -nsresult nsDNSPrefetch::Prefetch(uint32_t flags) { +nsresult nsDNSPrefetch::Prefetch(nsIDNSService::DNSFlags flags) { if (mHostname.IsEmpty()) return NS_ERROR_NOT_AVAILABLE; if (!sDNSService) return NS_ERROR_NOT_AVAILABLE; @@ -77,16 +77,19 @@ nsresult nsDNSPrefetch::Prefetch(uint32_t flags) { nsresult nsDNSPrefetch::PrefetchLow(bool refreshDNS) { return Prefetch(nsIDNSService::RESOLVE_PRIORITY_LOW | - (refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE : 0)); + (refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE + : nsIDNSService::RESOLVE_DEFAULT_FLAGS)); } nsresult nsDNSPrefetch::PrefetchMedium(bool refreshDNS) { return Prefetch(nsIDNSService::RESOLVE_PRIORITY_MEDIUM | - (refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE : 0)); + (refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE + : nsIDNSService::RESOLVE_DEFAULT_FLAGS)); } nsresult nsDNSPrefetch::PrefetchHigh(bool refreshDNS) { - return Prefetch(refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE : 0); + return Prefetch(refreshDNS ? nsIDNSService::RESOLVE_BYPASS_CACHE + : nsIDNSService::RESOLVE_DEFAULT_FLAGS); } namespace { @@ -130,7 +133,7 @@ nsresult nsDNSPrefetch::FetchHTTPSSVC( } nsCOMPtr target = mozilla::GetCurrentEventTarget(); - uint32_t flags = nsIDNSService::GetFlagsFromTRRMode(mTRRMode); + nsIDNSService::DNSFlags flags = nsIDNSService::GetFlagsFromTRRMode(mTRRMode); if (aRefreshDNS) { flags |= nsIDNSService::RESOLVE_BYPASS_CACHE; } diff --git a/netwerk/base/nsDNSPrefetch.h b/netwerk/base/nsDNSPrefetch.h index d30fa6d2891f..13e85f500768 100644 --- a/netwerk/base/nsDNSPrefetch.h +++ b/netwerk/base/nsDNSPrefetch.h @@ -16,9 +16,9 @@ #include "nsIDNSListener.h" #include "nsIRequest.h" +#include "nsIDNSService.h" class nsIURI; -class nsIDNSService; class nsIDNSHTTPSSVCRecord; class nsDNSPrefetch final : public nsIDNSListener { @@ -63,7 +63,7 @@ class nsDNSPrefetch final : public nsIDNSListener { mozilla::TimeStamp mEndTimestamp; nsWeakPtr mListener; - nsresult Prefetch(uint32_t flags); + nsresult Prefetch(nsIDNSService::DNSFlags flags); }; #endif diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index a800651f3d45..941e45c502c0 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -987,7 +987,7 @@ nsresult nsSocketTransport::ResolveHost() { mResolving = true; - uint32_t dnsFlags = 0; + nsIDNSService::DNSFlags dnsFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; if (mConnectionFlags & nsSocketTransport::BYPASS_CACHE) { dnsFlags = nsIDNSService::RESOLVE_BYPASS_CACHE; } diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 2d296e80c99b..860483cb3c35 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -67,8 +67,9 @@ static nsresult ResolveHost(const nsACString& host, } nsCOMPtr tmpOutstanding; - return dns->AsyncResolveNative(host, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0, - nullptr, listener, nullptr, aOriginAttributes, + return dns->AsyncResolveNative(host, nsIDNSService::RESOLVE_TYPE_DEFAULT, + nsIDNSService::RESOLVE_DEFAULT_FLAGS, nullptr, + listener, nullptr, aOriginAttributes, getter_AddRefs(tmpOutstanding)); } diff --git a/netwerk/dns/ChildDNSService.cpp b/netwerk/dns/ChildDNSService.cpp index d2bc2c36c011..1b0f3f73dad7 100644 --- a/netwerk/dns/ChildDNSService.cpp +++ b/netwerk/dns/ChildDNSService.cpp @@ -68,8 +68,9 @@ ChildDNSService::ChildDNSService() { void ChildDNSService::GetDNSRecordHashKey( const nsACString& aHost, const nsACString& aTrrServer, int32_t aPort, - uint16_t aType, const OriginAttributes& aOriginAttributes, uint32_t aFlags, - uintptr_t aListenerAddr, nsACString& aHashKey) { + uint16_t aType, const OriginAttributes& aOriginAttributes, + nsIDNSService::DNSFlags aFlags, uintptr_t aListenerAddr, + nsACString& aHashKey) { aHashKey.Assign(aHost); aHashKey.Assign(aTrrServer); aHashKey.AppendInt(aPort); @@ -84,7 +85,7 @@ void ChildDNSService::GetDNSRecordHashKey( } nsresult ChildDNSService::AsyncResolveInternal( - const nsACString& hostname, uint16_t type, uint32_t flags, + const nsACString& hostname, uint16_t type, nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* listener, nsIEventTarget* target_, const OriginAttributes& aOriginAttributes, nsICancelable** result) { @@ -157,7 +158,7 @@ nsresult ChildDNSService::AsyncResolveInternal( } nsresult ChildDNSService::CancelAsyncResolveInternal( - const nsACString& aHostname, uint16_t aType, uint32_t aFlags, + const nsACString& aHostname, uint16_t aType, nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsresult aReason, const OriginAttributes& aOriginAttributes) { if (mDisablePrefetch && (aFlags & RESOLVE_SPECULATE)) { @@ -185,7 +186,8 @@ nsresult ChildDNSService::CancelAsyncResolveInternal( NS_IMETHODIMP ChildDNSService::AsyncResolve(const nsACString& hostname, - nsIDNSService::ResolveType aType, uint32_t flags, + nsIDNSService::ResolveType aType, + nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* listener, nsIEventTarget* target_, JS::Handle aOriginAttributes, @@ -204,13 +206,11 @@ ChildDNSService::AsyncResolve(const nsACString& hostname, } NS_IMETHODIMP -ChildDNSService::AsyncResolveNative(const nsACString& hostname, - nsIDNSService::ResolveType aType, - uint32_t flags, nsIDNSAdditionalInfo* aInfo, - nsIDNSListener* listener, - nsIEventTarget* target_, - const OriginAttributes& aOriginAttributes, - nsICancelable** result) { +ChildDNSService::AsyncResolveNative( + const nsACString& hostname, nsIDNSService::ResolveType aType, + nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, + nsIDNSListener* listener, nsIEventTarget* target_, + const OriginAttributes& aOriginAttributes, nsICancelable** result) { return AsyncResolveInternal(hostname, aType, flags, aInfo, listener, target_, aOriginAttributes, result); } @@ -226,7 +226,7 @@ ChildDNSService::NewAdditionalInfo(const nsACString& aTrrURL, int32_t aPort, NS_IMETHODIMP ChildDNSService::CancelAsyncResolve(const nsACString& aHostname, nsIDNSService::ResolveType aType, - uint32_t aFlags, + nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsresult aReason, JS::Handle aOriginAttributes, @@ -246,14 +246,16 @@ ChildDNSService::CancelAsyncResolve(const nsACString& aHostname, NS_IMETHODIMP ChildDNSService::CancelAsyncResolveNative( const nsACString& aHostname, nsIDNSService::ResolveType aType, - uint32_t aFlags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, - nsresult aReason, const OriginAttributes& aOriginAttributes) { + nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, + nsIDNSListener* aListener, nsresult aReason, + const OriginAttributes& aOriginAttributes) { return CancelAsyncResolveInternal(aHostname, aType, aFlags, aInfo, aListener, aReason, aOriginAttributes); } NS_IMETHODIMP -ChildDNSService::Resolve(const nsACString& hostname, uint32_t flags, +ChildDNSService::Resolve(const nsACString& hostname, + nsIDNSService::DNSFlags flags, JS::Handle aOriginAttributes, JSContext* aCx, uint8_t aArgc, nsIDNSRecord** result) { // not planning to ever support this, since sync IPDL is evil. @@ -261,7 +263,8 @@ ChildDNSService::Resolve(const nsACString& hostname, uint32_t flags, } NS_IMETHODIMP -ChildDNSService::ResolveNative(const nsACString& hostname, uint32_t flags, +ChildDNSService::ResolveNative(const nsACString& hostname, + nsIDNSService::DNSFlags flags, const OriginAttributes& aOriginAttributes, nsIDNSRecord** result) { // not planning to ever support this, since sync IPDL is evil. @@ -368,7 +371,8 @@ ChildDNSService::GetODoHActivated(bool* aResult) { void ChildDNSService::NotifyRequestDone(DNSRequestSender* aDnsRequest) { // We need the original flags and listener for the pending requests hash. - uint32_t originalFlags = aDnsRequest->mFlags & ~RESOLVE_OFFLINE; + nsIDNSService::DNSFlags originalFlags = + aDnsRequest->mFlags & ~RESOLVE_OFFLINE; uintptr_t originalListenerAddr = reinterpret_cast(aDnsRequest->mListener.get()); RefPtr wrapper = do_QueryObject(aDnsRequest->mListener); diff --git a/netwerk/dns/ChildDNSService.h b/netwerk/dns/ChildDNSService.h index 72bfeaa9a2cb..4d92f3abf5f3 100644 --- a/netwerk/dns/ChildDNSService.h +++ b/netwerk/dns/ChildDNSService.h @@ -44,16 +44,19 @@ class ChildDNSService final : public DNSServiceBase, public nsPIDNSService { void MOZ_ALWAYS_INLINE GetDNSRecordHashKey( const nsACString& aHost, const nsACString& aTrrServer, int32_t aPort, uint16_t aType, const OriginAttributes& aOriginAttributes, - uint32_t aFlags, uintptr_t aListenerAddr, nsACString& aHashKey); + nsIDNSService::DNSFlags aFlags, uintptr_t aListenerAddr, + nsACString& aHashKey); nsresult AsyncResolveInternal(const nsACString& hostname, uint16_t type, - uint32_t flags, nsIDNSAdditionalInfo* aInfo, + nsIDNSService::DNSFlags flags, + nsIDNSAdditionalInfo* aInfo, nsIDNSListener* listener, nsIEventTarget* target_, const OriginAttributes& aOriginAttributes, nsICancelable** result); nsresult CancelAsyncResolveInternal( - const nsACString& aHostname, uint16_t aType, uint32_t aFlags, - nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsresult aReason, + const nsACString& aHostname, uint16_t aType, + nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, + nsIDNSListener* aListener, nsresult aReason, const OriginAttributes& aOriginAttributes); bool mODoHActivated = false; diff --git a/netwerk/dns/DNSRequestBase.h b/netwerk/dns/DNSRequestBase.h index 850aadaca4d9..7b26846f5e26 100644 --- a/netwerk/dns/DNSRequestBase.h +++ b/netwerk/dns/DNSRequestBase.h @@ -35,7 +35,7 @@ class DNSRequestBase : public nsISupports { const nsCString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, + const nsIDNSService::DNSFlags& flags, const nsresult& reason) = 0; virtual bool OnRecvLookupCompleted(const DNSRequestResponse& reply) = 0; virtual void OnIPCActorDestroy() = 0; @@ -60,14 +60,14 @@ class DNSRequestSender final : public DNSRequestBase, public nsICancelable { DNSRequestSender(const nsACString& aHost, const nsACString& aTrrServer, int32_t aPort, const uint16_t& aType, const OriginAttributes& aOriginAttributes, - const uint32_t& aFlags, nsIDNSListener* aListener, - nsIEventTarget* target); + const nsIDNSService::DNSFlags& aFlags, + nsIDNSListener* aListener, nsIEventTarget* target); void OnRecvCancelDNSRequest(const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, + const nsIDNSService::DNSFlags& flags, const nsresult& reason) override; bool OnRecvLookupCompleted(const DNSRequestResponse& reply) override; void OnIPCActorDestroy() override; @@ -92,7 +92,7 @@ class DNSRequestSender final : public DNSRequestBase, public nsICancelable { int32_t mPort; uint16_t mType = 0; const OriginAttributes mOriginAttributes; - uint16_t mFlags = 0; + nsIDNSService::DNSFlags mFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; }; // DNSRequestHandler handles the dns request and sends the result back via IPC. @@ -106,13 +106,14 @@ class DNSRequestHandler final : public DNSRequestBase, public nsIDNSListener { void DoAsyncResolve(const nsACString& hostname, const nsACString& trrServer, int32_t port, uint16_t type, - const OriginAttributes& originAttributes, uint32_t flags); + const OriginAttributes& originAttributes, + nsIDNSService::DNSFlags flags); void OnRecvCancelDNSRequest(const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, + const nsIDNSService::DNSFlags& flags, const nsresult& reason) override; bool OnRecvLookupCompleted(const DNSRequestResponse& reply) override; void OnIPCActorDestroy() override; @@ -123,7 +124,7 @@ class DNSRequestHandler final : public DNSRequestBase, public nsIDNSListener { private: virtual ~DNSRequestHandler() = default; - uint32_t mFlags = 0; + nsIDNSService::DNSFlags mFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; }; // Provides some common methods for DNSRequestChild and DNSRequestParent. diff --git a/netwerk/dns/DNSRequestChild.cpp b/netwerk/dns/DNSRequestChild.cpp index 2d8056d0a23a..e792706e007b 100644 --- a/netwerk/dns/DNSRequestChild.cpp +++ b/netwerk/dns/DNSRequestChild.cpp @@ -42,7 +42,7 @@ class ChildDNSRecord : public nsIDNSAddrRecord { NS_DECL_NSIDNSRECORD NS_DECL_NSIDNSADDRRECORD - ChildDNSRecord(const DNSRecord& reply, uint16_t flags); + ChildDNSRecord(const DNSRecord& reply, nsIDNSService::DNSFlags flags); private: virtual ~ChildDNSRecord() = default; @@ -50,7 +50,7 @@ class ChildDNSRecord : public nsIDNSAddrRecord { nsCString mCanonicalName; nsTArray mAddresses; uint32_t mCurrent = 0; // addr iterator - uint16_t mFlags = 0; + nsIDNSService::DNSFlags mFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; double mTrrFetchDuration = 0; double mTrrFetchDurationNetworkOnly = 0; bool mIsTRR = false; @@ -62,7 +62,8 @@ class ChildDNSRecord : public nsIDNSAddrRecord { NS_IMPL_ISUPPORTS(ChildDNSRecord, nsIDNSRecord, nsIDNSAddrRecord) -ChildDNSRecord::ChildDNSRecord(const DNSRecord& reply, uint16_t flags) +ChildDNSRecord::ChildDNSRecord(const DNSRecord& reply, + nsIDNSService::DNSFlags flags) : mFlags(flags) { mCanonicalName = reply.canonicalName(); mTrrFetchDuration = reply.trrFetchDuration(); @@ -362,10 +363,13 @@ ChildDNSByTypeRecord::GetTtl(uint32_t* aResult) { NS_IMPL_ISUPPORTS(DNSRequestSender, nsICancelable) -DNSRequestSender::DNSRequestSender( - const nsACString& aHost, const nsACString& aTrrServer, int32_t aPort, - const uint16_t& aType, const OriginAttributes& aOriginAttributes, - const uint32_t& aFlags, nsIDNSListener* aListener, nsIEventTarget* target) +DNSRequestSender::DNSRequestSender(const nsACString& aHost, + const nsACString& aTrrServer, int32_t aPort, + const uint16_t& aType, + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags, + nsIDNSListener* aListener, + nsIEventTarget* target) : mListener(aListener), mTarget(target), mResultStatus(NS_OK), @@ -379,7 +383,7 @@ DNSRequestSender::DNSRequestSender( void DNSRequestSender::OnRecvCancelDNSRequest( const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, const nsresult& reason) {} + const nsIDNSService::DNSFlags& flags, const nsresult& reason) {} NS_IMETHODIMP DNSRequestSender::Cancel(nsresult reason) { @@ -546,7 +550,7 @@ DNSRequestChild::DNSRequestChild(DNSRequestBase* aRequest) mozilla::ipc::IPCResult DNSRequestChild::RecvCancelDNSRequest( const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, const nsresult& reason) { + const nsIDNSService::DNSFlags& flags, const nsresult& reason) { mDNSRequest->OnRecvCancelDNSRequest(hostName, trrServer, port, type, originAttributes, flags, reason); return IPC_OK(); diff --git a/netwerk/dns/DNSRequestChild.h b/netwerk/dns/DNSRequestChild.h index 678aff2043a7..064c2425e097 100644 --- a/netwerk/dns/DNSRequestChild.h +++ b/netwerk/dns/DNSRequestChild.h @@ -30,8 +30,8 @@ class DNSRequestChild final : public DNSRequestActor, public PDNSRequestChild { mozilla::ipc::IPCResult RecvCancelDNSRequest( const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, - const OriginAttributes& originAttributes, const uint32_t& flags, - const nsresult& reason); + const OriginAttributes& originAttributes, + const nsIDNSService::DNSFlags& flags, const nsresult& reason); mozilla::ipc::IPCResult RecvLookupCompleted(const DNSRequestResponse& reply); virtual void ActorDestroy(ActorDestroyReason why) override; }; diff --git a/netwerk/dns/DNSRequestParent.cpp b/netwerk/dns/DNSRequestParent.cpp index ef87c05af8c6..3b6ebf00afa9 100644 --- a/netwerk/dns/DNSRequestParent.cpp +++ b/netwerk/dns/DNSRequestParent.cpp @@ -40,7 +40,7 @@ void DNSRequestHandler::DoAsyncResolve(const nsACString& hostname, const nsACString& trrServer, int32_t port, uint16_t type, const OriginAttributes& originAttributes, - uint32_t flags) { + nsIDNSService::DNSFlags flags) { nsresult rv; mFlags = flags; nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv); @@ -64,7 +64,7 @@ void DNSRequestHandler::DoAsyncResolve(const nsACString& hostname, void DNSRequestHandler::OnRecvCancelDNSRequest( const nsCString& hostName, const nsCString& aTrrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, const nsresult& reason) { + const nsIDNSService::DNSFlags& flags, const nsresult& reason) { nsresult rv; nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { @@ -159,7 +159,7 @@ DNSRequestParent::DNSRequestParent(DNSRequestBase* aRequest) mozilla::ipc::IPCResult DNSRequestParent::RecvCancelDNSRequest( const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& originAttributes, - const uint32_t& flags, const nsresult& reason) { + const nsIDNSService::DNSFlags& flags, const nsresult& reason) { mDNSRequest->OnRecvCancelDNSRequest(hostName, trrServer, port, type, originAttributes, flags, reason); return IPC_OK(); diff --git a/netwerk/dns/DNSRequestParent.h b/netwerk/dns/DNSRequestParent.h index 94eaf13cfd40..7583709678f0 100644 --- a/netwerk/dns/DNSRequestParent.h +++ b/netwerk/dns/DNSRequestParent.h @@ -33,8 +33,8 @@ class DNSRequestParent : public DNSRequestActor, public PDNSRequestParent { mozilla::ipc::IPCResult RecvCancelDNSRequest( const nsCString& hostName, const nsCString& trrServer, const int32_t& port, const uint16_t& type, - const OriginAttributes& originAttributes, const uint32_t& flags, - const nsresult& reason); + const OriginAttributes& originAttributes, + const nsIDNSService::DNSFlags& flags, const nsresult& reason); mozilla::ipc::IPCResult RecvLookupCompleted(const DNSRequestResponse& reply); void ActorDestroy(ActorDestroyReason) override; }; diff --git a/netwerk/dns/HostRecordQueue.cpp b/netwerk/dns/HostRecordQueue.cpp index 9b256959e87f..104cbe70284d 100644 --- a/netwerk/dns/HostRecordQueue.cpp +++ b/netwerk/dns/HostRecordQueue.cpp @@ -10,7 +10,8 @@ namespace mozilla { namespace net { -void HostRecordQueue::InsertRecord(nsHostRecord* aRec, uint16_t aFlags, +void HostRecordQueue::InsertRecord(nsHostRecord* aRec, + nsIDNSService::DNSFlags aFlags, const MutexAutoLock& aProofOfLock) { if (aRec->isInList()) { MOZ_DIAGNOSTIC_ASSERT(!mEvictionQ.contains(aRec), @@ -155,7 +156,8 @@ void HostRecordQueue::MaybeRemoveFromQ(nsHostRecord* aRec, aRec->remove(); } -void HostRecordQueue::MoveToAnotherPendingQ(nsHostRecord* aRec, uint16_t aFlags, +void HostRecordQueue::MoveToAnotherPendingQ(nsHostRecord* aRec, + nsIDNSService::DNSFlags aFlags, const MutexAutoLock& aProofOfLock) { if (!(mHighQ.contains(aRec) || mMediumQ.contains(aRec) || mLowQ.contains(aRec))) { diff --git a/netwerk/dns/HostRecordQueue.h b/netwerk/dns/HostRecordQueue.h index d3bc0b86f6e1..dc77d43be62a 100644 --- a/netwerk/dns/HostRecordQueue.h +++ b/netwerk/dns/HostRecordQueue.h @@ -26,7 +26,7 @@ class HostRecordQueue final { // Insert the record to mHighQ or mMediumQ or mLowQ based on the record's // priority. - void InsertRecord(nsHostRecord* aRec, uint16_t aFlags, + void InsertRecord(nsHostRecord* aRec, nsIDNSService::DNSFlags aFlags, const MutexAutoLock& aProofOfLock); // Insert the record to mEvictionQ. In theory, this function should be called // when the record is not in any queue. @@ -45,7 +45,7 @@ class HostRecordQueue final { // Remove the record from the queue that contains it. void MaybeRemoveFromQ(nsHostRecord* aRec, const MutexAutoLock& aProofOfLock); // When the record's priority changes, move the record between pending queues. - void MoveToAnotherPendingQ(nsHostRecord* aRec, uint16_t aFlags, + void MoveToAnotherPendingQ(nsHostRecord* aRec, nsIDNSService::DNSFlags aFlags, const MutexAutoLock& aProofOfLock); // Returning the first record from one of the pending queue. When |aHighQOnly| // is true, returning the record from mHighQ only. When false, return the diff --git a/netwerk/dns/ODoHService.cpp b/netwerk/dns/ODoHService.cpp index eda9d1f8542a..6a5efc3717b2 100644 --- a/netwerk/dns/ODoHService.cpp +++ b/netwerk/dns/ODoHService.cpp @@ -331,7 +331,7 @@ nsresult ODoHService::UpdateODoHConfigFromHTTPSRR() { nsCOMPtr target = TRRService::Get()->MainThreadOrTRRThread(); // We'd like to bypass the DNS cache, since ODoHConfigs will be updated // manually by ODoHService. - uint32_t flags = + nsIDNSService::DNSFlags flags = nsIDNSService::RESOLVE_DISABLE_ODOH | nsIDNSService::RESOLVE_BYPASS_CACHE; nsCOMPtr info; if (port != -1) { diff --git a/netwerk/dns/PDNSRequest.ipdl b/netwerk/dns/PDNSRequest.ipdl index 0ac361e8a222..0613ff67b46c 100644 --- a/netwerk/dns/PDNSRequest.ipdl +++ b/netwerk/dns/PDNSRequest.ipdl @@ -13,6 +13,7 @@ include PDNSRequestParams; include "mozilla/net/NeckoMessageUtils.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h"; +using nsIDNSService::DNSFlags from "nsIDNSService.h"; namespace mozilla { namespace net { @@ -28,7 +29,7 @@ both: // needed if the request is to be canceled. async CancelDNSRequest(nsCString hostName, nsCString trrServer, int32_t port, uint16_t type, OriginAttributes originAttributes, - uint32_t flags, nsresult reason); + DNSFlags flags, nsresult reason); async __delete__(); async LookupCompleted(DNSRequestResponse reply); diff --git a/netwerk/dns/TRRQuery.h b/netwerk/dns/TRRQuery.h index e53a0459a373..14f08ac7ac39 100644 --- a/netwerk/dns/TRRQuery.h +++ b/netwerk/dns/TRRQuery.h @@ -43,8 +43,8 @@ class TRRQuery : public AHostResolver { uint32_t aTtl, bool pb) override; virtual nsresult GetHostRecord(const nsACString& host, const nsACString& aTrrServer, uint16_t type, - uint16_t flags, uint16_t af, bool pb, - const nsCString& originSuffix, + nsIDNSService::DNSFlags flags, uint16_t af, + bool pb, const nsCString& originSuffix, nsHostRecord** result) override { if (!mHostResolver) { return NS_ERROR_FAILURE; diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index 336e4f909273..cc434e9bdcda 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -457,7 +457,7 @@ class nsDNSAsyncRequest final : public nsResolveHostCallback, nsDNSAsyncRequest(nsHostResolver* res, const nsACString& host, const nsACString& trrServer, uint16_t type, const OriginAttributes& attrs, nsIDNSListener* listener, - uint16_t flags, uint16_t af) + nsIDNSService::DNSFlags flags, uint16_t af) : mResolver(res), mHost(host), mTrrServer(trrServer), @@ -482,7 +482,7 @@ class nsDNSAsyncRequest final : public nsResolveHostCallback, const OriginAttributes mOriginAttributes; // The originAttributes for this resolving nsCOMPtr mListener; - uint16_t mFlags = 0; + nsIDNSService::DNSFlags mFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; uint16_t mAF = 0; private: @@ -981,7 +981,7 @@ nsresult nsDNSService::PreprocessHostname(bool aLocalDomain, } nsresult nsDNSService::AsyncResolveInternal( - const nsACString& aHostname, uint16_t type, uint32_t flags, + const nsACString& aHostname, uint16_t type, nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsIEventTarget* target_, const OriginAttributes& aOriginAttributes, nsICancelable** result) { @@ -1064,7 +1064,7 @@ nsresult nsDNSService::AsyncResolveInternal( } nsresult nsDNSService::CancelAsyncResolveInternal( - const nsACString& aHostname, uint16_t aType, uint32_t aFlags, + const nsACString& aHostname, uint16_t aType, nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsresult aReason, const OriginAttributes& aOriginAttributes) { // grab reference to global host resolver and IDN service. beware @@ -1103,7 +1103,8 @@ nsresult nsDNSService::CancelAsyncResolveInternal( NS_IMETHODIMP nsDNSService::AsyncResolve(const nsACString& aHostname, - nsIDNSService::ResolveType aType, uint32_t flags, + nsIDNSService::ResolveType aType, + nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* listener, nsIEventTarget* target_, JS::Handle aOriginAttributes, @@ -1122,13 +1123,11 @@ nsDNSService::AsyncResolve(const nsACString& aHostname, } NS_IMETHODIMP -nsDNSService::AsyncResolveNative(const nsACString& aHostname, - nsIDNSService::ResolveType aType, - uint32_t flags, nsIDNSAdditionalInfo* aInfo, - nsIDNSListener* aListener, - nsIEventTarget* target_, - const OriginAttributes& aOriginAttributes, - nsICancelable** result) { +nsDNSService::AsyncResolveNative( + const nsACString& aHostname, nsIDNSService::ResolveType aType, + nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, + nsIDNSListener* aListener, nsIEventTarget* target_, + const OriginAttributes& aOriginAttributes, nsICancelable** result) { return AsyncResolveInternal(aHostname, aType, flags, aInfo, aListener, target_, aOriginAttributes, result); } @@ -1144,7 +1143,8 @@ nsDNSService::NewAdditionalInfo(const nsACString& aTrrURL, int32_t aPort, NS_IMETHODIMP nsDNSService::CancelAsyncResolve(const nsACString& aHostname, nsIDNSService::ResolveType aType, - uint32_t aFlags, nsIDNSAdditionalInfo* aInfo, + nsIDNSService::DNSFlags aFlags, + nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsresult aReason, JS::Handle aOriginAttributes, JSContext* aCx, uint8_t aArgc) { @@ -1163,14 +1163,16 @@ nsDNSService::CancelAsyncResolve(const nsACString& aHostname, NS_IMETHODIMP nsDNSService::CancelAsyncResolveNative( const nsACString& aHostname, nsIDNSService::ResolveType aType, - uint32_t aFlags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, - nsresult aReason, const OriginAttributes& aOriginAttributes) { + nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, + nsIDNSListener* aListener, nsresult aReason, + const OriginAttributes& aOriginAttributes) { return CancelAsyncResolveInternal(aHostname, aType, aFlags, aInfo, aListener, aReason, aOriginAttributes); } NS_IMETHODIMP -nsDNSService::Resolve(const nsACString& aHostname, uint32_t flags, +nsDNSService::Resolve(const nsACString& aHostname, + nsIDNSService::DNSFlags flags, JS::Handle aOriginAttributes, JSContext* aCx, uint8_t aArgc, nsIDNSRecord** result) { OriginAttributes attrs; @@ -1185,7 +1187,8 @@ nsDNSService::Resolve(const nsACString& aHostname, uint32_t flags, } NS_IMETHODIMP -nsDNSService::ResolveNative(const nsACString& aHostname, uint32_t flags, +nsDNSService::ResolveNative(const nsACString& aHostname, + nsIDNSService::DNSFlags flags, const OriginAttributes& aOriginAttributes, nsIDNSRecord** result) { // Synchronous resolution is not available on the main thread. @@ -1197,13 +1200,13 @@ nsDNSService::ResolveNative(const nsACString& aHostname, uint32_t flags, } nsresult nsDNSService::DeprecatedSyncResolve( - const nsACString& aHostname, uint32_t flags, + const nsACString& aHostname, nsIDNSService::DNSFlags flags, const OriginAttributes& aOriginAttributes, nsIDNSRecord** result) { return ResolveInternal(aHostname, flags, aOriginAttributes, result); } nsresult nsDNSService::ResolveInternal( - const nsACString& aHostname, uint32_t flags, + const nsACString& aHostname, nsIDNSService::DNSFlags flags, const OriginAttributes& aOriginAttributes, nsIDNSRecord** result) { // grab reference to global host resolver and IDN service. beware // simultaneous shutdown!! @@ -1338,7 +1341,8 @@ nsDNSService::Observe(nsISupports* subject, const char* topic, return NS_OK; } -uint16_t nsDNSService::GetAFForLookup(const nsACString& host, uint32_t flags) { +uint16_t nsDNSService::GetAFForLookup(const nsACString& host, + nsIDNSService::DNSFlags flags) { if (mDisableIPv6 || (flags & RESOLVE_DISABLE_IPV6)) { return PR_AF_INET; } diff --git a/netwerk/dns/nsDNSService2.h b/netwerk/dns/nsDNSService2.h index 6bb562a2190a..cd516289d026 100644 --- a/netwerk/dns/nsDNSService2.h +++ b/netwerk/dns/nsDNSService2.h @@ -67,7 +67,7 @@ class nsDNSService final : public mozilla::net::DNSServiceBase, friend class DNSServiceWrapper; nsresult DeprecatedSyncResolve( - const nsACString& aHostname, uint32_t flags, + const nsACString& aHostname, nsIDNSService::DNSFlags flags, const mozilla::OriginAttributes& aOriginAttributes, nsIDNSRecord** result); @@ -77,24 +77,27 @@ class nsDNSService final : public mozilla::net::DNSServiceBase, void ReadPrefs(const char* name) override; static already_AddRefed GetSingleton(); - uint16_t GetAFForLookup(const nsACString& host, uint32_t flags); + uint16_t GetAFForLookup(const nsACString& host, + nsIDNSService::DNSFlags flags); nsresult PreprocessHostname(bool aLocalDomain, const nsACString& aInput, nsIIDNService* aIDN, nsACString& aACE); nsresult AsyncResolveInternal( - const nsACString& aHostname, uint16_t type, uint32_t flags, + const nsACString& aHostname, uint16_t type, nsIDNSService::DNSFlags flags, nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsIEventTarget* target_, const mozilla::OriginAttributes& aOriginAttributes, nsICancelable** result); nsresult CancelAsyncResolveInternal( - const nsACString& aHostname, uint16_t aType, uint32_t aFlags, - nsIDNSAdditionalInfo* aInfo, nsIDNSListener* aListener, nsresult aReason, + const nsACString& aHostname, uint16_t aType, + nsIDNSService::DNSFlags aFlags, nsIDNSAdditionalInfo* aInfo, + nsIDNSListener* aListener, nsresult aReason, const mozilla::OriginAttributes& aOriginAttributes); - nsresult ResolveInternal(const nsACString& aHostname, uint32_t flags, + nsresult ResolveInternal(const nsACString& aHostname, + nsIDNSService::DNSFlags flags, const mozilla::OriginAttributes& aOriginAttributes, nsIDNSRecord** result); diff --git a/netwerk/dns/nsHostRecord.cpp b/netwerk/dns/nsHostRecord.cpp index cf10c50f363b..fab4cb6e9490 100644 --- a/netwerk/dns/nsHostRecord.cpp +++ b/netwerk/dns/nsHostRecord.cpp @@ -29,8 +29,8 @@ using namespace mozilla; using namespace mozilla::net; nsHostKey::nsHostKey(const nsACString& aHost, const nsACString& aTrrServer, - uint16_t aType, uint16_t aFlags, uint16_t aAf, bool aPb, - const nsACString& aOriginsuffix) + uint16_t aType, nsIDNSService::DNSFlags aFlags, + uint16_t aAf, bool aPb, const nsACString& aOriginsuffix) : host(aHost), mTrrServer(aTrrServer), type(aType), @@ -119,7 +119,7 @@ void nsHostRecord::CopyExpirationTimesAndFlagsFrom( } bool nsHostRecord::HasUsableResult(const mozilla::TimeStamp& now, - uint16_t queryFlags) const { + nsIDNSService::DNSFlags queryFlags) const { if (mDoomed) { return false; } @@ -221,8 +221,8 @@ size_t AddrHostRecord::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const { return n; } -bool AddrHostRecord::HasUsableResultInternal(const mozilla::TimeStamp& now, - uint16_t queryFlags) const { +bool AddrHostRecord::HasUsableResultInternal( + const mozilla::TimeStamp& now, nsIDNSService::DNSFlags queryFlags) const { // don't use cached negative results for high priority queries. if (negative && IsHighPriority(queryFlags)) { return false; @@ -411,7 +411,8 @@ void AddrHostRecord::ResolveComplete() { } } -AddrHostRecord::DnsPriority AddrHostRecord::GetPriority(uint16_t aFlags) { +AddrHostRecord::DnsPriority AddrHostRecord::GetPriority( + nsIDNSService::DNSFlags aFlags) { if (IsHighPriority(aFlags)) { return AddrHostRecord::DNS_PRIORITY_HIGH; } @@ -440,8 +441,8 @@ TypeHostRecord::TypeHostRecord(const nsHostKey& key) TypeHostRecord::~TypeHostRecord() { mCallbacks.clear(); } -bool TypeHostRecord::HasUsableResultInternal(const mozilla::TimeStamp& now, - uint16_t queryFlags) const { +bool TypeHostRecord::HasUsableResultInternal( + const mozilla::TimeStamp& now, nsIDNSService::DNSFlags queryFlags) const { if (CheckExpiration(now) == EXP_EXPIRED) { return false; } diff --git a/netwerk/dns/nsHostRecord.h b/netwerk/dns/nsHostRecord.h index 95a2108903c2..00fd91f20acf 100644 --- a/netwerk/dns/nsHostRecord.h +++ b/netwerk/dns/nsHostRecord.h @@ -79,13 +79,13 @@ struct nsHostKey { const nsCString host; const nsCString mTrrServer; uint16_t type = 0; - uint16_t flags = 0; + nsIDNSService::DNSFlags flags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; uint16_t af = 0; bool pb = false; const nsCString originSuffix; explicit nsHostKey(const nsACString& host, const nsACString& aTrrServer, - uint16_t type, uint16_t flags, uint16_t af, bool pb, - const nsACString& originSuffix); + uint16_t type, nsIDNSService::DNSFlags flags, uint16_t af, + bool pb, const nsACString& originSuffix); bool operator==(const nsHostKey& other) const; size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; PLDHashNumber Hash() const; @@ -150,13 +150,15 @@ class nsHostRecord : public mozilla::LinkedListElement>, // Checks if the record is usable (not expired and has a value) bool HasUsableResult(const mozilla::TimeStamp& now, - uint16_t queryFlags = 0) const; + nsIDNSService::DNSFlags queryFlags = + nsIDNSService::RESOLVE_DEFAULT_FLAGS) const; - static DnsPriority GetPriority(uint16_t aFlags); + static DnsPriority GetPriority(nsIDNSService::DNSFlags aFlags); virtual void Cancel(); - virtual bool HasUsableResultInternal(const mozilla::TimeStamp& now, - uint16_t queryFlags) const = 0; + virtual bool HasUsableResultInternal( + const mozilla::TimeStamp& now, + nsIDNSService::DNSFlags queryFlags) const = 0; virtual bool RefreshForNegativeResponse() const { return true; } mozilla::LinkedList> mCallbacks; @@ -283,8 +285,9 @@ class AddrHostRecord final : public nsHostRecord { ~AddrHostRecord(); // Checks if the record is usable (not expired and has a value) - bool HasUsableResultInternal(const mozilla::TimeStamp& now, - uint16_t queryFlags) const override; + bool HasUsableResultInternal( + const mozilla::TimeStamp& now, + nsIDNSService::DNSFlags queryFlags) const override; bool RemoveOrRefresh(bool aTrrToo); // Mark records currently being resolved // as needed to resolve again. @@ -294,7 +297,7 @@ class AddrHostRecord final : public nsHostRecord { void NotifyRetryingTrr(); void ResolveComplete(); - static DnsPriority GetPriority(uint16_t aFlags); + static DnsPriority GetPriority(nsIDNSService::DNSFlags aFlags); // true if pending and on the queue (not yet given to getaddrinfo()) bool onQueue() { return LoadNative() && isInList(); } @@ -375,8 +378,9 @@ class TypeHostRecord final : public nsHostRecord, ~TypeHostRecord(); // Checks if the record is usable (not expired and has a value) - bool HasUsableResultInternal(const mozilla::TimeStamp& now, - uint16_t queryFlags) const override; + bool HasUsableResultInternal( + const mozilla::TimeStamp& now, + nsIDNSService::DNSFlags queryFlags) const override; bool RefreshForNegativeResponse() const override; mozilla::net::TypeRecordResultType mResults = AsVariant(mozilla::Nothing()); @@ -391,16 +395,16 @@ class TypeHostRecord final : public nsHostRecord, NS_DEFINE_STATIC_IID_ACCESSOR(TypeHostRecord, TYPEHOSTRECORD_IID) -static inline bool IsHighPriority(uint16_t flags) { +static inline bool IsHighPriority(nsIDNSService::DNSFlags flags) { return !(flags & (nsHostRecord::DNS_PRIORITY_LOW | nsHostRecord::DNS_PRIORITY_MEDIUM)); } -static inline bool IsMediumPriority(uint16_t flags) { +static inline bool IsMediumPriority(nsIDNSService::DNSFlags flags) { return flags & nsHostRecord::DNS_PRIORITY_MEDIUM; } -static inline bool IsLowPriority(uint16_t flags) { +static inline bool IsLowPriority(nsIDNSService::DNSFlags flags) { return flags & nsHostRecord::DNS_PRIORITY_LOW; } diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index dfb4931c107e..29b475f8f6e9 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -350,12 +350,10 @@ void nsHostResolver::Shutdown() { } } -nsresult nsHostResolver::GetHostRecord(const nsACString& host, - const nsACString& aTrrServer, - uint16_t type, uint16_t flags, - uint16_t af, bool pb, - const nsCString& originSuffix, - nsHostRecord** result) { +nsresult nsHostResolver::GetHostRecord( + const nsACString& host, const nsACString& aTrrServer, uint16_t type, + nsIDNSService::DNSFlags flags, uint16_t af, bool pb, + const nsCString& originSuffix, nsHostRecord** result) { MutexAutoLock lock(mLock); nsHostKey key(host, aTrrServer, type, flags, af, pb, originSuffix); @@ -420,7 +418,7 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost, const nsACString& aTrrServer, int32_t aPort, uint16_t type, const OriginAttributes& aOriginAttributes, - uint16_t flags, uint16_t af, + nsIDNSService::DNSFlags flags, uint16_t af, nsResolveHostCallback* aCallback) { nsAutoCString host(aHost); NS_ENSURE_TRUE(!host.IsEmpty(), NS_ERROR_UNEXPECTED); @@ -480,7 +478,7 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost, bool excludedFromTRR = false; if (TRRService::Get() && TRRService::Get()->IsExcludedFromTRR(host)) { - flags |= RES_DISABLE_TRR; + flags |= nsIDNSService::RESOLVE_DISABLE_TRR; excludedFromTRR = true; if (!aTrrServer.IsEmpty()) { @@ -681,8 +679,8 @@ already_AddRefed nsHostResolver::FromIPLiteral( already_AddRefed nsHostResolver::FromUnspecEntry( nsHostRecord* aRec, const nsACString& aHost, const nsACString& aTrrServer, - const nsACString& aOriginSuffix, uint16_t aType, uint16_t aFlags, - uint16_t af, bool aPb, nsresult& aStatus) { + const nsACString& aOriginSuffix, uint16_t aType, + nsIDNSService::DNSFlags aFlags, uint16_t af, bool aPb, nsresult& aStatus) { RefPtr result = nullptr; // If this is an IPV4 or IPV6 specific request, check if there is // an AF_UNSPEC entry we can use. Otherwise, hit the resolver... @@ -773,8 +771,8 @@ already_AddRefed nsHostResolver::FromUnspecEntry( void nsHostResolver::DetachCallback( const nsACString& host, const nsACString& aTrrServer, uint16_t aType, - const OriginAttributes& aOriginAttributes, uint16_t flags, uint16_t af, - nsResolveHostCallback* aCallback, nsresult status) { + const OriginAttributes& aOriginAttributes, nsIDNSService::DNSFlags flags, + uint16_t af, nsResolveHostCallback* aCallback, nsresult status) { RefPtr rec; RefPtr callback(aCallback); @@ -1108,7 +1106,7 @@ nsresult nsHostResolver::NameLookup(nsHostRecord* rec, return NS_ERROR_UNKNOWN_HOST; } - if (rec->flags & RES_DISABLE_TRR) { + if (rec->flags & nsIDNSService::RESOLVE_DISABLE_TRR) { LOG(("TRR with server and DISABLE_TRR flag. Returning error.")); return NS_ERROR_UNKNOWN_HOST; } @@ -1118,20 +1116,22 @@ nsresult nsHostResolver::NameLookup(nsHostRecord* rec, LOG(("NameLookup: %s effectiveTRRmode: %d flags: %X", rec->host.get(), rec->mEffectiveTRRMode, rec->flags)); - if (rec->flags & RES_DISABLE_TRR) { + if (rec->flags & nsIDNSService::RESOLVE_DISABLE_TRR) { rec->RecordReason(TRRSkippedReason::TRR_DISABLED_FLAG); } bool serviceNotReady = !TRRServiceEnabledForRecord(rec); if (rec->mEffectiveTRRMode != nsIRequest::TRR_DISABLED_MODE && - !((rec->flags & RES_DISABLE_TRR)) && !serviceNotReady) { + !((rec->flags & nsIDNSService::RESOLVE_DISABLE_TRR)) && + !serviceNotReady) { rv = TrrLookup(rec, aLock); } if (rec->mEffectiveTRRMode == nsIRequest::TRR_DISABLED_MODE || (rec->mEffectiveTRRMode == nsIRequest::TRR_FIRST_MODE && - (rec->flags & RES_DISABLE_TRR || serviceNotReady || NS_FAILED(rv)))) { + (rec->flags & nsIDNSService::RESOLVE_DISABLE_TRR || serviceNotReady || + NS_FAILED(rv)))) { if (!rec->IsAddrRecord()) { return rv; } @@ -1558,7 +1558,9 @@ nsHostResolver::LookupStatus nsHostResolver::CompleteLookupLocked( !rec->mResolving && sGetTtlEnabled) { LOG(("Issuing second async lookup for TTL for host [%s].", addrRec->host.get())); - addrRec->flags = (addrRec->flags & ~RES_PRIORITY_MEDIUM) | RES_PRIORITY_LOW; + addrRec->flags = + (addrRec->flags & ~nsIDNSService::RESOLVE_PRIORITY_MEDIUM) | + nsIDNSService::RESOLVE_PRIORITY_LOW; DebugOnly rv = NativeLookup(rec, aLock); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Could not issue second async lookup for TTL."); @@ -1644,8 +1646,8 @@ nsHostResolver::LookupStatus nsHostResolver::CompleteLookupByTypeLocked( void nsHostResolver::CancelAsyncRequest( const nsACString& host, const nsACString& aTrrServer, uint16_t aType, - const OriginAttributes& aOriginAttributes, uint16_t flags, uint16_t af, - nsIDNSListener* aListener, nsresult status) + const OriginAttributes& aOriginAttributes, nsIDNSService::DNSFlags flags, + uint16_t af, nsIDNSListener* aListener, nsresult status) { MutexAutoLock lock(mLock); diff --git a/netwerk/dns/nsHostResolver.h b/netwerk/dns/nsHostResolver.h index 3467b3884a75..7b715ff767d9 100644 --- a/netwerk/dns/nsHostResolver.h +++ b/netwerk/dns/nsHostResolver.h @@ -70,8 +70,8 @@ class AHostResolver { uint32_t aTtl, bool pb) = 0; virtual nsresult GetHostRecord(const nsACString& host, const nsACString& aTrrServer, uint16_t type, - uint16_t flags, uint16_t af, bool pb, - const nsCString& originSuffix, + nsIDNSService::DNSFlags flags, uint16_t af, + bool pb, const nsCString& originSuffix, nsHostRecord** result) { return NS_ERROR_FAILURE; } @@ -123,7 +123,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { nsresult ResolveHost(const nsACString& aHost, const nsACString& trrServer, int32_t aPort, uint16_t type, const mozilla::OriginAttributes& aOriginAttributes, - uint16_t flags, uint16_t af, + nsIDNSService::DNSFlags flags, uint16_t af, nsResolveHostCallback* callback); nsHostRecord* InitRecord(const nsHostKey& key); @@ -147,7 +147,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { void DetachCallback(const nsACString& hostname, const nsACString& trrServer, uint16_t type, const mozilla::OriginAttributes& aOriginAttributes, - uint16_t flags, uint16_t af, + nsIDNSService::DNSFlags flags, uint16_t af, nsResolveHostCallback* callback, nsresult status); /** @@ -160,7 +160,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { void CancelAsyncRequest(const nsACString& host, const nsACString& trrServer, uint16_t type, const mozilla::OriginAttributes& aOriginAttributes, - uint16_t flags, uint16_t af, + nsIDNSService::DNSFlags flags, uint16_t af, nsIDNSListener* aListener, nsresult status); /** * values for the flags parameter passed to ResolveHost and DetachCallback @@ -199,8 +199,8 @@ class nsHostResolver : public nsISupports, public AHostResolver { mozilla::net::TypeRecordResultType& aResult, uint32_t aTtl, bool pb) override; nsresult GetHostRecord(const nsACString& host, const nsACString& trrServer, - uint16_t type, uint16_t flags, uint16_t af, bool pb, - const nsCString& originSuffix, + uint16_t type, nsIDNSService::DNSFlags flags, + uint16_t af, bool pb, const nsCString& originSuffix, nsHostRecord** result) override; nsresult TrrLookup_unlocked(nsHostRecord*, mozilla::net::TRR* pushedTRR = nullptr) override; @@ -281,8 +281,9 @@ class nsHostResolver : public nsISupports, public AHostResolver { // Called to check if we have an AF_UNSPEC entry in the cache. already_AddRefed FromUnspecEntry( nsHostRecord* aRec, const nsACString& aHost, const nsACString& aTrrServer, - const nsACString& aOriginSuffix, uint16_t aType, uint16_t aFlags, - uint16_t af, bool aPb, nsresult& aStatus) MOZ_REQUIRES(mLock); + const nsACString& aOriginSuffix, uint16_t aType, + nsIDNSService::DNSFlags aFlags, uint16_t af, bool aPb, nsresult& aStatus) + MOZ_REQUIRES(mLock); enum { METHOD_HIT = 1, diff --git a/netwerk/dns/nsIDNSService.idl b/netwerk/dns/nsIDNSService.idl index 1179e5dd3e92..895eb153b208 100644 --- a/netwerk/dns/nsIDNSService.idl +++ b/netwerk/dns/nsIDNSService.idl @@ -8,6 +8,7 @@ %{ C++ #include "mozilla/BasePrincipal.h" +#include "mozilla/TypedEnumBits.h" %} interface nsICancelable; @@ -51,6 +52,49 @@ interface nsIDNSService : nsISupports MODE_TRROFF = 5 // identical to MODE_NATIVEONLY but explicitly selected }; + cenum DNSFlags : 32 { + RESOLVE_DEFAULT_FLAGS = 0, + // if set, this flag suppresses the internal DNS lookup cache. + RESOLVE_BYPASS_CACHE = (1 << 0), + // if set, the canonical name of the specified host will be queried. + RESOLVE_CANONICAL_NAME = (1 << 1), + // If PRIORITY flags are set, the query is given lower priority. + // Medium takes precedence if both MEDIUM and LOW are used. + RESOLVE_PRIORITY_MEDIUM = (1 << 2), + RESOLVE_PRIORITY_LOW = (1 << 3), + // if set, indicates request is speculative. Speculative requests + // return errors if prefetching is disabled by configuration. + RESOLVE_SPECULATE = (1 << 4), + // If set, only IPv4 addresses will be returned from resolve/asyncResolve. + RESOLVE_DISABLE_IPV6 = (1 << 5), + // If set, only literals and cached entries will be returned from resolve/asyncResolve. + RESOLVE_OFFLINE = (1 << 6), + // If set, only IPv6 addresses will be returned from resolve/asyncResolve. + RESOLVE_DISABLE_IPV4 = (1 << 7), + // If set, allow name collision results (127.0.53.53) which are normally filtered. + RESOLVE_ALLOW_NAME_COLLISION = (1 << 8), + // If set, do not use TRR for resolving the host name. + RESOLVE_DISABLE_TRR = (1 << 9), + // if set (together with RESOLVE_BYPASS_CACHE), invalidate the DNS + // existing cache entry first (if existing) then make a new resolve. + RESOLVE_REFRESH_CACHE = (1 << 10), + // These two bits encode the TRR mode of the request. + // Use the static helper methods GetFlagsFromTRRMode and + // GetTRRModeFromFlags to convert between the TRR mode and flags. + RESOLVE_TRR_MODE_MASK = (1 << 11) | (1 << 12), + RESOLVE_TRR_DISABLED_MODE = (1 << 11), + // Force resolution even when SOCKS proxy with DNS forwarding is configured. + // Only to be used for the proxy host resolution. + RESOLVE_IGNORE_SOCKS_DNS = (1 << 13), + // If set, only cached IP hint addresses will be returned from resolve/asyncResolve. + RESOLVE_IP_HINT = (1 << 14), + // If set, do not use ODoH for resolving the host name. + RESOLVE_DISABLE_ODOH = (1 << 15), + + // Bitflag containing all possible flags. + ALL_DNSFLAGS_BITS = ((1 << 16) - 1), + }; + /** * kicks off an asynchronous host lookup. * @@ -84,7 +128,7 @@ interface nsIDNSService : nsISupports [implicit_jscontext, optional_argc] nsICancelable asyncResolve(in AUTF8String aHostName, in nsIDNSService_ResolveType aType, - in unsigned long aFlags, + in nsIDNSService_DNSFlags aFlags, in nsIDNSAdditionalInfo aInfo, in nsIDNSListener aListener, in nsIEventTarget aListenerTarget, @@ -93,7 +137,7 @@ interface nsIDNSService : nsISupports [notxpcom] nsresult asyncResolveNative(in AUTF8String aHostName, in nsIDNSService_ResolveType aType, - in unsigned long aFlags, + in nsIDNSService_DNSFlags aFlags, in nsIDNSAdditionalInfo aInfo, in nsIDNSListener aListener, in nsIEventTarget aListenerTarget, @@ -133,7 +177,7 @@ interface nsIDNSService : nsISupports [implicit_jscontext, optional_argc] void cancelAsyncResolve(in AUTF8String aHostName, in nsIDNSService_ResolveType aType, - in unsigned long aFlags, + in nsIDNSService_DNSFlags aFlags, in nsIDNSAdditionalInfo aResolver, in nsIDNSListener aListener, in nsresult aReason, @@ -142,7 +186,7 @@ interface nsIDNSService : nsISupports [notxpcom] nsresult cancelAsyncResolveNative(in AUTF8String aHostName, in nsIDNSService_ResolveType aType, - in unsigned long aFlags, + in nsIDNSService_DNSFlags aFlags, in nsIDNSAdditionalInfo aResolver, in nsIDNSListener aListener, in nsresult aReason, @@ -169,12 +213,12 @@ interface nsIDNSService : nsISupports */ [implicit_jscontext, optional_argc] nsIDNSRecord resolve(in AUTF8String aHostName, - in unsigned long aFlags, + in nsIDNSService_DNSFlags aFlags, [optional] in jsval aOriginAttributes); [notxpcom] nsresult resolveNative(in AUTF8String aHostName, - in unsigned long aFlags, + in nsIDNSService_DNSFlags aFlags, in OriginAttributes aOriginAttributes, out nsIDNSRecord aResult); @@ -275,93 +319,16 @@ interface nsIDNSService : nsISupports * the aFlags parameter passed to asyncResolve() and resolve(). */ - /** - * if set, this flag suppresses the internal DNS lookup cache. - */ - const unsigned long RESOLVE_BYPASS_CACHE = (1 << 0); - - /** - * if set, the canonical name of the specified host will be queried. - */ - const unsigned long RESOLVE_CANONICAL_NAME = (1 << 1); - - /** - * if set, the query is given lower priority. Medium takes precedence - * if both are used. - */ - const unsigned long RESOLVE_PRIORITY_MEDIUM = (1 << 2); - const unsigned long RESOLVE_PRIORITY_LOW = (1 << 3); - - /** - * if set, indicates request is speculative. Speculative requests - * return errors if prefetching is disabled by configuration. - */ - const unsigned long RESOLVE_SPECULATE = (1 << 4); - - /** - * If set, only IPv4 addresses will be returned from resolve/asyncResolve. - */ - const unsigned long RESOLVE_DISABLE_IPV6 = (1 << 5); - - /** - * If set, only literals and cached entries will be returned from resolve/ - * asyncResolve. - */ - const unsigned long RESOLVE_OFFLINE = (1 << 6); - - /** - * If set, only IPv6 addresses will be returned from resolve/asyncResolve. - */ - const unsigned long RESOLVE_DISABLE_IPV4 = (1 << 7); - - /** - * If set, allow name collision results (127.0.53.53) which are normally filtered. - */ - const unsigned long RESOLVE_ALLOW_NAME_COLLISION = (1 << 8); - - /** - * If set, do not use TRR for resolving the host name. - */ - const unsigned long RESOLVE_DISABLE_TRR = (1 << 9); - - /** - * if set (together with RESOLVE_BYPASS_CACHE), invalidate the DNS - * existing cache entry first (if existing) then make a new resolve. - */ - const unsigned long RESOLVE_REFRESH_CACHE = (1 << 10); - - /** - * These two bits encode the TRR mode of the request. - * Use the static helper methods convert between the TRR mode and flags. - */ - const unsigned long RESOLVE_TRR_MODE_MASK = (1 << 11) | (1 << 12); - const unsigned long RESOLVE_TRR_DISABLED_MODE = (1 << 11); %{C++ - static uint32_t GetFlagsFromTRRMode(nsIRequest::TRRMode aMode) { - return static_cast(aMode) << 11; + static nsIDNSService::DNSFlags GetFlagsFromTRRMode(nsIRequest::TRRMode aMode) { + return static_cast(static_cast(aMode) << 11); } - static nsIRequest::TRRMode GetTRRModeFromFlags(uint32_t aFlags) { + static nsIRequest::TRRMode GetTRRModeFromFlags(nsIDNSService::DNSFlags aFlags) { return static_cast((aFlags & RESOLVE_TRR_MODE_MASK) >> 11); } %} - /** - * Force resolution even when SOCKS proxy with DNS forwarding is configured. - * Only to be used for the proxy host resolution. - */ - const unsigned long RESOLVE_IGNORE_SOCKS_DNS = 1 << 13; - - /** - * If set, only cached IP hint addresses will be returned from - * resolve/asyncResolve. - */ - const unsigned long RESOLVE_IP_HINT = 1 << 14; - - /** - * If set, do not use ODoH for resolving the host name. - */ - const unsigned long RESOLVE_DISABLE_ODOH = 1 << 15; }; %{C++ @@ -378,5 +345,7 @@ interface nsIDNSService : nsISupports */ #define NS_NETWORK_TRR_MODE_CHANGED_TOPIC "network:trr-mode-changed" +MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsIDNSService::DNSFlags) + %} diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index 712f9737d94c..d419d0f602c9 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -18,6 +18,7 @@ #include "mozilla/net/DNS.h" #include "ipc/IPCMessageUtilsSpecializations.h" #include "nsITRRSkipReason.h" +#include "nsIDNSService.h" namespace IPC { @@ -160,6 +161,12 @@ struct ParamTraits { } }; +template <> +struct ParamTraits + : public BitFlagsEnumSerializer< + nsIDNSService::DNSFlags, nsIDNSService::DNSFlags::ALL_DNSFLAGS_BITS> { +}; + } // namespace IPC #endif // mozilla_net_NeckoMessageUtils_h diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index 5c7a6dd0fb63..7fc681d5996b 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -504,7 +504,7 @@ bool NeckoParent::DeallocPUDPSocketParent(PUDPSocketParent* actor) { already_AddRefed NeckoParent::AllocPDNSRequestParent( const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, const OriginAttributes& aOriginAttributes, - const uint32_t& aFlags) { + const nsIDNSService::DNSFlags& aFlags) { RefPtr handler = new DNSRequestHandler(); RefPtr actor = new DNSRequestParent(handler); return actor.forget(); @@ -513,7 +513,8 @@ already_AddRefed NeckoParent::AllocPDNSRequestParent( mozilla::ipc::IPCResult NeckoParent::RecvPDNSRequestConstructor( PDNSRequestParent* aActor, const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, - const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) { + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags) { RefPtr actor = static_cast(aActor); RefPtr handler = actor->GetDNSRequest()->AsDNSRequestHandler(); @@ -541,15 +542,16 @@ mozilla::ipc::IPCResult NeckoParent::RecvSpeculativeConnect( mozilla::ipc::IPCResult NeckoParent::RecvHTMLDNSPrefetch( const nsAString& hostname, const bool& isHttps, - const OriginAttributes& aOriginAttributes, const uint32_t& flags) { + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& flags) { dom::HTMLDNSPrefetch::Prefetch(hostname, isHttps, aOriginAttributes, flags); return IPC_OK(); } mozilla::ipc::IPCResult NeckoParent::RecvCancelHTMLDNSPrefetch( const nsAString& hostname, const bool& isHttps, - const OriginAttributes& aOriginAttributes, const uint32_t& flags, - const nsresult& reason) { + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& flags, const nsresult& reason) { dom::HTMLDNSPrefetch::CancelPrefetch(hostname, isHttps, aOriginAttributes, flags, reason); return IPC_OK(); diff --git a/netwerk/ipc/NeckoParent.h b/netwerk/ipc/NeckoParent.h index 3811b712b273..f382779a1b62 100644 --- a/netwerk/ipc/NeckoParent.h +++ b/netwerk/ipc/NeckoParent.h @@ -116,22 +116,24 @@ class NeckoParent : public PNeckoParent { already_AddRefed AllocPDNSRequestParent( const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, - const OriginAttributes& aOriginAttributes, const uint32_t& aFlags); + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags); virtual mozilla::ipc::IPCResult RecvPDNSRequestConstructor( PDNSRequestParent* actor, const nsACString& aHost, const nsACString& trrServer, const int32_t& aPort, const uint16_t& type, const OriginAttributes& aOriginAttributes, - const uint32_t& flags) override; + const nsIDNSService::DNSFlags& flags) override; mozilla::ipc::IPCResult RecvSpeculativeConnect(nsIURI* aURI, nsIPrincipal* aPrincipal, const bool& aAnonymous); mozilla::ipc::IPCResult RecvHTMLDNSPrefetch( const nsAString& hostname, const bool& isHttps, - const OriginAttributes& aOriginAttributes, const uint32_t& flags); + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& flags); mozilla::ipc::IPCResult RecvCancelHTMLDNSPrefetch( const nsAString& hostname, const bool& isHttps, - const OriginAttributes& aOriginAttributes, const uint32_t& flags, - const nsresult& reason); + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& flags, const nsresult& reason); PWebSocketEventListenerParent* AllocPWebSocketEventListenerParent( const uint64_t& aInnerWindowID); bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent*); diff --git a/netwerk/ipc/PNecko.ipdl b/netwerk/ipc/PNecko.ipdl index b760932b8224..9b89b79e836c 100644 --- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -36,6 +36,7 @@ include "mozilla/dom/PermissionMessageUtils.h"; using mozilla::dom::MaybeDiscardedBrowsingContext from "mozilla/dom/BrowsingContext.h"; using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h"; +using nsIDNSService::DNSFlags from "nsIDNSService.h"; [RefCounted] using class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h"; [RefCounted] using class nsIURI from "mozilla/ipc/URIUtils.h"; [RefCounted] using class nsIPrincipal from "nsIPrincipal.h"; @@ -83,7 +84,7 @@ parent: async PDNSRequest(nsCString hostName, nsCString trrServer, int32_t port, uint16_t type, OriginAttributes originAttributes, - uint32_t flags); + DNSFlags flags); async PDocumentChannel(MaybeDiscardedBrowsingContext browsingContext, DocumentChannelCreationArgs args); @@ -100,10 +101,10 @@ parent: async SpeculativeConnect(nsIURI uri, nsIPrincipal principal, bool anonymous); async HTMLDNSPrefetch(nsString hostname, bool isHttps, - OriginAttributes originAttributes, uint32_t flags); + OriginAttributes originAttributes, DNSFlags flags); async CancelHTMLDNSPrefetch(nsString hostname, bool isHttps, OriginAttributes originAttributes, - uint32_t flags, nsresult reason); + DNSFlags flags, nsresult reason); /** * channelId is used to establish a connection between redirect channels in diff --git a/netwerk/ipc/PSocketProcess.ipdl b/netwerk/ipc/PSocketProcess.ipdl index 24fd0974cb2f..40a559364e8c 100644 --- a/netwerk/ipc/PSocketProcess.ipdl +++ b/netwerk/ipc/PSocketProcess.ipdl @@ -45,6 +45,7 @@ using struct nsID from "nsID.h"; using mozilla::net::SocketInfo from "mozilla/net/DashboardTypes.h"; using mozilla::net::DNSCacheEntries from "mozilla/net/DashboardTypes.h"; using mozilla::net::HttpRetParams from "mozilla/net/DashboardTypes.h"; +using nsIDNSService::DNSFlags from "nsIDNSService.h"; #if defined(XP_WIN) [MoveOnly] using mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h"; @@ -216,7 +217,7 @@ child: both: async PDNSRequest(nsCString hostName, nsCString trrServer, int32_t port, uint16_t type, OriginAttributes originAttributes, - uint32_t flags); + DNSFlags flags); }; } // namespace net diff --git a/netwerk/ipc/SocketProcessChild.cpp b/netwerk/ipc/SocketProcessChild.cpp index 3b79220c4409..97fccc35ccde 100644 --- a/netwerk/ipc/SocketProcessChild.cpp +++ b/netwerk/ipc/SocketProcessChild.cpp @@ -429,7 +429,7 @@ SocketProcessChild::AllocPAltSvcTransactionChild( already_AddRefed SocketProcessChild::AllocPDNSRequestChild( const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, const OriginAttributes& aOriginAttributes, - const uint32_t& aFlags) { + const nsIDNSService::DNSFlags& aFlags) { RefPtr handler = new DNSRequestHandler(); RefPtr actor = new DNSRequestChild(handler); return actor.forget(); @@ -438,7 +438,8 @@ already_AddRefed SocketProcessChild::AllocPDNSRequestChild( mozilla::ipc::IPCResult SocketProcessChild::RecvPDNSRequestConstructor( PDNSRequestChild* aActor, const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, - const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) { + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags) { RefPtr actor = static_cast(aActor); RefPtr handler = actor->GetDNSRequest()->AsDNSRequestHandler(); diff --git a/netwerk/ipc/SocketProcessChild.h b/netwerk/ipc/SocketProcessChild.h index 2bdd674142bf..2f01ae47acdc 100644 --- a/netwerk/ipc/SocketProcessChild.h +++ b/netwerk/ipc/SocketProcessChild.h @@ -91,12 +91,13 @@ class SocketProcessChild final : public PSocketProcessChild { already_AddRefed AllocPDNSRequestChild( const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, - const OriginAttributes& aOriginAttributes, const uint32_t& aFlags); + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags); mozilla::ipc::IPCResult RecvPDNSRequestConstructor( PDNSRequestChild* aActor, const nsACString& aHost, const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, const OriginAttributes& aOriginAttributes, - const uint32_t& aFlags) override; + const nsIDNSService::DNSFlags& aFlags) override; void AddDataBridgeToMap(uint64_t aChannelId, BackgroundDataBridgeParent* aActor); diff --git a/netwerk/ipc/SocketProcessParent.cpp b/netwerk/ipc/SocketProcessParent.cpp index a321f7a2b66c..ec6e4b2bdac3 100644 --- a/netwerk/ipc/SocketProcessParent.cpp +++ b/netwerk/ipc/SocketProcessParent.cpp @@ -214,7 +214,7 @@ bool SocketProcessParent::DeallocPWebrtcTCPSocketParent( already_AddRefed SocketProcessParent::AllocPDNSRequestParent( const nsACString& aHost, const nsACString& aTrrServer, const int32_t& port, const uint16_t& aType, const OriginAttributes& aOriginAttributes, - const uint32_t& aFlags) { + const nsIDNSService::DNSFlags& aFlags) { RefPtr handler = new DNSRequestHandler(); RefPtr actor = new DNSRequestParent(handler); return actor.forget(); @@ -223,7 +223,8 @@ already_AddRefed SocketProcessParent::AllocPDNSRequestParent( mozilla::ipc::IPCResult SocketProcessParent::RecvPDNSRequestConstructor( PDNSRequestParent* aActor, const nsACString& aHost, const nsACString& aTrrServer, const int32_t& port, const uint16_t& aType, - const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) { + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags) { RefPtr actor = static_cast(aActor); RefPtr handler = actor->GetDNSRequest()->AsDNSRequestHandler(); diff --git a/netwerk/ipc/SocketProcessParent.h b/netwerk/ipc/SocketProcessParent.h index 9972d90e072d..206b6996111d 100644 --- a/netwerk/ipc/SocketProcessParent.h +++ b/netwerk/ipc/SocketProcessParent.h @@ -56,12 +56,13 @@ class SocketProcessParent final already_AddRefed AllocPDNSRequestParent( const nsACString& aHost, const nsACString& aTrrServer, const int32_t& port, const uint16_t& aType, - const OriginAttributes& aOriginAttributes, const uint32_t& aFlags); + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags); virtual mozilla::ipc::IPCResult RecvPDNSRequestConstructor( PDNSRequestParent* actor, const nsACString& aHost, const nsACString& trrServer, const int32_t& port, const uint16_t& type, const OriginAttributes& aOriginAttributes, - const uint32_t& flags) override; + const nsIDNSService::DNSFlags& flags) override; void ActorDestroy(ActorDestroyReason aWhy) override; bool SendRequestMemoryReport(const uint32_t& aGeneration, diff --git a/netwerk/protocol/http/DnsAndConnectSocket.cpp b/netwerk/protocol/http/DnsAndConnectSocket.cpp index c1d01d45538a..7e3bab180f72 100644 --- a/netwerk/protocol/http/DnsAndConnectSocket.cpp +++ b/netwerk/protocol/http/DnsAndConnectSocket.cpp @@ -181,7 +181,7 @@ void DnsAndConnectSocket::CheckProxyConfig() { nsresult DnsAndConnectSocket::SetupDnsFlags(ConnectionEntry* ent) { LOG(("DnsAndConnectSocket::SetupDnsFlags [this=%p] ", this)); - uint32_t dnsFlags = 0; + nsIDNSService::DNSFlags dnsFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; bool disableIpv6ForBackup = false; if (mCaps & NS_HTTP_REFRESH_DNS) { dnsFlags = nsIDNSService::RESOLVE_BYPASS_CACHE; diff --git a/netwerk/protocol/http/DnsAndConnectSocket.h b/netwerk/protocol/http/DnsAndConnectSocket.h index 5ddaa4525211..8409de3d080f 100644 --- a/netwerk/protocol/http/DnsAndConnectSocket.h +++ b/netwerk/protocol/http/DnsAndConnectSocket.h @@ -15,6 +15,7 @@ #include "nsICancelable.h" #include "nsIDNSListener.h" #include "nsIDNSRecord.h" +#include "nsIDNSService.h" #include "nsINamed.h" #include "nsITransport.h" #include "nsWeakReference.h" @@ -153,7 +154,7 @@ class DnsAndConnectSocket final : public nsIOutputStreamCallback, nsCString mHost; nsCOMPtr mDNSRequest; nsCOMPtr mDNSRecord; - uint32_t mDnsFlags = 0; + nsIDNSService::DNSFlags mDnsFlags = nsIDNSService::RESOLVE_DEFAULT_FLAGS; bool mRetryWithDifferentIPFamily = false; bool mResetFamilyPreference = false; bool mSkipDnsResolution = false; diff --git a/netwerk/protocol/http/HTTPSRecordResolver.cpp b/netwerk/protocol/http/HTTPSRecordResolver.cpp index b7ef60c7db10..9f899afb2ed6 100644 --- a/netwerk/protocol/http/HTTPSRecordResolver.cpp +++ b/netwerk/protocol/http/HTTPSRecordResolver.cpp @@ -41,7 +41,8 @@ nsresult HTTPSRecordResolver::FetchHTTPSRRInternal( return NS_ERROR_NOT_AVAILABLE; } - uint32_t flags = nsIDNSService::GetFlagsFromTRRMode(mConnInfo->GetTRRMode()); + nsIDNSService::DNSFlags flags = + nsIDNSService::GetFlagsFromTRRMode(mConnInfo->GetTRRMode()); if (mCaps & NS_HTTP_REFRESH_DNS) { flags |= nsIDNSService::RESOLVE_BYPASS_CACHE; } @@ -94,7 +95,7 @@ void HTTPSRecordResolver::PrefetchAddrRecord(const nsACString& aTargetName, return; } - uint32_t flags = nsIDNSService::GetFlagsFromTRRMode( + nsIDNSService::DNSFlags flags = nsIDNSService::GetFlagsFromTRRMode( mTransaction->ConnectionInfo()->GetTRRMode()); if (aRefreshDNS) { flags |= nsIDNSService::RESOLVE_BYPASS_CACHE; diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index 8a703eba4280..5223d65aa923 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -2855,9 +2855,10 @@ nsresult WebSocketChannel::DoAdmissionDNS() { NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr main = GetMainThreadEventTarget(); nsCOMPtr cancelable; - rv = dns->AsyncResolveNative( - hostName, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0, nullptr, this, main, - mLoadInfo->GetOriginAttributes(), getter_AddRefs(cancelable)); + rv = dns->AsyncResolveNative(hostName, nsIDNSService::RESOLVE_TYPE_DEFAULT, + nsIDNSService::RESOLVE_DEFAULT_FLAGS, nullptr, + this, main, mLoadInfo->GetOriginAttributes(), + getter_AddRefs(cancelable)); if (NS_FAILED(rv)) { return rv; } diff --git a/widget/android/WebExecutorSupport.cpp b/widget/android/WebExecutorSupport.cpp index 52f93f1ace92..33f7cc5c1b9f 100644 --- a/widget/android/WebExecutorSupport.cpp +++ b/widget/android/WebExecutorSupport.cpp @@ -442,8 +442,9 @@ static nsresult ResolveHost(nsCString& host, java::GeckoResult::Param result) { nsCOMPtr cancelable; RefPtr listener = new DNSListener(host, result); - rv = dns->AsyncResolveNative(host, nsIDNSService::RESOLVE_TYPE_DEFAULT, 0, - nullptr, listener, nullptr /* aListenerTarget */, + rv = dns->AsyncResolveNative(host, nsIDNSService::RESOLVE_TYPE_DEFAULT, + nsIDNSService::RESOLVE_DEFAULT_FLAGS, nullptr, + listener, nullptr /* aListenerTarget */, OriginAttributes(), getter_AddRefs(cancelable)); return rv; }