Backed out 2 changesets (bug 1417827) for windows build bustage. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Thu, 14 Jun 2018 22:07:18 +0300
changeset 422581 24bfb36d26e86f8c8a2b8e03a82081f4041c57f2
parent 422580 efeb9170c20175cd350c1d545e726bdd37197b09
child 422582 95abb158e9eb5370ce4466ba2a36070aa6c8a4b8
push id65189
push userdluca@mozilla.com
push dateThu, 14 Jun 2018 19:08:52 +0000
treeherderautoland@24bfb36d26e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1417827
milestone62.0a1
backs out35655153f9c927031e251bfd04c8a2effb51d6ae
9606d0d95b5387f124a3de62fb6475952f566829
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 1417827) for windows build bustage. CLOSED TREE Backed out changeset 35655153f9c9 (bug 1417827) Backed out changeset 9606d0d95b53 (bug 1417827)
netwerk/dns/DNS.cpp
netwerk/dns/DNS.h
netwerk/dns/GetAddrInfo.cpp
netwerk/dns/GetAddrInfo.h
netwerk/dns/TRR.cpp
netwerk/dns/TRRService.cpp
netwerk/dns/nsDNSService2.cpp
netwerk/dns/nsHostResolver.cpp
netwerk/dns/nsHostResolver.h
--- a/netwerk/dns/DNS.cpp
+++ b/netwerk/dns/DNS.cpp
@@ -4,17 +4,16 @@
  * 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 "mozilla/net/DNS.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/ArrayUtils.h"
-#include "nsString.h"
 #include <string.h>
 
 #ifdef XP_WIN
 #include "ws2tcpip.h"
 #endif
 
 namespace mozilla {
 namespace net {
@@ -289,91 +288,120 @@ NetAddrElement::NetAddrElement(const PRN
 
 NetAddrElement::NetAddrElement(const NetAddrElement& netAddr)
 {
   mAddress = netAddr.mAddress;
 }
 
 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 {
     iter = PR_EnumerateAddrInfo(iter, prAddrInfo, 0, &tmpAddr);
     bool addIt = iter &&
         (!disableIPv4 || tmpAddr.raw.family != PR_AF_INET) &&
         (!filterNameCollision || tmpAddr.raw.family != PR_AF_INET || (tmpAddr.inet.ip != nameCollisionAddr));
     if (addIt) {
         auto *addrElement = new NetAddrElement(&tmpAddr);
         mAddresses.insertBack(addrElement);
     }
   } 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;
 
   for (auto element = src->mAddresses.getFirst(); element;
        element = element->getNext()) {
     AddAddress(new NetAddrElement(*element));
   }
 }
 
 AddrInfo::~AddrInfo()
 {
   NetAddrElement *addrElement;
   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
 AddrInfo::AddAddress(NetAddrElement *address)
 {
   MOZ_ASSERT(address, "Cannot add the address to an uninitialized list");
 
   mAddresses.insertBack(address);
 }
 
 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;
 }
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/dns/DNS.h
+++ b/netwerk/dns/DNS.h
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef DNS_h_
 #define DNS_h_
 
 #include "nscore.h"
-#include "nsString.h"
 #include "prio.h"
 #include "prnetdb.h"
 #include "plstr.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/MemoryReporting.h"
 
 #if !defined(XP_WIN)
 #include <arpa/inet.h>
@@ -129,43 +128,44 @@ public:
   NetAddrElement(const NetAddrElement& netAddr);
   ~NetAddrElement();
 
   NetAddr mAddress;
 };
 
 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
 
   void AddAddress(NetAddrElement *address);
 
   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;
 
   LinkedList<NetAddrElement> mAddresses;
   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.
 // Does not do a ptr safety check!
 void PRNetAddrToNetAddr(const PRNetAddr *prAddr, NetAddr *addr);
 
 // Copies the contents of a NetAddr to a PRNetAddr.
 // Does not do a ptr safety check!
--- a/netwerk/dns/GetAddrInfo.cpp
+++ b/netwerk/dns/GetAddrInfo.cpp
@@ -191,19 +191,19 @@ static MOZ_ALWAYS_INLINE nsresult
     }
   }
 
   dnsapi->mDnsFreeFunc(dnsData, DNS_FREE_TYPE::DnsFreeRecordList);
   return NS_OK;
 }
 
 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 &&
       aAddressFamily != PR_AF_INET6) {
     return NS_ERROR_UNEXPECTED;
   }
 
   RefPtr<DnsapiInfo> dnsapi = nullptr;
