зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625213 - Make txt records be resolved with onLookupComplete r=dragana
This patch makes nsIDNSByTypeRecord extend nsIDNSRecord, but implementations will safely forward the nsIDNSRecord methods to `nullptr`, meaning they will throw an error when called. Consumers should try to QI the nsIDNSRecord to nsIDNSByTypeRecord (or any future types) and use that. Differential Revision: https://phabricator.services.mozilla.com/D69326 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5bba92d0ef
Коммит
f29e4186dd
|
@ -284,13 +284,6 @@ nsHTMLDNSPrefetch::nsListener::OnLookupComplete(nsICancelable* request,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDNSPrefetch::nsListener::OnLookupByTypeComplete(nsICancelable* request,
|
||||
nsIDNSByTypeRecord* res,
|
||||
nsresult status) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsHTMLDNSPrefetch::nsDeferrals::nsDeferrals()
|
||||
|
|
|
@ -96,11 +96,7 @@ class NrIceResolver {
|
|||
cb_arg_(cb_arg) {}
|
||||
NS_IMETHOD OnLookupComplete(nsICancelable* request, nsIDNSRecord* record,
|
||||
nsresult status) override;
|
||||
NS_IMETHOD OnLookupByTypeComplete(nsICancelable* request,
|
||||
nsIDNSByTypeRecord* res,
|
||||
nsresult status) override {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int cancel();
|
||||
nsCOMPtr<nsICancelable> request_;
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
|
|
@ -267,13 +267,6 @@ LookupHelper::OnLookupComplete(nsICancelable* aRequest, nsIDNSRecord* aRecord,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LookupHelper::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult LookupHelper::ConstructAnswer(LookupArgument* aArgument) {
|
||||
nsIDNSRecord* aRecord = aArgument->mRecord;
|
||||
AutoSafeJSContext cx;
|
||||
|
|
|
@ -111,13 +111,6 @@ NetworkConnectivityService::OnLookupComplete(nsICancelable* aRequest,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NetworkConnectivityService::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NetworkConnectivityService::RecheckDNS() {
|
||||
bool enabled =
|
||||
|
|
|
@ -127,13 +127,6 @@ Predictor::DNSListener::OnLookupComplete(nsICancelable* request,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Predictor::DNSListener::OnLookupByTypeComplete(nsICancelable* request,
|
||||
nsIDNSByTypeRecord* res,
|
||||
nsresult status) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Class to proxy important information from the initial predictor call through
|
||||
// the cache API and back into the internals of the predictor. We can't use the
|
||||
// predictor itself, as it may have multiple actions in-flight, and each action
|
||||
|
|
|
@ -327,12 +327,6 @@ class PACResolver final : public nsIDNSListener,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD OnLookupByTypeComplete(nsICancelable* request,
|
||||
nsIDNSByTypeRecord* res,
|
||||
nsresult status) override {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsITimerCallback
|
||||
NS_IMETHOD Notify(nsITimer* timer) override {
|
||||
nsCOMPtr<nsICancelable> request;
|
||||
|
|
|
@ -127,21 +127,3 @@ nsDNSPrefetch::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
mListener = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDNSPrefetch::OnLookupByTypeComplete(nsICancelable* request,
|
||||
nsIDNSByTypeRecord* res,
|
||||
nsresult status) {
|
||||
if (mStoreTiming) {
|
||||
mEndTimestamp = mozilla::TimeStamp::Now();
|
||||
}
|
||||
nsCOMPtr<nsIDNSListener> listener = do_QueryReferent(mListener);
|
||||
if (listener) {
|
||||
listener->OnLookupByTypeComplete(request, res, status);
|
||||
}
|
||||
// OnLookupByTypeComplete should be called on the target thread, so we release
|
||||
// mListener here to make sure mListener is also released on the target
|
||||
// thread.
|
||||
mListener = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -3017,10 +3017,43 @@ nsSocketTransport::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
SOCKET_LOG(("nsSocketTransport::OnLookupComplete: this=%p status %" PRIx32
|
||||
".",
|
||||
this, static_cast<uint32_t>(status)));
|
||||
|
||||
if (request == mDNSTxtRequest) {
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
nsCOMPtr<nsIDNSByTypeRecord> txtResponse = do_QueryInterface(rec);
|
||||
txtResponse->GetRecordsAsOneString(mDNSRecordTxt);
|
||||
mDNSRecordTxt.Trim(" ");
|
||||
}
|
||||
Telemetry::Accumulate(Telemetry::ESNI_KEYS_RECORDS_FOUND,
|
||||
NS_SUCCEEDED(status));
|
||||
// flag host lookup complete for the benefit of the ResolveHost method.
|
||||
if (!mDNSRequest) {
|
||||
mResolving = false;
|
||||
MOZ_ASSERT(mDNSARequestFinished);
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::ESNI_KEYS_RECORD_FETCH_DELAYS,
|
||||
PR_IntervalToMilliseconds(PR_IntervalNow() - mDNSARequestFinished));
|
||||
|
||||
nsresult rv =
|
||||
PostEvent(MSG_DNS_LOOKUP_COMPLETE, mDNSLookupStatus, nullptr);
|
||||
|
||||
// if posting a message fails, then we should assume that the socket
|
||||
// transport has been shutdown. this should never happen! if it does
|
||||
// it means that the socket transport service was shutdown before the
|
||||
// DNS service.
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("unable to post DNS lookup complete message");
|
||||
}
|
||||
} else {
|
||||
mDNSTxtRequest = nullptr;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_FAILED(status) && mDNSTxtRequest) {
|
||||
mDNSTxtRequest->Cancel(NS_ERROR_ABORT);
|
||||
} else if (NS_SUCCEEDED(status)) {
|
||||
mDNSRecord = static_cast<nsIDNSRecord*>(rec);
|
||||
mDNSRecord = rec;
|
||||
}
|
||||
|
||||
// flag host lookup complete for the benefit of the ResolveHost method.
|
||||
|
@ -3048,46 +3081,6 @@ nsSocketTransport::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::OnLookupByTypeComplete(nsICancelable* request,
|
||||
nsIDNSByTypeRecord* txtResponse,
|
||||
nsresult status) {
|
||||
SOCKET_LOG(
|
||||
("nsSocketTransport::OnLookupByTypeComplete: "
|
||||
"this=%p status %" PRIx32 ".",
|
||||
this, static_cast<uint32_t>(status)));
|
||||
MOZ_ASSERT(mDNSTxtRequest == request);
|
||||
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
txtResponse->GetRecordsAsOneString(mDNSRecordTxt);
|
||||
mDNSRecordTxt.Trim(" ");
|
||||
}
|
||||
Telemetry::Accumulate(Telemetry::ESNI_KEYS_RECORDS_FOUND,
|
||||
NS_SUCCEEDED(status));
|
||||
// flag host lookup complete for the benefit of the ResolveHost method.
|
||||
if (!mDNSRequest) {
|
||||
mResolving = false;
|
||||
MOZ_ASSERT(mDNSARequestFinished);
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::ESNI_KEYS_RECORD_FETCH_DELAYS,
|
||||
PR_IntervalToMilliseconds(PR_IntervalNow() - mDNSARequestFinished));
|
||||
|
||||
nsresult rv = PostEvent(MSG_DNS_LOOKUP_COMPLETE, mDNSLookupStatus, nullptr);
|
||||
|
||||
// if posting a message fails, then we should assume that the socket
|
||||
// transport has been shutdown. this should never happen! if it does
|
||||
// it means that the socket transport service was shutdown before the
|
||||
// DNS service.
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("unable to post DNS lookup complete message");
|
||||
}
|
||||
} else {
|
||||
mDNSTxtRequest = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetInterface(const nsIID& iid, void** result) {
|
||||
|
|
|
@ -987,13 +987,6 @@ PendingSend::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PendingSend::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class PendingSendStream : public nsIDNSListener {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
@ -1030,13 +1023,6 @@ PendingSendStream::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PendingSendStream::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class SendRequestRunnable : public Runnable {
|
||||
public:
|
||||
SendRequestRunnable(nsUDPSocket* aSocket, const NetAddr& aAddr,
|
||||
|
|
|
@ -20,27 +20,12 @@ DNSListenerProxy::OnLookupComplete(nsICancelable* aRequest,
|
|||
return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DNSListenerProxy::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
RefPtr<OnLookupByTypeCompleteRunnable> r =
|
||||
new OnLookupByTypeCompleteRunnable(mListener, aRequest, aRes, aStatus);
|
||||
return mTargetThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DNSListenerProxy::OnLookupCompleteRunnable::Run() {
|
||||
mListener->OnLookupComplete(mRequest, mRecord, mStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DNSListenerProxy::OnLookupByTypeCompleteRunnable::Run() {
|
||||
mListener->OnLookupByTypeComplete(mRequest, mResult, mStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DNSListenerProxy::GetOriginalListener(nsIDNSListener** aOriginalListener) {
|
||||
NS_IF_ADDREF(*aOriginalListener = mListener);
|
||||
|
|
|
@ -55,26 +55,6 @@ class DNSListenerProxy final : public nsIDNSListener,
|
|||
nsresult mStatus;
|
||||
};
|
||||
|
||||
class OnLookupByTypeCompleteRunnable : public Runnable {
|
||||
public:
|
||||
OnLookupByTypeCompleteRunnable(
|
||||
const nsMainThreadPtrHandle<nsIDNSListener>& aListener,
|
||||
nsICancelable* aRequest, nsIDNSByTypeRecord* aRes, nsresult aStatus)
|
||||
: Runnable("DNSListenerProxy::OnLookupByTypeCompleteRunnable"),
|
||||
mListener(aListener),
|
||||
mRequest(aRequest),
|
||||
mResult(aRes),
|
||||
mStatus(aStatus) {}
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
private:
|
||||
nsMainThreadPtrHandle<nsIDNSListener> mListener;
|
||||
nsCOMPtr<nsICancelable> mRequest;
|
||||
nsCOMPtr<nsIDNSByTypeRecord> mResult;
|
||||
nsresult mStatus;
|
||||
};
|
||||
|
||||
private:
|
||||
~DNSListenerProxy() {}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ ChildDNSRecord::ReportUnusable(uint16_t aPort) {
|
|||
class ChildDNSByTypeRecord : public nsIDNSByTypeRecord {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_FORWARD_SAFE_NSIDNSRECORD(((nsIDNSRecord*)nullptr))
|
||||
NS_DECL_NSIDNSBYTYPERECORD
|
||||
|
||||
explicit ChildDNSByTypeRecord(const nsTArray<nsCString>& reply);
|
||||
|
@ -170,7 +171,7 @@ class ChildDNSByTypeRecord : public nsIDNSByTypeRecord {
|
|||
nsTArray<nsCString> mRecords;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(ChildDNSByTypeRecord, nsIDNSByTypeRecord)
|
||||
NS_IMPL_ISUPPORTS(ChildDNSByTypeRecord, nsIDNSByTypeRecord, nsIDNSRecord)
|
||||
|
||||
ChildDNSByTypeRecord::ChildDNSByTypeRecord(const nsTArray<nsCString>& reply) {
|
||||
mRecords = reply;
|
||||
|
@ -278,12 +279,6 @@ void DNSRequestChild::CallOnLookupComplete() {
|
|||
mListener->OnLookupComplete(this, mResultRecord, mResultStatus);
|
||||
}
|
||||
|
||||
void DNSRequestChild::CallOnLookupByTypeComplete() {
|
||||
MOZ_ASSERT(mListener);
|
||||
MOZ_ASSERT(mType != nsIDNSService::RESOLVE_TYPE_DEFAULT);
|
||||
mListener->OnLookupByTypeComplete(this, mResultByTypeRecords, mResultStatus);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult DNSRequestChild::RecvLookupCompleted(
|
||||
const DNSRequestResponse& reply) {
|
||||
MOZ_ASSERT(mListener);
|
||||
|
@ -299,8 +294,7 @@ mozilla::ipc::IPCResult DNSRequestChild::RecvLookupCompleted(
|
|||
}
|
||||
case DNSRequestResponse::TArrayOfnsCString: {
|
||||
MOZ_ASSERT(mType != nsIDNSService::RESOLVE_TYPE_DEFAULT);
|
||||
mResultByTypeRecords =
|
||||
new ChildDNSByTypeRecord(reply.get_ArrayOfnsCString());
|
||||
mResultRecord = new ChildDNSByTypeRecord(reply.get_ArrayOfnsCString());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -318,23 +312,12 @@ mozilla::ipc::IPCResult DNSRequestChild::RecvLookupCompleted(
|
|||
}
|
||||
|
||||
if (targetIsMain) {
|
||||
if (mType == nsIDNSService::RESOLVE_TYPE_DEFAULT) {
|
||||
CallOnLookupComplete();
|
||||
} else {
|
||||
CallOnLookupByTypeComplete();
|
||||
}
|
||||
CallOnLookupComplete();
|
||||
} else {
|
||||
if (mType == nsIDNSService::RESOLVE_TYPE_DEFAULT) {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NewRunnableMethod("net::DNSRequestChild::CallOnLookupComplete", this,
|
||||
&DNSRequestChild::CallOnLookupComplete);
|
||||
mTarget->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
} else {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NewRunnableMethod("net::DNSRequestChild::CallOnLookupByTypeComplete",
|
||||
this, &DNSRequestChild::CallOnLookupByTypeComplete);
|
||||
mTarget->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NewRunnableMethod("net::DNSRequestChild::CallOnLookupComplete", this,
|
||||
&DNSRequestChild::CallOnLookupComplete);
|
||||
mTarget->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
Unused << Send__delete__(this);
|
||||
|
|
|
@ -33,7 +33,6 @@ class DNSRequestChild final : public PDNSRequestChild, public nsICancelable {
|
|||
// Sends IPDL request to parent
|
||||
void StartRequest();
|
||||
void CallOnLookupComplete();
|
||||
void CallOnLookupByTypeComplete();
|
||||
|
||||
protected:
|
||||
friend class CancelDNSRequestEvent;
|
||||
|
@ -46,13 +45,6 @@ class DNSRequestChild final : public PDNSRequestChild, public nsICancelable {
|
|||
nsCOMPtr<nsIDNSListener> mListener;
|
||||
nsCOMPtr<nsIEventTarget> mTarget;
|
||||
nsCOMPtr<nsIDNSRecord> mResultRecord;
|
||||
nsCOMPtr<nsIDNSByTypeRecord>
|
||||
mResultByTypeRecords; // the result of a by-type
|
||||
// query (mType must not be
|
||||
// equal to
|
||||
// nsIDNSService::RESOLVE_TYPE_DEFAULT
|
||||
// (this is reserved for
|
||||
// the standard A/AAAA query)).
|
||||
nsresult mResultStatus;
|
||||
nsCString mHost;
|
||||
nsCString mTrrServer;
|
||||
|
|
|
@ -92,6 +92,14 @@ DNSRequestParent::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
if (NS_SUCCEEDED(status)) {
|
||||
MOZ_ASSERT(rec);
|
||||
|
||||
nsCOMPtr<nsIDNSByTypeRecord> txtRec = do_QueryInterface(rec);
|
||||
if (txtRec) {
|
||||
nsTArray<nsCString> rec;
|
||||
txtRec->GetRecords(rec);
|
||||
Unused << SendLookupCompleted(DNSRequestResponse(rec));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString cname;
|
||||
if (mFlags & nsHostResolver::RES_CANON_NAME) {
|
||||
rec->GetCanonicalName(cname);
|
||||
|
@ -112,24 +120,5 @@ DNSRequestParent::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DNSRequestParent::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
if (!CanSend()) {
|
||||
// nothing to do: child probably crashed
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
nsTArray<nsCString> rec;
|
||||
aRes->GetRecords(rec);
|
||||
Unused << SendLookupCompleted(DNSRequestResponse(rec));
|
||||
} else {
|
||||
Unused << SendLookupCompleted(DNSRequestResponse(aStatus));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -321,6 +321,7 @@ nsDNSRecord::ReportUnusable(uint16_t aPort) {
|
|||
class nsDNSByTypeRecord : public nsIDNSByTypeRecord {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_FORWARD_SAFE_NSIDNSRECORD(((nsIDNSRecord*)nullptr))
|
||||
NS_DECL_NSIDNSBYTYPERECORD
|
||||
|
||||
explicit nsDNSByTypeRecord(nsHostRecord* hostRecord) {
|
||||
|
@ -332,7 +333,7 @@ class nsDNSByTypeRecord : public nsIDNSByTypeRecord {
|
|||
RefPtr<TypeHostRecord> mHostRecord;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDNSByTypeRecord, nsIDNSByTypeRecord)
|
||||
NS_IMPL_ISUPPORTS(nsDNSByTypeRecord, nsIDNSRecord, nsIDNSByTypeRecord)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDNSByTypeRecord::GetRecords(nsTArray<nsCString>& aRecords) {
|
||||
|
@ -396,25 +397,21 @@ NS_IMPL_ISUPPORTS(nsDNSAsyncRequest, nsICancelable)
|
|||
void nsDNSAsyncRequest::OnResolveHostComplete(nsHostResolver* resolver,
|
||||
nsHostRecord* hostRecord,
|
||||
nsresult status) {
|
||||
if (hostRecord->type != nsDNSService::RESOLVE_TYPE_DEFAULT) {
|
||||
nsCOMPtr<nsIDNSByTypeRecord> rec;
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
MOZ_ASSERT(hostRecord, "no host record");
|
||||
// need to have an owning ref when we issue the callback to enable
|
||||
// the caller to be able to addref/release multiple times without
|
||||
// destroying the record prematurely.
|
||||
nsCOMPtr<nsIDNSRecord> rec;
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
MOZ_ASSERT(hostRecord, "no host record");
|
||||
printf("hostRecordType: %d\n", hostRecord->type);
|
||||
if (hostRecord->type != nsDNSService::RESOLVE_TYPE_DEFAULT) {
|
||||
rec = new nsDNSByTypeRecord(hostRecord);
|
||||
}
|
||||
mListener->OnLookupByTypeComplete(this, rec, status);
|
||||
} else {
|
||||
// need to have an owning ref when we issue the callback to enable
|
||||
// the caller to be able to addref/release multiple times without
|
||||
// destroying the record prematurely.
|
||||
nsCOMPtr<nsIDNSRecord> rec;
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
NS_ASSERTION(hostRecord, "no host record");
|
||||
} else {
|
||||
rec = new nsDNSRecord(hostRecord);
|
||||
}
|
||||
|
||||
mListener->OnLookupComplete(this, rec, status);
|
||||
}
|
||||
|
||||
mListener->OnLookupComplete(this, rec, status);
|
||||
mListener = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIDNSRecord.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
|
@ -11,7 +11,7 @@
|
|||
[ref] native CStringArrayRef(nsTArray<nsCString>);
|
||||
|
||||
[scriptable, uuid(5d13241b-9d46-448a-90d8-77c418491026)]
|
||||
interface nsIDNSByTypeRecord : nsISupports
|
||||
interface nsIDNSByTypeRecord : nsIDNSRecord
|
||||
{
|
||||
CStringArrayRef getRecords();
|
||||
|
||||
|
|
|
@ -28,20 +28,6 @@ interface nsIDNSListener : nsISupports
|
|||
void onLookupComplete(in nsICancelable aRequest,
|
||||
in nsIDNSRecord aRecord,
|
||||
in nsresult aStatus);
|
||||
/**
|
||||
* called when an asynchronous dns lookup by type completes.
|
||||
*
|
||||
* @param aRequest
|
||||
* the value returned from asyncResolve.
|
||||
* @param aRecord
|
||||
* a string returned by the dns server.
|
||||
* @param aStatus
|
||||
* if the lookup failed, this parameter gives the reason.
|
||||
*/
|
||||
void onLookupByTypeComplete(in nsICancelable aRequest,
|
||||
in nsIDNSByTypeRecord aResult,
|
||||
in nsresult aStatus);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1180,13 +1180,6 @@ TRRServiceChannel::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRServiceChannel::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRServiceChannel::LogBlockedCORSRequest(const nsAString& aMessage,
|
||||
const nsACString& aCategory) {
|
||||
|
|
|
@ -9348,13 +9348,6 @@ nsHttpChannel::OnLookupComplete(nsICancelable* request, nsIDNSRecord* rec,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpChannel internal functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -2977,13 +2977,6 @@ WebSocketChannel::OnLookupComplete(nsICancelable* aRequest,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebSocketChannel::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* aRes,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIProtocolProxyCallback
|
||||
NS_IMETHODIMP
|
||||
WebSocketChannel::OnProxyAvailable(nsICancelable* aRequest,
|
||||
|
|
|
@ -496,13 +496,6 @@ nsSOCKSSocketInfo::OnLookupComplete(nsICancelable* aRequest,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSOCKSSocketInfo::OnLookupByTypeComplete(nsICancelable* aRequest,
|
||||
nsIDNSByTypeRecord* res,
|
||||
nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRStatus nsSOCKSSocketInfo::ConnectToProxy(PRFileDesc* fd) {
|
||||
PRStatus status;
|
||||
nsresult rv;
|
||||
|
|
|
@ -86,11 +86,16 @@ class DNSListener {
|
|||
this.resolve = resolve;
|
||||
});
|
||||
}
|
||||
onLookupByTypeComplete(inRequest, inRecord, inStatus) {
|
||||
this.resolve([inRequest, inRecord, inStatus, "onLookupByTypeComplete"]);
|
||||
}
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
this.resolve([inRequest, inRecord, inStatus, "onLookupComplete"]);
|
||||
let txtRec;
|
||||
try {
|
||||
txtRec = inRecord.QueryInterface(Ci.nsIDNSByTypeRecord);
|
||||
} catch (e) {}
|
||||
if (txtRec) {
|
||||
this.resolve([inRequest, txtRec, inStatus, "onLookupByTypeComplete"]);
|
||||
} else {
|
||||
this.resolve([inRequest, inRecord, inStatus, "onLookupComplete"]);
|
||||
}
|
||||
}
|
||||
// So we can await this as a promise.
|
||||
then() {
|
||||
|
|
|
@ -439,13 +439,6 @@ class DNSListener final : public nsIDNSListener {
|
|||
mResult->CompleteExceptionally(error.Cast<jni::Throwable>());
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
OnLookupByTypeComplete(nsICancelable* aRequest, nsIDNSByTypeRecord* aRecord,
|
||||
nsresult aStatus) override {
|
||||
MOZ_ASSERT_UNREACHABLE("unxpected nsIDNSListener callback");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult CompleteWithRecord(nsIDNSRecord* aRecord) {
|
||||
nsTArray<NetAddr> addrs;
|
||||
|
|
Загрузка…
Ссылка в новой задаче