зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1552176 - pass TRRMode into nsHTMLDNSPrefetch methods r=dragana
Differential Revision: https://phabricator.services.mozilla.com/D49159 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
90fff44905
Коммит
16ae7bd480
|
@ -817,7 +817,8 @@ void nsContentSink::PrefetchDNS(const nsAString& aHref) {
|
|||
|
||||
if (!hostname.IsEmpty() && nsHTMLDNSPrefetch::IsAllowed(mDocument)) {
|
||||
nsHTMLDNSPrefetch::PrefetchLow(
|
||||
hostname, isHttps, mDocument->NodePrincipal()->OriginAttributesRef());
|
||||
hostname, isHttps, mDocument->NodePrincipal()->OriginAttributesRef(),
|
||||
mDocument->GetChannel()->GetTRRMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,10 +91,21 @@ bool nsHTMLDNSPrefetch::IsAllowed(Document* aDocument) {
|
|||
return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow();
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::Prefetch(Link* aElement, uint16_t flags) {
|
||||
static uint32_t GetDNSFlagsFromLink(Link* aElement) {
|
||||
if (!aElement || !aElement->GetElement() ||
|
||||
!aElement->GetElement()->OwnerDoc()->GetChannel()) {
|
||||
return 0;
|
||||
}
|
||||
nsIRequest::TRRMode mode =
|
||||
aElement->GetElement()->OwnerDoc()->GetChannel()->GetTRRMode();
|
||||
return nsIDNSService::GetFlagsFromTRRMode(mode);
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::Prefetch(Link* aElement, uint32_t flags) {
|
||||
if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
flags |= GetDNSFlagsFromLink(aElement);
|
||||
return sPrefetches->Add(flags, aElement);
|
||||
}
|
||||
|
||||
|
@ -112,7 +123,7 @@ nsresult nsHTMLDNSPrefetch::PrefetchHigh(Link* aElement) {
|
|||
|
||||
nsresult nsHTMLDNSPrefetch::Prefetch(const nsAString& hostname, bool isHttps,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
uint16_t flags) {
|
||||
uint32_t flags) {
|
||||
if (IsNeckoChild()) {
|
||||
// We need to check IsEmpty() because net_IsValidHostName()
|
||||
// considers empty strings to be valid hostnames
|
||||
|
@ -154,25 +165,28 @@ nsresult nsHTMLDNSPrefetch::Prefetch(const nsAString& hostname, bool isHttps,
|
|||
|
||||
nsresult nsHTMLDNSPrefetch::PrefetchLow(
|
||||
const nsAString& hostname, bool isHttps,
|
||||
const OriginAttributes& aOriginAttributes) {
|
||||
const OriginAttributes& aOriginAttributes, nsIRequest::TRRMode aMode) {
|
||||
return Prefetch(hostname, isHttps, aOriginAttributes,
|
||||
nsIDNSService::RESOLVE_PRIORITY_LOW);
|
||||
nsIDNSService::GetFlagsFromTRRMode(aMode) |
|
||||
nsIDNSService::RESOLVE_PRIORITY_LOW);
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::PrefetchMedium(
|
||||
const nsAString& hostname, bool isHttps,
|
||||
const OriginAttributes& aOriginAttributes) {
|
||||
const OriginAttributes& aOriginAttributes, nsIRequest::TRRMode aMode) {
|
||||
return Prefetch(hostname, isHttps, aOriginAttributes,
|
||||
nsIDNSService::RESOLVE_PRIORITY_MEDIUM);
|
||||
nsIDNSService::GetFlagsFromTRRMode(aMode) |
|
||||
nsIDNSService::RESOLVE_PRIORITY_MEDIUM);
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::PrefetchHigh(
|
||||
const nsAString& hostname, bool isHttps,
|
||||
const OriginAttributes& aOriginAttributes) {
|
||||
return Prefetch(hostname, isHttps, aOriginAttributes, 0);
|
||||
const OriginAttributes& aOriginAttributes, nsIRequest::TRRMode aMode) {
|
||||
return Prefetch(hostname, isHttps, aOriginAttributes,
|
||||
nsIDNSService::GetFlagsFromTRRMode(aMode));
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::CancelPrefetch(Link* aElement, uint16_t flags,
|
||||
nsresult nsHTMLDNSPrefetch::CancelPrefetch(Link* aElement, uint32_t flags,
|
||||
nsresult aReason) {
|
||||
if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -196,7 +210,7 @@ nsresult nsHTMLDNSPrefetch::CancelPrefetch(Link* aElement, uint16_t flags,
|
|||
|
||||
nsresult nsHTMLDNSPrefetch::CancelPrefetch(
|
||||
const nsAString& hostname, bool isHttps,
|
||||
const OriginAttributes& aOriginAttributes, uint16_t flags,
|
||||
const OriginAttributes& aOriginAttributes, uint32_t flags,
|
||||
nsresult aReason) {
|
||||
// Forward this request to Necko Parent if we're a child process
|
||||
if (IsNeckoChild()) {
|
||||
|
@ -235,14 +249,20 @@ nsresult nsHTMLDNSPrefetch::CancelPrefetch(
|
|||
|
||||
nsresult nsHTMLDNSPrefetch::CancelPrefetchLow(Link* aElement,
|
||||
nsresult aReason) {
|
||||
return CancelPrefetch(aElement, nsIDNSService::RESOLVE_PRIORITY_LOW, aReason);
|
||||
return CancelPrefetch(
|
||||
aElement,
|
||||
GetDNSFlagsFromLink(aElement) | nsIDNSService::RESOLVE_PRIORITY_LOW,
|
||||
aReason);
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::CancelPrefetchLow(
|
||||
const nsAString& hostname, bool isHttps,
|
||||
const OriginAttributes& aOriginAttributes, nsresult aReason) {
|
||||
const OriginAttributes& aOriginAttributes, nsIRequest::TRRMode aTRRMode,
|
||||
nsresult aReason) {
|
||||
return CancelPrefetch(hostname, isHttps, aOriginAttributes,
|
||||
nsIDNSService::RESOLVE_PRIORITY_LOW, aReason);
|
||||
nsIDNSService::GetFlagsFromTRRMode(aTRRMode) |
|
||||
nsIDNSService::RESOLVE_PRIORITY_LOW,
|
||||
aReason);
|
||||
}
|
||||
|
||||
void nsHTMLDNSPrefetch::LinkDestroyed(Link* aLink) {
|
||||
|
@ -301,7 +321,7 @@ void nsHTMLDNSPrefetch::nsDeferrals::Flush() {
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsHTMLDNSPrefetch::nsDeferrals::Add(uint16_t flags, Link* aElement) {
|
||||
nsresult nsHTMLDNSPrefetch::nsDeferrals::Add(uint32_t flags, Link* aElement) {
|
||||
// The FIFO has no lock, so it can only be accessed on main thread
|
||||
NS_ASSERTION(NS_IsMainThread(), "nsDeferrals::Add must be on main thread");
|
||||
|
||||
|
|
|
@ -52,16 +52,20 @@ class nsHTMLDNSPrefetch {
|
|||
static nsresult PrefetchLow(mozilla::dom::Link* aElement);
|
||||
static nsresult PrefetchHigh(
|
||||
const nsAString& host, bool isHttps,
|
||||
const mozilla::OriginAttributes& aOriginAttributes);
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
nsIRequest::TRRMode aTRRMode);
|
||||
static nsresult PrefetchMedium(
|
||||
const nsAString& host, bool isHttps,
|
||||
const mozilla::OriginAttributes& aOriginAttributes);
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
nsIRequest::TRRMode aTRRMode);
|
||||
static nsresult PrefetchLow(
|
||||
const nsAString& host, bool isHttps,
|
||||
const mozilla::OriginAttributes& aOriginAttributes);
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
nsIRequest::TRRMode aTRRMode);
|
||||
static nsresult CancelPrefetchLow(
|
||||
const nsAString& host, bool isHttps,
|
||||
const mozilla::OriginAttributes& aOriginAttributes, nsresult aReason);
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
nsIRequest::TRRMode aTRRMode, nsresult aReason);
|
||||
static nsresult CancelPrefetchLow(mozilla::dom::Link* aElement,
|
||||
nsresult aReason);
|
||||
|
||||
|
@ -70,13 +74,13 @@ class nsHTMLDNSPrefetch {
|
|||
private:
|
||||
static nsresult Prefetch(const nsAString& host, bool isHttps,
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
uint16_t flags);
|
||||
static nsresult Prefetch(mozilla::dom::Link* aElement, uint16_t flags);
|
||||
uint32_t flags);
|
||||
static nsresult Prefetch(mozilla::dom::Link* aElement, uint32_t flags);
|
||||
static nsresult CancelPrefetch(
|
||||
const nsAString& hostname, bool isHttps,
|
||||
const mozilla::OriginAttributes& aOriginAttributes, uint16_t flags,
|
||||
const mozilla::OriginAttributes& aOriginAttributes, uint32_t flags,
|
||||
nsresult aReason);
|
||||
static nsresult CancelPrefetch(mozilla::dom::Link* aElement, uint16_t flags,
|
||||
static nsresult CancelPrefetch(mozilla::dom::Link* aElement, uint32_t flags,
|
||||
nsresult aReason);
|
||||
|
||||
public:
|
||||
|
@ -103,7 +107,7 @@ class nsHTMLDNSPrefetch {
|
|||
nsDeferrals();
|
||||
|
||||
void Activate();
|
||||
nsresult Add(uint16_t flags, mozilla::dom::Link* aElement);
|
||||
nsresult Add(uint32_t flags, mozilla::dom::Link* aElement);
|
||||
|
||||
void RemoveUnboundLinks();
|
||||
|
||||
|
@ -125,7 +129,7 @@ class nsHTMLDNSPrefetch {
|
|||
static const int sMaxDeferredMask = (sMaxDeferred - 1);
|
||||
|
||||
struct deferred_entry {
|
||||
uint16_t mFlags;
|
||||
uint32_t mFlags;
|
||||
// Link implementation clears this raw pointer in its destructor.
|
||||
mozilla::dom::Link* mElement;
|
||||
} mEntries[sMaxDeferred];
|
||||
|
|
|
@ -634,14 +634,14 @@ mozilla::ipc::IPCResult NeckoParent::RecvSpeculativeConnect(
|
|||
|
||||
mozilla::ipc::IPCResult NeckoParent::RecvHTMLDNSPrefetch(
|
||||
const nsString& hostname, const bool& isHttps,
|
||||
const OriginAttributes& aOriginAttributes, const uint16_t& flags) {
|
||||
const OriginAttributes& aOriginAttributes, const uint32_t& flags) {
|
||||
nsHTMLDNSPrefetch::Prefetch(hostname, isHttps, aOriginAttributes, flags);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult NeckoParent::RecvCancelHTMLDNSPrefetch(
|
||||
const nsString& hostname, const bool& isHttps,
|
||||
const OriginAttributes& aOriginAttributes, const uint16_t& flags,
|
||||
const OriginAttributes& aOriginAttributes, const uint32_t& flags,
|
||||
const nsresult& reason) {
|
||||
nsHTMLDNSPrefetch::CancelPrefetch(hostname, isHttps, aOriginAttributes, flags,
|
||||
reason);
|
||||
|
|
|
@ -162,10 +162,10 @@ class NeckoParent : public PNeckoParent {
|
|||
const bool& aAnonymous);
|
||||
mozilla::ipc::IPCResult RecvHTMLDNSPrefetch(
|
||||
const nsString& hostname, const bool& isHttps,
|
||||
const OriginAttributes& aOriginAttributes, const uint16_t& flags);
|
||||
const OriginAttributes& aOriginAttributes, const uint32_t& flags);
|
||||
mozilla::ipc::IPCResult RecvCancelHTMLDNSPrefetch(
|
||||
const nsString& hostname, const bool& isHttps,
|
||||
const OriginAttributes& aOriginAttributes, const uint16_t& flags,
|
||||
const OriginAttributes& aOriginAttributes, const uint32_t& flags,
|
||||
const nsresult& reason);
|
||||
PWebSocketEventListenerParent* AllocPWebSocketEventListenerParent(
|
||||
const uint64_t& aInnerWindowID);
|
||||
|
|
|
@ -104,10 +104,10 @@ parent:
|
|||
|
||||
async SpeculativeConnect(URIParams uri, nsIPrincipal principal, bool anonymous);
|
||||
async HTMLDNSPrefetch(nsString hostname, bool isHttps,
|
||||
OriginAttributes originAttributes, uint16_t flags);
|
||||
OriginAttributes originAttributes, uint32_t flags);
|
||||
async CancelHTMLDNSPrefetch(nsString hostname, bool isHttps,
|
||||
OriginAttributes originAttributes,
|
||||
uint16_t flags, nsresult reason);
|
||||
uint32_t flags, nsresult reason);
|
||||
|
||||
/**
|
||||
* channelId is used to establish a connection between redirect channels in
|
||||
|
|
Загрузка…
Ссылка в новой задаче