@@ -217,20 +217,20 @@ static MOZ_ALWAYS_INLINE nsresult
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // In order to avoid using ANY records which are not always implemented as a
   // "Gimme what you have" request in hostname resolvers, we should send A
   // 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);
   }
 
   {
     // dnsapi's destructor is not thread-safe, so we release explicitly here
     OffTheBooksMutexAutoLock lock(*gDnsapiInfoLock);
     dnsapi = nullptr;
   }
 
@@ -244,20 +244,20 @@ static MOZ_ALWAYS_INLINE nsresult
 }
 #endif
 
 ////////////////////////////////////
 // PORTABLE RUNTIME IMPLEMENTATION//
 ////////////////////////////////////
 
 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
   // need to translate the aFlags into a form that PR_GetAddrInfoByName
   // accepts.
   int prFlags = PR_AI_ADDRCONFIG;
   if (!(aFlags & nsHostResolver::RES_CANON_NAME)) {
     prFlags |= PR_AI_NOCANONNAME;
@@ -265,25 +265,25 @@ static MOZ_ALWAYS_INLINE nsresult
 
   // We need to remove IPv4 records manually because PR_GetAddrInfoByName
   // doesn't support PR_AF_INET6.
   bool disableIPv4 = aAddressFamily == PR_AF_INET6;
   if (disableIPv4) {
     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);
   nsAutoPtr<AddrInfo> ai(new AddrInfo(aCanonHost, prai, disableIPv4,
                                       filterNameCollision, canonName));
   PR_FreeAddrInfo(prai);
   if (ai->mAddresses.isEmpty()) {
     return NS_ERROR_UNKNOWN_HOST;
@@ -315,61 +315,59 @@ GetAddrInfoShutdown() {
 #ifdef DNSQUERY_AVAILABLE
   return _GetAddrInfoShutdown_Windows();
 #else
   return NS_OK;
 #endif
 }
 
 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;
   }
 
 #ifdef DNSQUERY_AVAILABLE
   // The GetTTLData needs the canonical name to function properly
   if (aGetTtl) {
     aFlags |= nsHostResolver::RES_CANON_NAME;
   }
 #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
 
   return rv;
 }
 
 } // namespace net
--- a/netwerk/dns/GetAddrInfo.h
+++ b/netwerk/dns/GetAddrInfo.h
@@ -32,17 +32,17 @@ class AddrInfo;
  *     suppress the determination of the canonical name corresponding to
  *     hostname (PR_AI_NOCANONNAME will be ignored if the TTL is retrieved).
  * @param aAddrInfo[out] Will point to the results of the host lookup, or be
  *     null if the lookup failed.
  * @param aGetTtl[in] If true, the TTL will be retrieved if DNS provides the
  *     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);
 
 /**
  * Initialize the GetAddrInfo module.
  *
  * GetAddrInfoShutdown() should be called for every time this function is
  * called.
  */
