Backed out 2 changesets (bug 1417827) for windows build bustage. CLOSED TREE

Backed out changeset 35655153f9c9 (bug 1417827)
Backed out changeset 9606d0d95b53 (bug 1417827)

--HG--
extra : amend_source : ce9a86c7b5ded39d1b00a7c626ba7a082efaabde
This commit is contained in:
Dorel Luca 2018-06-14 22:07:18 +03:00
parent dd36a7641b
commit ff4d587dc8
9 changed files with 127 additions and 105 deletions

View File

@ -9,7 +9,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/mozalloc.h"
#include "mozilla/ArrayUtils.h"
#include "nsString.h"
#include <string.h>
#ifdef XP_WIN
@ -294,17 +293,17 @@ NetAddrElement::NetAddrElement(const NetAddrElement& netAddr)
NetAddrElement::~NetAddrElement() = default;
AddrInfo::AddrInfo(const nsACString& host, const PRAddrInfo *prAddrInfo,
bool disableIPv4, bool filterNameCollision,
const nsACString& cname)
: mHostName(host)
, mCanonicalName(cname)
AddrInfo::AddrInfo(const char *host, const PRAddrInfo *prAddrInfo,
bool disableIPv4, bool filterNameCollision, const char *cname)
: mHostName(nullptr)
, mCanonicalName(nullptr)
, ttl(NO_TTL_DATA)
, mFromTRR(false)
{
MOZ_ASSERT(prAddrInfo, "Cannot construct AddrInfo with a null prAddrInfo pointer!");
const uint32_t nameCollisionAddr = htonl(0x7f003535); // 127.0.53.53
Init(host, cname);
PRNetAddr tmpAddr;
void *iter = nullptr;
do {
@ -319,27 +318,35 @@ AddrInfo::AddrInfo(const nsACString& host, const PRAddrInfo *prAddrInfo,
} while (iter);
}
AddrInfo::AddrInfo(const nsACString& host, const nsACString& cname, unsigned int aTRR)
: mHostName(host)
, mCanonicalName(cname)
AddrInfo::AddrInfo(const char *host, const char *cname, unsigned int aTRR)
: mHostName(nullptr)
, mCanonicalName(nullptr)
, ttl(NO_TTL_DATA)
, mFromTRR(aTRR)
{
Init(host, cname);
}
AddrInfo::AddrInfo(const nsACString& host, unsigned int aTRR)
: mHostName(host)
, mCanonicalName(EmptyCString())
AddrInfo::AddrInfo(const char *host, unsigned int aTRR)
: mHostName(nullptr)
, mCanonicalName(nullptr)
, ttl(NO_TTL_DATA)
, mFromTRR(aTRR)
{
Init(host, nullptr);
}
// deep copy constructor
AddrInfo::AddrInfo(const AddrInfo *src)
{
mHostName = src->mHostName;
mCanonicalName = src->mCanonicalName;
mHostName = nullptr;
if (src->mHostName) {
mHostName = strdup(src->mHostName);
}
mCanonicalName = nullptr;
if (src->mCanonicalName) {
mCanonicalName = strdup(src->mCanonicalName);
}
ttl = src->ttl;
mFromTRR = src->mFromTRR;
@ -355,6 +362,27 @@ AddrInfo::~AddrInfo()
while ((addrElement = mAddresses.popLast())) {
delete addrElement;
}
free(mHostName);
free(mCanonicalName);
}
void
AddrInfo::Init(const char *host, const char *cname)
{
MOZ_ASSERT(host, "Cannot initialize AddrInfo with a null host pointer!");
ttl = NO_TTL_DATA;
size_t hostlen = strlen(host);
mHostName = static_cast<char*>(moz_xmalloc(hostlen + 1));
memcpy(mHostName, host, hostlen + 1);
if (cname) {
size_t cnameLen = strlen(cname);
mCanonicalName = static_cast<char*>(moz_xmalloc(cnameLen + 1));
memcpy(mCanonicalName, cname, cnameLen + 1);
}
else {
mCanonicalName = nullptr;
}
}
void
@ -369,8 +397,8 @@ size_t
AddrInfo::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const
{
size_t n = mallocSizeOf(this);
n += mHostName.SizeOfExcludingThisIfUnshared(mallocSizeOf);
n += mCanonicalName.SizeOfExcludingThisIfUnshared(mallocSizeOf);
n += mallocSizeOf(mHostName);
n += mallocSizeOf(mCanonicalName);
n += mAddresses.sizeOfExcludingThis(mallocSizeOf);
return n;
}

View File

@ -8,7 +8,6 @@
#define DNS_h_
#include "nscore.h"
#include "nsString.h"
#include "prio.h"
#include "prnetdb.h"
#include "plstr.h"
@ -134,16 +133,16 @@ public:
class AddrInfo {
public:
// Creates an AddrInfo object.
explicit AddrInfo(const nsACString& host, const PRAddrInfo *prAddrInfo,
bool disableIPv4, bool filterNameCollision,
const nsACString& cname);
// Creates an AddrInfo object. It calls the AddrInfo(const char*, const char*)
// to initialize the host and the cname.
explicit AddrInfo(const char *host, const PRAddrInfo *prAddrInfo, bool disableIPv4,
bool filterNameCollision, const char *cname);
// Creates a basic AddrInfo object (initialize only the host, cname and TRR type).
explicit AddrInfo(const nsACString& host, const nsACString& cname, unsigned int TRRType);
explicit AddrInfo(const char *host, const char *cname, unsigned int TRRType);
// Creates a basic AddrInfo object (initialize only the host and TRR status).
explicit AddrInfo(const nsACString& host, unsigned int TRRType);
explicit AddrInfo(const char *host, unsigned int TRRType);
~AddrInfo();
explicit AddrInfo(const AddrInfo *src); // copy
@ -152,8 +151,8 @@ public:
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
nsCString mHostName;
nsCString mCanonicalName;
char *mHostName;
char *mCanonicalName;
uint32_t ttl;
static const uint32_t NO_TTL_DATA = (uint32_t) -1;
@ -161,6 +160,7 @@ public:
unsigned int IsTRR() { return mFromTRR; }
private:
unsigned int mFromTRR;
void Init(const char *host, const char *cname);
};
// Copies the contents of a PRNetAddr to a NetAddr.

View File

@ -196,9 +196,9 @@ _GetMinTTLForRequestType_Windows(DnsapiInfo * dnsapi, const char* aHost,
}
static MOZ_ALWAYS_INLINE nsresult
_GetTTLData_Windows(const nsACString& aHost, uint32_t* aResult, uint16_t aAddressFamily)
_GetTTLData_Windows(const char* aHost, uint32_t* aResult, uint16_t aAddressFamily)
{
MOZ_ASSERT(!aHost.IsEmpty());
MOZ_ASSERT(aHost);
MOZ_ASSERT(aResult);
if (aAddressFamily != PR_AF_UNSPEC &&
aAddressFamily != PR_AF_INET &&
@ -222,10 +222,10 @@ _GetTTLData_Windows(const nsACString& aHost, uint32_t* aResult, uint16_t aAddres
// and/or AAAA requests, based on the address family requested.
unsigned int ttl = (unsigned int)-1;
if (aAddressFamily == PR_AF_UNSPEC || aAddressFamily == PR_AF_INET) {
_GetMinTTLForRequestType_Windows(dnsapi, aHost.get(), DNS_TYPE_A, &ttl);
_GetMinTTLForRequestType_Windows(dnsapi, aHost, DNS_TYPE_A, &ttl);
}
if (aAddressFamily == PR_AF_UNSPEC || aAddressFamily == PR_AF_INET6) {
_GetMinTTLForRequestType_Windows(dnsapi, aHost.get(), DNS_TYPE_AAAA, &ttl);
_GetMinTTLForRequestType_Windows(dnsapi, aHost, DNS_TYPE_AAAA, &ttl);
}
{
@ -249,10 +249,10 @@ _GetTTLData_Windows(const nsACString& aHost, uint32_t* aResult, uint16_t aAddres
////////////////////////////////////
static MOZ_ALWAYS_INLINE nsresult
_GetAddrInfo_Portable(const nsACString& aCanonHost, uint16_t aAddressFamily,
_GetAddrInfo_Portable(const char* aCanonHost, uint16_t aAddressFamily,
uint16_t aFlags, AddrInfo** aAddrInfo)
{
MOZ_ASSERT(!aCanonHost.IsEmpty());
MOZ_ASSERT(aCanonHost);
MOZ_ASSERT(aAddrInfo);
// We accept the same aFlags that nsHostResolver::ResolveHost accepts, but we
@ -270,15 +270,15 @@ _GetAddrInfo_Portable(const nsACString& aCanonHost, uint16_t aAddressFamily,
aAddressFamily = PR_AF_UNSPEC;
}
PRAddrInfo* prai = PR_GetAddrInfoByName(aCanonHost.BeginReading(), aAddressFamily, prFlags);
PRAddrInfo* prai = PR_GetAddrInfoByName(aCanonHost, aAddressFamily, prFlags);
if (!prai) {
return NS_ERROR_UNKNOWN_HOST;
}
nsAutoCString canonName;
const char* canonName = nullptr;
if (aFlags & nsHostResolver::RES_CANON_NAME) {
canonName.Assign(PR_GetCanonNameFromAddrInfo(prai));
canonName = PR_GetCanonNameFromAddrInfo(prai);
}
bool filterNameCollision = !(aFlags & nsHostResolver::RES_ALLOW_NAME_COLLISION);
@ -320,10 +320,10 @@ GetAddrInfoShutdown() {
}
nsresult
GetAddrInfo(const nsACString& aHost, uint16_t aAddressFamily, uint16_t aFlags,
GetAddrInfo(const char* aHost, uint16_t aAddressFamily, uint16_t aFlags,
AddrInfo** aAddrInfo, bool aGetTtl)
{
if (NS_WARN_IF(aHost.IsEmpty()) || NS_WARN_IF(!aAddrInfo)) {
if (NS_WARN_IF(!aHost) || NS_WARN_IF(!aAddrInfo)) {
return NS_ERROR_NULL_POINTER;
}
@ -334,37 +334,35 @@ GetAddrInfo(const nsACString& aHost, uint16_t aAddressFamily, uint16_t aFlags,
}
#endif
nsAutoCString host(aHost);
if (gNativeIsLocalhost) {
// pretend we use the given host but use IPv4 localhost instead!
host = NS_LITERAL_CSTRING("localhost");
aHost = "localhost";
aAddressFamily = PR_AF_INET;
}
*aAddrInfo = nullptr;
nsresult rv = _GetAddrInfo_Portable(host, aAddressFamily, aFlags,
nsresult rv = _GetAddrInfo_Portable(aHost, aAddressFamily, aFlags,
aAddrInfo);
#ifdef DNSQUERY_AVAILABLE
if (aGetTtl && NS_SUCCEEDED(rv)) {
// Figure out the canonical name, or if that fails, just use the host name
// we have.
nsAutoCString name;
const char *name = nullptr;
if (*aAddrInfo != nullptr && (*aAddrInfo)->mCanonicalName) {
name = (*aAddrInfo)->mCanonicalName;
} else {
name = host;
name = aHost;
}
LOG("Getting TTL for %s (cname = %s).", host.get(), name.get());
LOG("Getting TTL for %s (cname = %s).", aHost, name);
uint32_t ttl = 0;
nsresult ttlRv = _GetTTLData_Windows(name, &ttl, aAddressFamily);
if (NS_SUCCEEDED(ttlRv)) {
(*aAddrInfo)->ttl = ttl;
LOG("Got TTL %u for %s (name = %s).", ttl, host, name.get());
LOG("Got TTL %u for %s (name = %s).", ttl, aHost, name);
} else {
LOG_WARNING("Could not get TTL for %s (cname = %s).", host.get(), name.get());
LOG_WARNING("Could not get TTL for %s (cname = %s).", aHost, name);
}
}
#endif

View File

@ -37,7 +37,7 @@ class AddrInfo;
* answers..
*/
nsresult
GetAddrInfo(const nsACString& aHost, uint16_t aAddressFamily, uint16_t aFlags,
GetAddrInfo(const char* aHost, uint16_t aAddressFamily, uint16_t aFlags,
AddrInfo** aAddrInfo, bool aGetTtl);
/**

View File

@ -394,7 +394,7 @@ TRR::ReceivePush(nsIHttpChannel *pushed, nsHostRecord *pushedRec)
RefPtr<nsHostRecord> hostRecord;
nsresult rv;
rv = mHostResolver->GetHostRecord(mHost,
rv = mHostResolver->GetHostRecord(mHost.get(),
pushedRec->flags, pushedRec->af,
pushedRec->pb,
pushedRec->originSuffix,
@ -824,7 +824,7 @@ nsresult
TRR::ReturnData()
{
// create and populate an AddrInfo instance to pass on
nsAutoPtr<AddrInfo> ai(new AddrInfo(mHost, mType));
nsAutoPtr<AddrInfo> ai(new AddrInfo(mHost.get(), mType));
DOHaddr *item;
uint32_t ttl = AddrInfo::NO_TTL_DATA;
while ((item = static_cast<DOHaddr*>(mDNS.mAddresses.popFirst()))) {
@ -857,7 +857,7 @@ TRR::FailData()
}
// create and populate an TRR AddrInfo instance to pass on to signal that
// this comes from TRR
AddrInfo *ai = new AddrInfo(mHost, mType);
AddrInfo *ai = new AddrInfo(mHost.get(), mType);
(void)mHostResolver->CompleteLookup(mRec, NS_ERROR_FAILURE, ai, mPB);
mHostResolver = nullptr;

View File

@ -589,10 +589,10 @@ TRRService::CompleteLookup(nsHostRecord *rec, nsresult status, AddrInfo *aNewRRS
// when called without a host record, this is a domain name check response.
if (NS_SUCCEEDED(status)) {
LOG(("TRR verified %s to be fine!\n", newRRSet->mHostName.get()));
LOG(("TRR verified %s to be fine!\n", newRRSet->mHostName));
} else {
LOG(("TRR says %s doesn't resolve as NS!\n", newRRSet->mHostName.get()));
TRRBlacklist(newRRSet->mHostName, pb, false);
LOG(("TRR says %s doesn't resolve as NS!\n", newRRSet->mHostName));
TRRBlacklist(nsCString(newRRSet->mHostName), pb, false);
}
return LOOKUP_OK;
}

View File

@ -92,18 +92,15 @@ nsDNSRecord::GetCanonicalName(nsACString &result)
NS_ERROR_NOT_AVAILABLE);
MutexAutoLock lock(mHostRecord->addr_info_lock);
// if the record is for an IP address literal, then the canonical
// host name is the IP address literal.
if (!mHostRecord->addr_info) {
result = mHostRecord->host;
return NS_OK;
}
if (mHostRecord->addr_info->mCanonicalName.IsEmpty()) {
result = mHostRecord->addr_info->mHostName;
if (mHostRecord->addr_info) {
const char* cname = mHostRecord->addr_info->mCanonicalName ?
mHostRecord->addr_info->mCanonicalName :
mHostRecord->addr_info->mHostName;
result.Assign(cname);
} else {
result = mHostRecord->addr_info->mCanonicalName;
// if the record is for an IP address literal, then the canonical
// host name is the IP address literal.
result = mHostRecord->host;
}
return NS_OK;
}
@ -396,7 +393,7 @@ NS_IMETHODIMP
nsDNSAsyncRequest::Cancel(nsresult reason)
{
NS_ENSURE_ARG(NS_FAILED(reason));
mResolver->DetachCallback(mHost, mOriginAttributes, mFlags, mAF,
mResolver->DetachCallback(mHost.get(), mOriginAttributes, mFlags, mAF,
this, reason);
return NS_OK;
}
@ -877,7 +874,7 @@ nsDNSService::AsyncResolveNative(const nsACString &aHostname,
if (!req)
return NS_ERROR_OUT_OF_MEMORY;
rv = res->ResolveHost(req->mHost, req->mOriginAttributes, flags, af, req);
rv = res->ResolveHost(req->mHost.get(), req->mOriginAttributes, flags, af, req);
req.forget(result);
return rv;
}
@ -937,7 +934,7 @@ nsDNSService::CancelAsyncResolveNative(const nsACString &aHostname,
uint16_t af = GetAFForLookup(hostname, aFlags);
res->CancelAsyncRequest(hostname, aOriginAttributes, aFlags, af,
res->CancelAsyncRequest(hostname.get(), aOriginAttributes, aFlags, af,
aListener, aReason);
return NS_OK;
}
@ -1037,7 +1034,7 @@ nsDNSService::ResolveInternal(const nsACString &aHostname,
uint16_t af = GetAFForLookup(hostname, flags);
rv = res->ResolveHost(hostname, aOriginAttributes, flags, af, syncReq);
rv = res->ResolveHost(hostname.get(), aOriginAttributes, flags, af, syncReq);
if (NS_SUCCEEDED(rv)) {
// wait for result
while (!syncReq->mDone) {

View File

@ -707,13 +707,13 @@ nsHostResolver::Shutdown()
}
nsresult
nsHostResolver::GetHostRecord(const nsACString &host,
nsHostResolver::GetHostRecord(const char *host,
uint16_t flags, uint16_t af, bool pb,
const nsCString &originSuffix,
nsHostRecord **result)
{
MutexAutoLock lock(mLock);
nsHostKey key(host, flags, af, pb, originSuffix);
nsHostKey key(nsCString(host), flags, af, pb, originSuffix);
RefPtr<nsHostRecord>& entry = mRecordDB.GetOrInsert(key);
if (!entry) {
@ -732,22 +732,21 @@ nsHostResolver::GetHostRecord(const nsACString &host,
}
nsresult
nsHostResolver::ResolveHost(const nsACString &aHost,
nsHostResolver::ResolveHost(const char *host,
const OriginAttributes &aOriginAttributes,
uint16_t flags,
uint16_t af,
nsResolveHostCallback *aCallback)
{
nsAutoCString host(aHost);
NS_ENSURE_TRUE(!host.IsEmpty(), NS_ERROR_UNEXPECTED);
NS_ENSURE_TRUE(host && *host, NS_ERROR_UNEXPECTED);
LOG(("Resolving host [%s]%s%s.\n", host.get(),
LOG(("Resolving host [%s]%s%s.\n", host,
flags & RES_BYPASS_CACHE ? " - bypassing cache" : "",
flags & RES_REFRESH_CACHE ? " - refresh cache" : ""));
// ensure that we are working with a valid hostname before proceeding. see
// bug 304904 for details.
if (!net_IsValidHostName(host))
if (!net_IsValidHostName(nsDependentCString(host)))
return NS_ERROR_UNKNOWN_HOST;
RefPtr<nsResolveHostCallback> callback(aCallback);
@ -776,7 +775,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
nsAutoCString originSuffix;
aOriginAttributes.CreateSuffix(originSuffix);
nsHostKey key(host, flags, af,
nsHostKey key(nsCString(host), flags, af,
(aOriginAttributes.mPrivateBrowsingId > 0),
originSuffix);
RefPtr<nsHostRecord>& entry = mRecordDB.GetOrInsert(key);
@ -788,7 +787,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
MOZ_ASSERT(rec, "Record should not be null");
if (!(flags & RES_BYPASS_CACHE) &&
rec->HasUsableResult(TimeStamp::NowLoRes(), flags)) {
LOG((" Using cached record for host [%s].\n", host.get()));
LOG((" Using cached record for host [%s].\n", host));
// put reference to host record on stack...
result = rec;
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2, METHOD_HIT);
@ -799,7 +798,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
ConditionallyRefreshRecord(rec, host);
if (rec->negative) {
LOG((" Negative cache entry for host [%s].\n", host.get()));
LOG((" Negative cache entry for host [%s].\n", host));
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
METHOD_NEGATIVE_HIT);
status = NS_ERROR_UNKNOWN_HOST;
@ -807,15 +806,15 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
} else if (rec->addr) {
// if the host name is an IP address literal and has been parsed,
// go ahead and use it.
LOG((" Using cached address for IP Literal [%s].\n", host.get()));
LOG((" Using cached address for IP Literal [%s].\n", host));
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
METHOD_LITERAL);
result = rec;
} else if (PR_StringToNetAddr(host.get(), &tempAddr) == PR_SUCCESS) {
} else if (PR_StringToNetAddr(host, &tempAddr) == PR_SUCCESS) {
// try parsing the host name as an IP address literal to short
// circuit full host resolution. (this is necessary on some
// platforms like Win9x. see bug 219376 for more details.)
LOG((" Host is IP Literal [%s].\n", host.get()));
LOG((" Host is IP Literal [%s].\n", host));
// ok, just copy the result into the host record, and be done
// with it! ;-)
rec->addr = MakeUnique<NetAddr>();
@ -829,13 +828,13 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
!rec->mResolving) {
LOG((" Lookup queue full: dropping %s priority request for "
"host [%s].\n",
IsMediumPriority(flags) ? "medium" : "low", host.get()));
IsMediumPriority(flags) ? "medium" : "low", host));
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
METHOD_OVERFLOW);
// This is a lower priority request and we are swamped, so refuse it.
rv = NS_ERROR_DNS_LOOKUP_QUEUE_FULL;
} else if (flags & RES_OFFLINE) {
LOG((" Offline request for host [%s]; ignoring.\n", host.get()));
LOG((" Offline request for host [%s]; ignoring.\n", host));
rv = NS_ERROR_OFFLINE;
} else if (!rec->mResolving) {
// If this is an IPV4 or IPV6 specific request, check if there is
@ -844,7 +843,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
if (!(flags & RES_BYPASS_CACHE) &&
((af == PR_AF_INET) || (af == PR_AF_INET6))) {
// First, search for an entry with AF_UNSPEC
const nsHostKey unspecKey(host, flags, PR_AF_UNSPEC,
const nsHostKey unspecKey(nsCString(host), flags, PR_AF_UNSPEC,
(aOriginAttributes.mPrivateBrowsingId > 0),
originSuffix);
RefPtr<nsHostRecord> unspecRec = mRecordDB.Get(unspecKey);
@ -855,7 +854,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
MOZ_ASSERT(unspecRec->addr_info || unspecRec->negative,
"Entry should be resolved or negative.");
LOG((" Trying AF_UNSPEC entry for host [%s] af: %s.\n", host.get(),
LOG((" Trying AF_UNSPEC entry for host [%s] af: %s.\n", host,
(af == PR_AF_INET) ? "AF_INET" : "AF_INET6"));
// We need to lock in case any other thread is reading
@ -907,7 +906,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
// AF_UNSPEC addresses, so we mark this record as
// negative.
LOG((" No AF_INET6 in AF_UNSPEC entry: "
"host [%s] unknown host.", host.get()));
"host [%s] unknown host.", host));
result = rec;
rec->negative = true;
status = NS_ERROR_UNKNOWN_HOST;
@ -919,7 +918,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
// If no valid address was found in the cache or this is an
// AF_UNSPEC request, then start a new lookup.
if (!result) {
LOG((" No usable address in cache for host [%s].", host.get()));
LOG((" No usable address in cache for host [%s].", host));
if (flags & RES_REFRESH_CACHE) {
rec->Invalidate();
@ -936,7 +935,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
} else {
LOG((" DNS lookup for host [%s] blocking "
"pending 'getaddrinfo' query: callback [%p]",
host.get(), callback.get()));
host, callback.get()));
}
}
} else if (rec->mDidCallbacks) {
@ -945,10 +944,10 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
result = rec;
// make it count as a hit
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2, METHOD_HIT);
LOG((" Host [%s] re-using early TRR resolve data\n", host.get()));
LOG((" Host [%s] re-using early TRR resolve data\n", host));
} else {
LOG((" Host [%s] is being resolved. Appending callback "
"[%p].", host.get(), callback.get()));
"[%p].", host, callback.get()));
rec->mCallbacks.insertBack(callback);
if (rec->onQueue) {
@ -992,7 +991,7 @@ nsHostResolver::ResolveHost(const nsACString &aHost,
}
void
nsHostResolver::DetachCallback(const nsACString &host,
nsHostResolver::DetachCallback(const char *host,
const OriginAttributes &aOriginAttributes,
uint16_t flags,
uint16_t af,
@ -1008,7 +1007,7 @@ nsHostResolver::DetachCallback(const nsACString &host,
nsAutoCString originSuffix;
aOriginAttributes.CreateSuffix(originSuffix);
nsHostKey key(host, flags, af,
nsHostKey key(nsCString(host), flags, af,
(aOriginAttributes.mPrivateBrowsingId > 0),
originSuffix);
RefPtr<nsHostRecord> entry = mRecordDB.Get(key);
@ -1267,12 +1266,12 @@ nsHostResolver::NameLookup(nsHostRecord *rec)
}
nsresult
nsHostResolver::ConditionallyRefreshRecord(nsHostRecord *rec, const nsACString &host)
nsHostResolver::ConditionallyRefreshRecord(nsHostRecord *rec, const char *host)
{
if ((rec->CheckExpiration(TimeStamp::NowLoRes()) != nsHostRecord::EXP_VALID
|| rec->negative) && !rec->mResolving) {
LOG((" Using %s cache entry for host [%s] but starting async renewal.",
rec->negative ? "negative" :"positive", host.BeginReading()));
rec->negative ? "negative" :"positive", host));
NameLookup(rec);
if (!rec->negative) {
@ -1419,7 +1418,7 @@ different_rrset(AddrInfo *rrset1, AddrInfo *rrset2)
return true;
}
LOG(("different_rrset %s\n", rrset1->mHostName.get()));
LOG(("different_rrset %s\n", rrset1->mHostName));
nsTArray<NetAddr> orderedSet1;
nsTArray<NetAddr> orderedSet2;
@ -1496,7 +1495,7 @@ nsHostResolver::CompleteLookup(nsHostRecord* rec, nsresult status, AddrInfo* aNe
if (trrResult) {
MutexAutoLock trrlock(rec->mTrrLock);
LOG(("TRR lookup Complete (%d) %s %s\n",
newRRSet->IsTRR(), newRRSet->mHostName.get(),
newRRSet->IsTRR(), newRRSet->mHostName,
NS_SUCCEEDED(status) ? "OK" : "FAILED"));
MOZ_ASSERT(TRROutstanding());
if (newRRSet->IsTRR() == TRRTYPE_A) {
@ -1705,7 +1704,7 @@ nsHostResolver::CompleteLookup(nsHostRecord* rec, nsresult status, AddrInfo* aNe
}
void
nsHostResolver::CancelAsyncRequest(const nsACString &host,
nsHostResolver::CancelAsyncRequest(const char *host,
const OriginAttributes &aOriginAttributes,
uint16_t flags,
uint16_t af,
@ -1720,7 +1719,7 @@ nsHostResolver::CancelAsyncRequest(const nsACString &host,
// Lookup the host record associated with host, flags & address family
nsHostKey key(host, flags, af,
nsHostKey key(nsCString(host), flags, af,
(aOriginAttributes.mPrivateBrowsingId > 0),
originSuffix);
RefPtr<nsHostRecord> rec = mRecordDB.Get(key);
@ -1802,12 +1801,12 @@ nsHostResolver::ThreadFunc(void *arg)
TimeStamp startTime = TimeStamp::Now();
bool getTtl = rec->mGetTtl;
nsresult status = GetAddrInfo(rec->host, rec->af,
nsresult status = GetAddrInfo(rec->host.get(), rec->af,
rec->flags, &ai,
getTtl);
#if defined(RES_RETRY_ON_FAILURE)
if (NS_FAILED(status) && rs.Reset()) {
status = GetAddrInfo(rec->host, rec->af,
status = GetAddrInfo(rec->host.get(), rec->af,
rec->flags, &ai, getTtl);
}
#endif

View File

@ -277,7 +277,7 @@ public:
};
virtual LookupStatus CompleteLookup(nsHostRecord *, nsresult, mozilla::net::AddrInfo *, bool pb) = 0;
virtual nsresult GetHostRecord(const nsACString &host,
virtual nsresult GetHostRecord(const char *host,
uint16_t flags, uint16_t af, bool pb,
const nsCString &originSuffix,
nsHostRecord **result)
@ -329,7 +329,7 @@ public:
* host lookup cannot be canceled (cancelation can be layered above this by
* having the callback implementation return without doing anything).
*/
nsresult ResolveHost(const nsACString &hostname,
nsresult ResolveHost(const char *hostname,
const mozilla::OriginAttributes &aOriginAttributes,
uint16_t flags,
uint16_t af,
@ -341,7 +341,7 @@ public:
* should correspond to the parameters passed to ResolveHost. this function
* executes the callback if the callback is still pending with the given status.
*/
void DetachCallback(const nsACString &hostname,
void DetachCallback(const char *hostname,
const mozilla::OriginAttributes &aOriginAttributes,
uint16_t flags,
uint16_t af,
@ -355,7 +355,7 @@ public:
* passed to ResolveHost. If this is the last callback associated with the
* host record, it is removed from any request queues it might be on.
*/
void CancelAsyncRequest(const nsACString &host,
void CancelAsyncRequest(const char *host,
const mozilla::OriginAttributes &aOriginAttributes,
uint16_t flags,
uint16_t af,
@ -390,7 +390,7 @@ public:
void FlushCache();
LookupStatus CompleteLookup(nsHostRecord *, nsresult, mozilla::net::AddrInfo *, bool pb) override;
nsresult GetHostRecord(const nsACString &host,
nsresult GetHostRecord(const char *host,
uint16_t flags, uint16_t af, bool pb,
const nsCString &originSuffix,
nsHostRecord **result) override;
@ -425,7 +425,7 @@ private:
* Starts a new lookup in the background for entries that are in the grace
* period with a failed connect or all cached entries are negative.
*/
nsresult ConditionallyRefreshRecord(nsHostRecord *rec, const nsACString &host);
nsresult ConditionallyRefreshRecord(nsHostRecord *rec, const char *host);
static void ThreadFunc(void *);