Bug 1488628 - Change nsIDirIndex's wstring/string attributes to AString/ACString. r=valentin
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 05 Sep 2018 11:31:28 +1000
changeset 435166 067c003d030208d94cb77bf615e136c4fb2fd9fd
parent 435165 a1d9229766f4b95abd7f0e6cec12b83e22f8b845
child 435167 9bcffbb1684cebe93d8b631cad71c86887ce3992
push id34598
push userdluca@mozilla.com
push dateFri, 07 Sep 2018 16:36:02 +0000
treeherdermozilla-central@b8905df54d01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1488628
milestone64.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 1488628 - Change nsIDirIndex's wstring/string attributes to AString/ACString. r=valentin
netwerk/streamconv/converters/nsDirIndex.cpp
netwerk/streamconv/converters/nsDirIndexParser.cpp
netwerk/streamconv/converters/nsIndexedToHTML.cpp
netwerk/streamconv/nsIDirIndex.idl
--- a/netwerk/streamconv/converters/nsDirIndex.cpp
+++ b/netwerk/streamconv/converters/nsDirIndex.cpp
@@ -26,69 +26,54 @@ nsDirIndex::GetType(uint32_t* aType)
 NS_IMETHODIMP
 nsDirIndex::SetType(uint32_t aType)
 {
   mType = aType;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDirIndex::GetContentType(char* *aContentType)
+nsDirIndex::GetContentType(nsACString& aContentType)
 {
-  NS_ENSURE_ARG_POINTER(aContentType);
-
-  *aContentType = ToNewCString(mContentType);
-  if (!*aContentType)
-    return NS_ERROR_OUT_OF_MEMORY;
-
+  aContentType = mContentType;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDirIndex::SetContentType(const char* aContentType)
+nsDirIndex::SetContentType(const nsACString& aContentType)
 {
   mContentType = aContentType;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDirIndex::GetLocation(char* *aLocation)
+nsDirIndex::GetLocation(nsACString& aLocation)
 {
-  NS_ENSURE_ARG_POINTER(aLocation);
-
-  *aLocation = ToNewCString(mLocation);
-  if (!*aLocation)
-    return NS_ERROR_OUT_OF_MEMORY;
-
+  aLocation = mLocation;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDirIndex::SetLocation(const char* aLocation)
+nsDirIndex::SetLocation(const nsACString& aLocation)
 {
   mLocation = aLocation;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDirIndex::GetDescription(char16_t* *aDescription)
+nsDirIndex::GetDescription(nsAString& aDescription)
 {
-  NS_ENSURE_ARG_POINTER(aDescription);
-
-  *aDescription = ToNewUnicode(mDescription);
-  if (!*aDescription)
-    return NS_ERROR_OUT_OF_MEMORY;
-
+  aDescription = mDescription;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDirIndex::SetDescription(const char16_t* aDescription)
+nsDirIndex::SetDescription(const nsAString& aDescription)
 {
-  mDescription.Assign(aDescription);
+  mDescription = aDescription;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDirIndex::GetSize(int64_t* aSize)
 {
   NS_ENSURE_ARG_POINTER(aSize);
 
--- a/netwerk/streamconv/converters/nsDirIndexParser.cpp
+++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp
@@ -241,41 +241,41 @@ nsDirIndexParser::ParseData(nsIDirIndex 
 
       nsAutoString entryuri;
 
       if (gTextToSubURI) {
         nsAutoString result;
         if (NS_SUCCEEDED(rv = gTextToSubURI->UnEscapeAndConvert(
                            mEncoding, filename, result))) {
           if (!result.IsEmpty()) {
-            aIdx->SetLocation(filename.get());
+            aIdx->SetLocation(filename);
             if (!mHasDescription)
-              aIdx->SetDescription(result.get());
+              aIdx->SetDescription(result);
             success = true;
           }
         } else {
           NS_WARNING("UnEscapeAndConvert error");
         }
       }
 
       if (!success) {
         // if unsuccessfully at charset conversion, then
         // just fallback to unescape'ing in-place
         // XXX - this shouldn't be using UTF8, should it?
         // when can we fail to get the service, anyway? - bbaetz
-        aIdx->SetLocation(filename.get());
+        aIdx->SetLocation(filename);
         if (!mHasDescription) {
-          aIdx->SetDescription(NS_ConvertUTF8toUTF16(value).get());
+          aIdx->SetDescription(NS_ConvertUTF8toUTF16(value));
         }
       }
     }
       break;
     case FIELD_DESCRIPTION:
       nsUnescape(value);
-      aIdx->SetDescription(NS_ConvertUTF8toUTF16(value).get());
+      aIdx->SetDescription(NS_ConvertUTF8toUTF16(value));
       break;
     case FIELD_CONTENTLENGTH:
       {
         int64_t len;
         int32_t status = PR_sscanf(value, "%lld", &len);
         if (status == 1)
           aIdx->SetSize(len);
         else
@@ -287,17 +287,17 @@ nsDirIndexParser::ParseData(nsIDirIndex 
         PRTime tm;
         nsUnescape(value);
         if (PR_ParseTimeString(value, false, &tm) == PR_SUCCESS) {
           aIdx->SetLastModified(tm);
         }
       }
       break;
     case FIELD_CONTENTTYPE:
-      aIdx->SetContentType(value);
+      aIdx->SetContentType(nsDependentCString(value));
       break;
     case FIELD_FILETYPE:
       // unescape in-place
       nsUnescape(value);
       if (!nsCRT::strcasecmp(value, "directory")) {
         aIdx->SetType(nsIDirIndex::TYPE_DIRECTORY);
       } else if (!nsCRT::strcasecmp(value, "file")) {
         aIdx->SetType(nsIDirIndex::TYPE_FILE);
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -682,17 +682,17 @@ nsIndexedToHTML::OnIndexAvailable(nsIReq
         return NS_ERROR_NULL_POINTER;
 
     nsCString pushBuffer;
     pushBuffer.AppendLiteral("<tr");
 
     // We don't know the file's character set yet, so retrieve the raw bytes
     // which will be decoded by the HTML parser.
     nsCString loc;
-    aIndex->GetLocation(getter_Copies(loc));
+    aIndex->GetLocation(loc);
 
     // Adjust the length in case unescaping shortened the string.
     loc.Truncate(nsUnescapeCount(loc.BeginWriting()));
 
     if (loc.IsEmpty()) {
         return NS_ERROR_ILLEGAL_VALUE;
     }
     if (loc.First() == char16_t('.'))
--- a/netwerk/streamconv/nsIDirIndex.idl
+++ b/netwerk/streamconv/nsIDirIndex.idl
@@ -36,31 +36,31 @@ interface nsIDirIndex : nsISupports
      * The type of the entry - one of the constants above
      */
     attribute unsigned long type;
 
     /**
      * The content type - may be null if it is unknown.
      * Unspecified for directories
      */
-    attribute string contentType;
+    attribute ACString contentType;
 
     /**
      * The fully qualified filename, expressed as a uri
      *
      * This is encoded with the encoding specified in
      * the nsIDirIndexParser, and is also escaped.
      */
-    attribute string location;
+    attribute ACString location;
 
     /**
      * A description for the filename, which should be
      * displayed by a viewer
      */
-    attribute wstring description;
+    attribute AString description;
 
     /**
      * File size, with -1 meaning "unknown"
      */
     attribute long long size;
     
     /**
      * Last-modified time in seconds-since-epoch.