--- a/netwerk/dns/TRR.cpp
+++ b/netwerk/dns/TRR.cpp
@@ -389,17 +389,17 @@ TRR::ReceivePush(nsIHttpChannel *pushed,
   if (NS_FAILED(DohDecodeQuery(query, mHost, mType)) ||
       (PR_StringToNetAddr(mHost.get(), &tempAddr) == PR_SUCCESS)) { // literal
     LOG(("TRR::ReceivePush failed to decode %s\n", mHost.get()));
     return NS_ERROR_UNEXPECTED;
   }
 
   RefPtr<nsHostRecord> hostRecord;
   nsresult rv;
-  rv = mHostResolver->GetHostRecord(mHost,
+  rv = mHostResolver->GetHostRecord(mHost.get(),
                                     pushedRec->flags, pushedRec->af,
                                     pushedRec->pb,
                                     pushedRec->originSuffix,
                                     getter_AddRefs(hostRecord));
   if (NS_FAILED(rv)) {
     return rv;
   }
 
@@ -819,17 +819,17 @@ TRR::DohDecode(nsCString &aHost)
   }
   return NS_OK;
 }
 
 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()))) {
     PRNetAddr prAddr;
     NetAddrToPRNetAddr(&item->mNet, &prAddr);
     auto *addrElement = new NetAddrElement(&prAddr);
     ai->AddAddress(addrElement);
     if (item->mTtl < ttl) {
@@ -852,17 +852,17 @@ TRR::ReturnData()
 nsresult
 TRR::FailData()
 {
   if (!mHostResolver) {
     return NS_ERROR_FAILURE;
   }
   // 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;
   mRec = nullptr;
   return NS_OK;
 }
 
 nsresult
--- a/netwerk/dns/TRRService.cpp
+++ b/netwerk/dns/TRRService.cpp
@@ -584,20 +584,20 @@ TRRService::CompleteLookup(nsHostRecord 
       }
       mRetryConfirmInterval = 1000;
     }
     return LOOKUP_OK;
   }
 
   // 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;
 }
 
 #undef LOG
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -87,28 +87,25 @@ NS_IMPL_ISUPPORTS(nsDNSRecord, nsIDNSRec
 NS_IMETHODIMP
 nsDNSRecord::GetCanonicalName(nsACString &result)
 {
     // this method should only be called if we have a CNAME
     NS_ENSURE_TRUE(mHostRecord->flags & nsHostResolver::RES_CANON_NAME,
                    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) {
+    if (mHostRecord->addr_info) {
+        const char* cname = mHostRecord->addr_info->mCanonicalName ?
+            mHostRecord->addr_info->mCanonicalName :
+            mHostRecord->addr_info->mHostName;
+        result.Assign(cname);
+    } else {
+        // 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;
-    }
-
-    if (mHostRecord->addr_info->mCanonicalName.IsEmpty()) {
-        result = mHostRecord->addr_info->mHostName;
-    } else {
-        result = mHostRecord->addr_info->mCanonicalName;
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDNSRecord::IsTRR(bool *retval)
 {
     MutexAutoLock lock(mHostRecord->addr_info_lock);
@@ -391,17 +388,17 @@ nsDNSAsyncRequest::SizeOfIncludingThis(M
 
     return n;
 }
 
 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;
 }
 
 //-----------------------------------------------------------------------------
 
 class nsDNSSyncRequest
     : public nsResolveHostCallback
@@ -872,17 +869,17 @@ nsDNSService::AsyncResolveNative(const n
     uint16_t af = GetAFForLookup(hostname, flags);
 
     MOZ_ASSERT(listener);
     RefPtr<nsDNSAsyncRequest> req =
         new nsDNSAsyncRequest(res, hostname, aOriginAttributes, listener, flags, af);
     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;
 }
 
 NS_IMETHODIMP
 nsDNSService::CancelAsyncResolve(const nsACString &aHostname,
                                  uint32_t          aFlags,
                                  nsIDNSListener   *aListener,
@@ -932,17 +929,17 @@ nsDNSService::CancelAsyncResolveNative(c
     nsCString hostname;
     nsresult rv = PreprocessHostname(localDomain, aHostname, idn, hostname);
     if (NS_FAILED(rv)) {
         return rv;
     }
 
     uint16_t af = GetAFForLookup(hostname, aFlags);
 
-    res->CancelAsyncRequest(hostname, aOriginAttributes, aFlags, af,
+    res->CancelAsyncRequest(hostname.get(), aOriginAttributes, aFlags, af,
                             aListener, aReason);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDNSService::Resolve(const nsACString  &aHostname,
                       uint32_t           flags,
                       JS::HandleValue    aOriginAttributes,
@@ -1032,17 +1029,17 @@ nsDNSService::ResolveInternal(const nsAC
     if (!mon)
         return NS_ERROR_OUT_OF_MEMORY;
 
     PR_EnterMonitor(mon);
     RefPtr<nsDNSSyncRequest> syncReq = new nsDNSSyncRequest(mon);
 
     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) {
             PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);
         }
 
         if (NS_FAILED(syncReq->mStatus)) {
             rv = syncReq->mStatus;
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -702,23 +702,23 @@ nsHostResolver::Shutdown()
     {
         mozilla::DebugOnly<nsresult> rv = GetAddrInfoShutdown();
         NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                              "Failed to shutdown GetAddrInfo");
     }
 }
 
 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) {
         entry = new nsHostRecord(key);
     }
 
     RefPtr<nsHostRecord> rec = entry;
     if (rec->addr) {
@@ -727,32 +727,31 @@ nsHostResolver::GetHostRecord(const nsAC
     if (rec->mResolving) {
         return NS_ERROR_FAILURE;
     }
     *result = rec.forget().take();
     return NS_OK;
 }
 
 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);
     // if result is set inside the lock, then we need to issue the
     // callback before returning.
     RefPtr<nsHostRecord> result;
     nsresult status = NS_OK, rv = NS_OK;
     {
@@ -771,96 +770,96 @@ nsHostResolver::ResolveHost(const nsACSt
             // in the hash table.  if so, then check to see if we can't
             // just reuse the lookup result.  otherwise, if there are
             // any pending callbacks, then add to pending callbacks queue,
             // and return.  otherwise, add ourselves as first pending
             // callback, and proceed to do the lookup.
             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);
             if (!entry) {
                 entry = new nsHostRecord(key);
             }
 
             RefPtr<nsHostRecord> rec = entry;
             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);
 
                 // For entries that are in the grace period
                 // or all cached negative entries, use the cache but start a new
                 // lookup in the background
                 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;
                 }
             } 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>();
                 PRNetAddrToNetAddr(&tempAddr, rec->addr.get());
                 // put reference to host record on stack...
                 Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
                                       METHOD_LITERAL);
                 result = rec;
             } else if (mPendingCount >= MAX_NON_PRIORITY_REQUESTS &&
                        !IsHighPriority(flags) &&
                        !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
                 // an AF_UNSPEC entry we can use. Otherwise, hit the resolver...
 
                 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);
 
                     TimeStamp now = TimeStamp::NowLoRes();
                     if (unspecRec && unspecRec->HasUsableResult(now, flags)) {
 
                         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
                         // addr_info.
                         MutexAutoLock lock(rec->addr_info_lock);
 
                         // XXX: note that this actually leaks addr_info.
                         // For some reason, freeing the memory causes a crash in
@@ -902,58 +901,58 @@ nsHostResolver::ResolveHost(const nsACSt
                                                   METHOD_HIT);
                             ConditionallyRefreshRecord(rec, host);
                         } else if (af == PR_AF_INET6) {
                             // For AF_INET6, a new lookup means another AF_UNSPEC
                             // lookup. We have already iterated through the
                             // 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;
                             Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
                                                   METHOD_NEGATIVE_HIT);
                         }
                     }
                 }
                 // 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();
                     }
 
                     // Add callback to the list of pending callbacks.
                     rec->mCallbacks.insertBack(callback);
                     rec->flags = flags;
                     rv = NameLookup(rec);
                     Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
                                           METHOD_NETWORK_FIRST);
                     if (NS_FAILED(rv) && callback->isInList()) {
                         callback->remove();
                     } else {
                         LOG(("  DNS lookup for host [%s] blocking "
                              "pending 'getaddrinfo' query: callback [%p]",
-                             host.get(), callback.get()));
+                             host, callback.get()));
                     }
                 }
             } else if (rec->mDidCallbacks) {
                 // record is still pending more (TRR) data; make the callback
                 // at once
                 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) {
                     Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
                                           METHOD_NETWORK_SHARED);
 
                     // Consider the case where we are on a pending queue of
                     // lower priority than the request is being made at.
