Bug 1333631 - Fix misuse of nsIFile::GetNativeTarget in dom/filesystem. r=baku draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 27 Jan 2017 00:48:52 +0900
changeset 470085 b0c0bc340d206ce967098082e2a341bd2a475b39
parent 469974 c8102da699dba43d85eb80b70956e80c6793feca
child 544392 43571b94819e8034f2780eba1040abbd4c82046c
push id43936
push userVYV03354@nifty.ne.jp
push dateFri, 03 Feb 2017 07:53:58 +0000
reviewersbaku
bugs1333631
milestone54.0a1
Bug 1333631 - Fix misuse of nsIFile::GetNativeTarget in dom/filesystem. r=baku MozReview-Commit-ID: 9VpLg1iNFxs
dom/filesystem/GetFilesHelper.cpp
dom/filesystem/GetFilesHelper.h
--- a/dom/filesystem/GetFilesHelper.cpp
+++ b/dom/filesystem/GetFilesHelper.cpp
@@ -424,28 +424,24 @@ GetFilesHelperBase::AddExploredDirectory
 #endif
 
   bool isLink;
   rv = aDir->IsSymlink(&isLink);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  nsAutoCString path;
-
+  nsAutoString path;
   if (!isLink) {
-    nsAutoString path16;
-    rv = aDir->GetPath(path16);
+    rv = aDir->GetPath(path);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
-
-    path = NS_ConvertUTF16toUTF8(path16);
   } else {
-    rv = aDir->GetNativeTarget(path);
+    rv = aDir->GetTarget(path);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   mExploredDirectories.PutEntry(path);
   return NS_OK;
 }
@@ -458,18 +454,18 @@ GetFilesHelperBase::ShouldFollowSymLink(
   if (NS_WARN_IF(NS_FAILED(aDir->IsSymlink(&isLink)) ||
                  NS_FAILED(aDir->IsDirectory(&isDir)))) {
     return false;
   }
 
   MOZ_ASSERT(isLink && isDir, "Why are we here?");
 #endif
 
-  nsAutoCString targetPath;
-  if (NS_WARN_IF(NS_FAILED(aDir->GetNativeTarget(targetPath)))) {
+  nsAutoString targetPath;
+  if (NS_WARN_IF(NS_FAILED(aDir->GetTarget(targetPath)))) {
     return false;
   }
 
   return !mExploredDirectories.Contains(targetPath);
 }
 
 void
 GetFilesHelper::ResolveOrRejectPromise(Promise* aPromise)
--- a/dom/filesystem/GetFilesHelper.h
+++ b/dom/filesystem/GetFilesHelper.h
@@ -60,17 +60,17 @@ protected:
 
   bool
   ShouldFollowSymLink(nsIFile* aDirectory);
 
   bool mRecursiveFlag;
 
   // We populate this array in the I/O thread with the BlobImpl.
   FallibleTArray<RefPtr<BlobImpl>> mTargetBlobImplArray;
-  nsTHashtable<nsCStringHashKey> mExploredDirectories;
+  nsTHashtable<nsStringHashKey> mExploredDirectories;
 };
 
 // Retrieving the list of files can be very time/IO consuming. We use this
 // helper class to do it just once.
 class GetFilesHelper : public Runnable
                      , public GetFilesHelperBase
 {
   friend class GetFilesHelperParent;