зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8bfa7127e064 (bug 1629457) for WPT and Mochitest failures. CLOSED TREE
This commit is contained in:
Родитель
3e91ad7f5b
Коммит
42e5873ad1
|
@ -54,8 +54,7 @@ nsDNSPrefetch::nsDNSPrefetch(nsIURI* aURI,
|
||||||
: mOriginAttributes(aOriginAttributes),
|
: mOriginAttributes(aOriginAttributes),
|
||||||
mStoreTiming(storeTiming),
|
mStoreTiming(storeTiming),
|
||||||
mTRRMode(aTRRMode),
|
mTRRMode(aTRRMode),
|
||||||
mListener(aListener),
|
mListener(do_GetWeakReference(aListener)) {
|
||||||
mTarget(GetCurrentThreadEventTarget()) {
|
|
||||||
aURI->GetAsciiHost(mHostname);
|
aURI->GetAsciiHost(mHostname);
|
||||||
mIsHttps = aURI->SchemeIs("https");
|
mIsHttps = aURI->SchemeIs("https");
|
||||||
}
|
}
|
||||||
|
@ -72,11 +71,12 @@ nsresult nsDNSPrefetch::Prefetch(uint32_t flags) {
|
||||||
// then our timing will be useless. However, in such a case,
|
// then our timing will be useless. However, in such a case,
|
||||||
// mEndTimestamp will be a null timestamp and callers should check
|
// mEndTimestamp will be a null timestamp and callers should check
|
||||||
// TimingsValid() before using the timing.
|
// TimingsValid() before using the timing.
|
||||||
|
nsCOMPtr<nsIEventTarget> target = mozilla::GetCurrentThreadEventTarget();
|
||||||
|
|
||||||
flags |= nsIDNSService::GetFlagsFromTRRMode(mTRRMode);
|
flags |= nsIDNSService::GetFlagsFromTRRMode(mTRRMode);
|
||||||
|
|
||||||
nsresult rv = sDNSService->AsyncResolveNative(
|
nsresult rv = sDNSService->AsyncResolveNative(
|
||||||
mHostname, flags | nsIDNSService::RESOLVE_SPECULATE, this, mTarget,
|
mHostname, flags | nsIDNSService::RESOLVE_SPECULATE, this, target,
|
||||||
mOriginAttributes, getter_AddRefs(tmpOutstanding));
|
mOriginAttributes, getter_AddRefs(tmpOutstanding));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -89,7 +89,7 @@ nsresult nsDNSPrefetch::Prefetch(uint32_t flags) {
|
||||||
esniHost.Append(mHostname);
|
esniHost.Append(mHostname);
|
||||||
sDNSService->AsyncResolveByTypeNative(
|
sDNSService->AsyncResolveByTypeNative(
|
||||||
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
|
esniHost, nsIDNSService::RESOLVE_TYPE_TXT,
|
||||||
flags | nsIDNSService::RESOLVE_SPECULATE, this, mTarget,
|
flags | nsIDNSService::RESOLVE_SPECULATE, this, target,
|
||||||
mOriginAttributes, getter_AddRefs(tmpOutstanding));
|
mOriginAttributes, getter_AddRefs(tmpOutstanding));
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -114,16 +114,16 @@ NS_IMPL_ISUPPORTS(nsDNSPrefetch, nsIDNSListener)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDNSPrefetch::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
nsDNSPrefetch::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
||||||
nsresult status) {
|
nsresult status) {
|
||||||
MOZ_ASSERT(mTarget->IsOnCurrentThread());
|
|
||||||
|
|
||||||
if (mStoreTiming) {
|
if (mStoreTiming) {
|
||||||
mEndTimestamp = mozilla::TimeStamp::Now();
|
mEndTimestamp = mozilla::TimeStamp::Now();
|
||||||
}
|
}
|
||||||
|
nsCOMPtr<nsIDNSListener> listener = do_QueryReferent(mListener);
|
||||||
nsCOMPtr<nsIDNSListener> listener;
|
if (listener) {
|
||||||
mListener.swap(listener);
|
listener->OnLookupComplete(request, rec, status);
|
||||||
|
}
|
||||||
MOZ_ASSERT(listener);
|
// OnLookupComplete should be called on the target thread, so we release
|
||||||
listener->OnLookupComplete(request, rec, status);
|
// mListener here to make sure mListener is also released on the target
|
||||||
|
// thread.
|
||||||
|
mListener = nullptr;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#ifndef nsDNSPrefetch_h___
|
#ifndef nsDNSPrefetch_h___
|
||||||
#define nsDNSPrefetch_h___
|
#define nsDNSPrefetch_h___
|
||||||
|
|
||||||
|
#include "nsIWeakReferenceUtils.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
@ -52,8 +53,7 @@ class nsDNSPrefetch final : public nsIDNSListener {
|
||||||
nsIRequest::TRRMode mTRRMode;
|
nsIRequest::TRRMode mTRRMode;
|
||||||
mozilla::TimeStamp mStartTimestamp;
|
mozilla::TimeStamp mStartTimestamp;
|
||||||
mozilla::TimeStamp mEndTimestamp;
|
mozilla::TimeStamp mEndTimestamp;
|
||||||
nsCOMPtr<nsIDNSListener> mListener;
|
nsWeakPtr mListener;
|
||||||
nsCOMPtr<nsIEventTarget> mTarget;
|
|
||||||
|
|
||||||
nsresult Prefetch(uint32_t flags);
|
nsresult Prefetch(uint32_t flags);
|
||||||
};
|
};
|
||||||
|
|
|
@ -439,6 +439,7 @@ void nsHttpChannel::ReleaseMainThreadOnlyReferences() {
|
||||||
arrayToRelease.AppendElement(mAuthProvider.forget());
|
arrayToRelease.AppendElement(mAuthProvider.forget());
|
||||||
arrayToRelease.AppendElement(mRedirectChannel.forget());
|
arrayToRelease.AppendElement(mRedirectChannel.forget());
|
||||||
arrayToRelease.AppendElement(mPreflightChannel.forget());
|
arrayToRelease.AppendElement(mPreflightChannel.forget());
|
||||||
|
arrayToRelease.AppendElement(mDNSPrefetch.forget());
|
||||||
|
|
||||||
NS_DispatchToMainThread(new ProxyReleaseRunnable(std::move(arrayToRelease)));
|
NS_DispatchToMainThread(new ProxyReleaseRunnable(std::move(arrayToRelease)));
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче