Bug 1552176 - Pass TRRMode to nsDNSPrefetch r=dragana

Differential Revision: https://phabricator.services.mozilla.com/D49158

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2020-01-07 19:33:10 +00:00
Родитель cbc2554d2d
Коммит 90fff44905
3 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -33,15 +33,17 @@ nsresult nsDNSPrefetch::Shutdown() {
nsDNSPrefetch::nsDNSPrefetch(nsIURI* aURI,
mozilla::OriginAttributes& aOriginAttributes,
nsIRequest::TRRMode aTRRMode,
nsIDNSListener* aListener, bool storeTiming)
: mOriginAttributes(aOriginAttributes),
mStoreTiming(storeTiming),
mTRRMode(aTRRMode),
mListener(do_GetWeakReference(aListener)) {
aURI->GetAsciiHost(mHostname);
mIsHttps = aURI->SchemeIs("https");
}
nsresult nsDNSPrefetch::Prefetch(uint16_t flags) {
nsresult nsDNSPrefetch::Prefetch(uint32_t flags) {
// This can work properly only if this call is on the main thread.
// Curenlty we use nsDNSPrefetch only in nsHttpChannel which will call
// PrefetchHigh() from the main thread. Let's add assertion to catch
@ -61,6 +63,8 @@ nsresult nsDNSPrefetch::Prefetch(uint16_t flags) {
// TimingsValid() before using the timing.
nsCOMPtr<nsIEventTarget> main = mozilla::GetMainThreadEventTarget();
flags |= nsIDNSService::GetFlagsFromTRRMode(mTRRMode);
nsresult rv = sDNSService->AsyncResolveNative(
mHostname, flags | nsIDNSService::RESOLVE_SPECULATE, this, main,
mOriginAttributes, getter_AddRefs(tmpOutstanding));

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/BasePrincipal.h"
#include "nsIDNSListener.h"
#include "nsIRequest.h"
class nsIURI;
class nsIDNSService;
@ -25,7 +26,8 @@ class nsDNSPrefetch final : public nsIDNSListener {
NS_DECL_NSIDNSLISTENER
nsDNSPrefetch(nsIURI* aURI, mozilla::OriginAttributes& aOriginAttributes,
nsIDNSListener* aListener, bool storeTiming);
nsIRequest::TRRMode aTRRMode, nsIDNSListener* aListener,
bool storeTiming);
bool TimingsValid() const {
return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull();
}
@ -46,11 +48,12 @@ class nsDNSPrefetch final : public nsIDNSListener {
bool mIsHttps;
mozilla::OriginAttributes mOriginAttributes;
bool mStoreTiming;
nsIRequest::TRRMode mTRRMode;
mozilla::TimeStamp mStartTimestamp;
mozilla::TimeStamp mEndTimestamp;
nsWeakPtr mListener;
nsresult Prefetch(uint16_t flags);
nsresult Prefetch(uint32_t flags);
};
#endif

Просмотреть файл

@ -6856,8 +6856,8 @@ void nsHttpChannel::MaybeStartDNSPrefetch() {
mCaps & NS_HTTP_REFRESH_DNS ? ", refresh requested" : ""));
OriginAttributes originAttributes;
NS_GetOriginAttributes(this, originAttributes);
mDNSPrefetch =
new nsDNSPrefetch(mURI, originAttributes, this, mTimingEnabled);
mDNSPrefetch = new nsDNSPrefetch(
mURI, originAttributes, nsIRequest::GetTRRMode(), this, mTimingEnabled);
mDNSPrefetch->PrefetchHigh(mCaps & NS_HTTP_REFRESH_DNS);
}
}