@@ -987,33 +986,33 @@ nsHostResolver::ResolveHost(const nsACSt
         }
         callback->OnResolveHostComplete(this, result, status);
     }
 
     return rv;
 }
 
 void
-nsHostResolver::DetachCallback(const nsACString &host,
+nsHostResolver::DetachCallback(const char             *host,
                                const OriginAttributes &aOriginAttributes,
                                uint16_t                flags,
                                uint16_t                af,
                                nsResolveHostCallback  *aCallback,
                                nsresult                status)
 {
     RefPtr<nsHostRecord> rec;
     RefPtr<nsResolveHostCallback> callback(aCallback);
 
     {
         MutexAutoLock lock(mLock);
 
         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);
         if (entry) {
             // walk list looking for |callback|... we cannot assume
             // that it will be there!
 
             for (nsResolveHostCallback* c: entry->mCallbacks) {
@@ -1262,22 +1261,22 @@ nsHostResolver::NameLookup(nsHostRecord 
         ((mode == MODE_TRRFIRST) && NS_FAILED(rv))) {
         rv = NativeLookup(rec);
     }
 
     return rv;
 }
 
 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) {
             // negative entries are constantly being refreshed, only
             // track positive grace period induced renewals
             Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
                 METHOD_RENEWAL);
         }
@@ -1414,17 +1413,17 @@ merge_rrset(AddrInfo *rrto, AddrInfo *rr
 
 static bool
 different_rrset(AddrInfo *rrset1, AddrInfo *rrset2)
 {
     if (!rrset1 || !rrset2) {
         return true;
     }
 
-    LOG(("different_rrset %s\n", rrset1->mHostName.get()));
+    LOG(("different_rrset %s\n", rrset1->mHostName));
     nsTArray<NetAddr> orderedSet1;
     nsTArray<NetAddr> orderedSet2;
 
     if (rrset1->IsTRR() != rrset2->IsTRR()) {
         return true;
     }
 
     for (NetAddrElement *element = rrset1->mAddresses.getFirst();
@@ -1491,17 +1490,17 @@ nsHostResolver::CompleteLookup(nsHostRec
     rec->mResolving--;
     LOG(("nsHostResolver::CompleteLookup %s %p %X trr=%d stillResolving=%d\n",
          rec->host.get(), aNewRRSet, (unsigned int)status,
          aNewRRSet ? aNewRRSet->IsTRR() : 0, rec->mResolving));
 
     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) {
             MOZ_ASSERT(rec->mTrrA);
             rec->mTrrA = nullptr;
             rec->mTrrAUsed = NS_SUCCEEDED(status) ? nsHostRecord::OK : nsHostRecord::FAILED;
         } else if (newRRSet->IsTRR() == TRRTYPE_AAAA) {
             MOZ_ASSERT(rec->mTrrAAAA);
@@ -1700,32 +1699,32 @@ nsHostResolver::CompleteLookup(nsHostRec
             NS_SUCCEEDED(rv),
             "Could not issue second async lookup for TTL.");
     }
 #endif
     return LOOKUP_OK;
 }
 
 void
-nsHostResolver::CancelAsyncRequest(const nsACString &host,
+nsHostResolver::CancelAsyncRequest(const char             *host,
                                    const OriginAttributes &aOriginAttributes,
                                    uint16_t                flags,
                                    uint16_t                af,
                                    nsIDNSListener         *aListener,
                                    nsresult                status)
 
 {
     MutexAutoLock lock(mLock);
 
     nsAutoCString originSuffix;
     aOriginAttributes.CreateSuffix(originSuffix);
 
     // 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);
     if (rec) {
         nsHostRecord* recPtr = nullptr;
 
         for (RefPtr<nsResolveHostCallback> c : rec->mCallbacks) {
             if (c->EqualsAsyncListener(aListener)) {
@@ -1797,22 +1796,22 @@ nsHostResolver::ThreadFunc(void *arg)
             rec.swap(tmpRec);
         }
 
         LOG(("DNS lookup thread - Calling getaddrinfo for host [%s].\n",
              rec->host.get()));
         
         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
 
         {   // obtain lock to check shutdown and manage inter-module telemetry
             MutexAutoLock lock(resolver->mLock);
 
             if (!resolver->mShutdown) {
--- a/netwerk/dns/nsHostResolver.h
+++ b/netwerk/dns/nsHostResolver.h
@@ -272,17 +272,17 @@ public:
     NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
      enum LookupStatus {
         LOOKUP_OK,
         LOOKUP_RESOLVEAGAIN,
     };
 
     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)
     {
         return NS_ERROR_FAILURE;
     }
     virtual nsresult TrrLookup_unlocked(nsHostRecord *, mozilla::net::TRR *pushedTRR = nullptr)
     {
@@ -324,43 +324,43 @@ public:
 
     /**
      * resolve the given hostname and originAttributes asynchronously.  the caller
      * can synthesize a synchronous host lookup using a lock and a cvar.  as noted
      * above the callback will occur re-entrantly from an unspecified thread.  the
      * 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,
                          nsResolveHostCallback           *callback);
 
     /**
      * removes the specified callback from the nsHostRecord for the given
      * hostname, originAttributes, flags, and address family.  these parameters
      * 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,
                         nsResolveHostCallback           *callback,
                         nsresult                         status);
 
     /**
      * Cancels an async request associated with the hostname, originAttributes, flags,
      * address family and listener.  Cancels first callback found which matches
      * these criteria.  These parameters should correspond to the parameters
      * 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,
                             nsIDNSListener                  *aListener,
                             nsresult                         status);
     /**
      * values for the flags parameter passed to ResolveHost and DetachCallback
      * that may be bitwise OR'd together.
@@ -385,17 +385,17 @@ public:
     size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
 
     /**
      * Flush the DNS cache.
      */
     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;
     nsresult TrrLookup_unlocked(nsHostRecord *, mozilla::net::TRR *pushedTRR = nullptr) override;
 
 private:
    explicit nsHostResolver(uint32_t maxCacheEntries,
                            uint32_t defaultCacheEntryLifetime,
@@ -420,17 +420,17 @@ private:
     // calls CompleteLookup with the NS_ERROR_ABORT result code.
     void     ClearPendingQueue(mozilla::LinkedList<RefPtr<nsHostRecord>>& aPendingQ);
     nsresult ConditionallyCreateThread(nsHostRecord *rec);
 
     /**
      * 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 *);
 
     enum {
         METHOD_HIT = 1,
         METHOD_RENEWAL = 2,
         METHOD_NEGATIVE_HIT = 3,
         METHOD_LITERAL = 4,