Bug 1384834 (part 2) - Remove remaining uses of nsAdoptingCString. r=erahm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 28 Jul 2017 11:21:47 +1000
changeset 372162 d1f258975b80a9cef336962987cdf33113a8ddb2
parent 372161 dd41537bcdd1b492583c553ec0191d2fd70689c7
child 372163 f3b45d52b78e2757f26559033bdb476e22c35159
push id32266
push userarchaeopteryx@coole-files.de
push dateTue, 01 Aug 2017 09:24:14 +0000
treeherdermozilla-central@51ffb9283f0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1384834
milestone56.0a1
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
Bug 1384834 (part 2) - Remove remaining uses of nsAdoptingCString. r=erahm.
dom/security/test/gtest/TestCSPParser.cpp
gfx/thebes/gfxPrefs.cpp
netwerk/dns/nsDNSService2.cpp
netwerk/dns/nsDNSService2.h
netwerk/streamconv/converters/nsIndexedToHTML.cpp
toolkit/components/extensions/WebExtensionPolicy.cpp
widget/tests/TestChromeMargin.cpp
--- a/dom/security/test/gtest/TestCSPParser.cpp
+++ b/dom/security/test/gtest/TestCSPParser.cpp
@@ -14,17 +14,16 @@
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
 class nsACString;
 class nsAString;
 class nsString;
 class nsCString;
-class nsAdoptingCString;
 class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nsIContentSecurityPolicy.h"
 #include "nsNetUtil.h"
 #include "nsIScriptSecurityManager.h"
 #include "mozilla/dom/nsCSPContext.h"
--- a/gfx/thebes/gfxPrefs.cpp
+++ b/gfx/thebes/gfxPrefs.cpp
@@ -192,17 +192,17 @@ float gfxPrefs::PrefGet(const char* aPre
   MOZ_ASSERT(IsPrefsServiceAvailable());
   return Preferences::GetFloat(aPref, aDefault);
 }
 
 std::string gfxPrefs::PrefGet(const char* aPref, std::string aDefault)
 {
   MOZ_ASSERT(IsPrefsServiceAvailable());
 
-  nsAdoptingCString result;
+  nsAutoCString result;
   Preferences::GetCString(aPref, result);
 
   if (result.IsEmpty()) {
     return aDefault;
   }
 
   return result.get();
 }
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -542,19 +542,19 @@ nsDNSService::Init()
     uint32_t defaultGracePeriod = 60; // seconds
     bool     disableIPv6      = false;
     bool     offlineLocalhost = true;
     bool     disablePrefetch  = false;
     bool     blockDotOnion    = true;
     int      proxyType        = nsIProtocolProxyService::PROXYCONFIG_DIRECT;
     bool     notifyResolution = false;
 
-    nsAdoptingCString ipv4OnlyDomains;
-    nsAdoptingCString localDomains;
-    nsAdoptingCString forceResolve;
+    nsCString ipv4OnlyDomains;
+    nsCString localDomains;
+    nsCString forceResolve;
 
     // read prefs
     nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefs) {
         int32_t val;
         if (NS_SUCCEEDED(prefs->GetIntPref(kPrefDnsCacheEntries, &val)))
             maxCacheEntries = (uint32_t) val;
         if (NS_SUCCEEDED(prefs->GetIntPref(kPrefDnsCacheExpiration, &val)))
@@ -613,28 +613,28 @@ nsDNSService::Init()
                                          defaultCacheLifetime,
                                          defaultGracePeriod,
                                          getter_AddRefs(res));
     if (NS_SUCCEEDED(rv)) {
         // now, set all of our member variables while holding the lock
         MutexAutoLock lock(mLock);
         mResolver = res;
         mIDN = idn;
-        mIPv4OnlyDomains = ipv4OnlyDomains; // exchanges buffer ownership
+        mIPv4OnlyDomains = ipv4OnlyDomains;
         mOfflineLocalhost = offlineLocalhost;
         mDisableIPv6 = disableIPv6;
         mBlockDotOnion = blockDotOnion;
         mForceResolve = forceResolve;
         mForceResolveOn = !mForceResolve.IsEmpty();
 
         // Disable prefetching either by explicit preference or if a manual proxy is configured
         mDisablePrefetch = disablePrefetch || (proxyType == nsIProtocolProxyService::PROXYCONFIG_MANUAL);
 
         mLocalDomains.Clear();
-        if (localDomains) {
+        if (!localDomains.IsVoid()) {
             nsCCharSeparatedTokenizer tokenizer(localDomains, ',',
                                                 nsCCharSeparatedTokenizer::SEPARATOR_OPTIONAL);
 
             while (tokenizer.hasMoreTokens()) {
                 mLocalDomains.PutEntry(tokenizer.nextToken());
             }
         }
         mNotifyResolution = notifyResolution;
--- a/netwerk/dns/nsDNSService2.h
+++ b/netwerk/dns/nsDNSService2.h
@@ -54,18 +54,18 @@ private:
     nsCOMPtr<nsIIDNService>   mIDN;
 
     // mLock protects access to mResolver and mIPv4OnlyDomains
     mozilla::Mutex            mLock;
 
     // mIPv4OnlyDomains is a comma-separated list of domains for which only
     // IPv4 DNS lookups are performed. This allows the user to disable IPv6 on
     // a per-domain basis and work around broken DNS servers. See bug 68796.
-    nsAdoptingCString                         mIPv4OnlyDomains;
-    nsAdoptingCString                         mForceResolve;
+    nsCString                                 mIPv4OnlyDomains;
+    nsCString                                 mForceResolve;
     bool                                      mDisableIPv6;
     bool                                      mDisablePrefetch;
     bool                                      mBlockDotOnion;
     bool                                      mFirstTime;
     bool                                      mNotifyResolution;
     bool                                      mOfflineLocalhost;
     bool                                      mForceResolveOn;
     nsTHashtable<nsCStringHashKey>            mLocalDomains;
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -551,17 +551,18 @@ nsIndexedToHTML::DoOnStartRequest(nsIReq
     if (!baseUri.Contains('"'))
     {
         // Great, the baseUri does not contain a char that
         // will prematurely close the string.  Go ahead an
         // add a base href, but only do so if we're not
         // dealing with a resource URI.
         if (!isResource) {
             buffer.AppendLiteral("<base href=\"");
-            nsAdoptingCString htmlEscapedUri(nsEscapeHTML(baseUri.get()));
+            nsCString htmlEscapedUri;
+            htmlEscapedUri.Adopt(nsEscapeHTML(baseUri.get()));
             buffer.Append(htmlEscapedUri);
             buffer.AppendLiteral("\" />\n");
         }
     }
     else
     {
         NS_ERROR("broken protocol handler didn't escape double-quote.");
     }
@@ -591,17 +592,18 @@ nsIndexedToHTML::DoOnStartRequest(nsIReq
     if (!parentStr.IsEmpty()) {
         nsXPIDLString parentText;
         rv = mBundle->GetStringFromName("DirGoUp",
                                         getter_Copies(parentText));
         if (NS_FAILED(rv)) return rv;
 
         buffer.AppendLiteral("<p id=\"UI_goUp\"><a class=\"up\" href=\"");
 
-        nsAdoptingCString htmlParentStr(nsEscapeHTML(parentStr.get()));
+        nsCString htmlParentStr;
+        htmlParentStr.Adopt(nsEscapeHTML(parentStr.get()));
         buffer.Append(htmlParentStr);
         buffer.AppendLiteral("\">");
         AppendNonAsciiToNCR(parentText, buffer);
         buffer.AppendLiteral("</a></p>\n");
     }
 
     if (isSchemeFile) {
         nsXPIDLString showHiddenText;
@@ -721,17 +723,18 @@ nsIndexedToHTML::OnIndexAvailable(nsIReq
             break;
         case nsIDirIndex::TYPE_DIRECTORY:
             pushBuffer.Append('1');
             break;
         default:
             pushBuffer.Append('2');
             break;
     }
-    nsAdoptingCString escaped(nsEscapeHTML(loc));
+    nsCString escaped;
+    escaped.Adopt(nsEscapeHTML(loc));
     pushBuffer.Append(escaped);
 
     pushBuffer.AppendLiteral("\"><table class=\"ellipsis\"><tbody><tr><td><a class=\"");
     switch (type) {
         case nsIDirIndex::TYPE_DIRECTORY:
             pushBuffer.AppendLiteral("dir");
             break;
         case nsIDirIndex::TYPE_SYMLINK:
@@ -772,27 +775,29 @@ nsIndexedToHTML::OnIndexAvailable(nsIReq
         // that directory will be incorrect
         escFlags = esc_Forced | esc_AlwaysCopy | esc_FileBaseName | esc_Colon | esc_Directory;
     }
     NS_EscapeURL(loc.get(), loc.Length(), escFlags, locEscaped);
     // esc_Directory does not escape the semicolons, so if a filename
     // contains semicolons we need to manually escape them.
     // This replacement should be removed in bug #473280
     locEscaped.ReplaceSubstring(";", "%3b");
-    nsAdoptingCString htmlEscapedURL(nsEscapeHTML(locEscaped.get()));
+    nsCString htmlEscapedURL;
+    htmlEscapedURL.Adopt(nsEscapeHTML(locEscaped.get()));
     pushBuffer.Append(htmlEscapedURL);
 
     pushBuffer.AppendLiteral("\">");
 
     if (type == nsIDirIndex::TYPE_FILE || type == nsIDirIndex::TYPE_UNKNOWN) {
         pushBuffer.AppendLiteral("<img src=\"moz-icon://");
         int32_t lastDot = locEscaped.RFindChar('.');
         if (lastDot != kNotFound) {
             locEscaped.Cut(0, lastDot);
-            nsAdoptingCString htmlFileExt(nsEscapeHTML(locEscaped.get()));
+            nsCString htmlFileExt;
+            htmlFileExt.Adopt(nsEscapeHTML(locEscaped.get()));
             pushBuffer.Append(htmlFileExt);
         } else {
             pushBuffer.AppendLiteral("unknown");
         }
         pushBuffer.AppendLiteral("?size=16\" alt=\"");
 
         nsXPIDLString altText;
         rv = mBundle->GetStringFromName("DirFileLabel",
--- a/toolkit/components/extensions/WebExtensionPolicy.cpp
+++ b/toolkit/components/extensions/WebExtensionPolicy.cpp
@@ -47,25 +47,16 @@ static const char kBackgroundPageHTMLSta
 
 static const char kBackgroundPageHTMLScript[] = "\n\
     <script type=\"text/javascript\" src=\"%s\"></script>";
 
 static const char kBackgroundPageHTMLEnd[] = "\n\
   <body>\n\
 </html>";
 
-class EscapeHTML final : public nsAdoptingCString
-{
-public:
-  explicit EscapeHTML(const nsACString& str)
-    : nsAdoptingCString(nsEscapeHTML(str.BeginReading()))
-  {}
-};
-
-
 static inline ExtensionPolicyService&
 EPS()
 {
   return ExtensionPolicyService::GetSingleton();
 }
 
 static nsISubstitutingProtocolHandler*
 Proto()
@@ -253,17 +244,18 @@ WebExtensionPolicy::BackgroundPageHTML()
   if (mBackgroundScripts.IsNull()) {
     result.SetIsVoid(true);
     return result;
   }
 
   result.AppendLiteral(kBackgroundPageHTMLStart);
 
   for (auto& script : mBackgroundScripts.Value()) {
-    EscapeHTML escaped{NS_ConvertUTF16toUTF8(script)};
+    nsCString escaped;
+    escaped.Adopt(nsEscapeHTML(NS_ConvertUTF16toUTF8(script).get()));
 
     result.AppendPrintf(kBackgroundPageHTMLScript, escaped.get());
   }
 
   result.AppendLiteral(kBackgroundPageHTMLEnd);
   return result;
 }
 
--- a/widget/tests/TestChromeMargin.cpp
+++ b/widget/tests/TestChromeMargin.cpp
@@ -21,17 +21,16 @@
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
 class nsACString;
 class nsAString;
 class nsString;
 class nsCString;
-class nsAdoptingCString;
 class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nscore.h"
 #include "nsContentUtils.h"
 
 #ifndef MOZILLA_INTERNAL_API