Bug 1323935 - Entries API must use NS_NewLocalFile instead of NS_NewNativeLocalFile, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 18 Jan 2017 04:48:29 +0100
changeset 374784 7f091f9ab43a679d08c29b74fc47691d9d380ded
parent 374783 a9fe1bab102479c6cf8a157600f2b7699fad4910
child 374785 f930d9fbb4036a21045cbff90be5cc5a59958857
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1323935
milestone53.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 1323935 - Entries API must use NS_NewLocalFile instead of NS_NewNativeLocalFile, r=smaug
dom/events/DataTransferItem.cpp
dom/filesystem/CreateDirectoryTask.cpp
dom/filesystem/CreateFileTask.cpp
dom/filesystem/Directory.cpp
dom/filesystem/FileSystemBase.cpp
dom/filesystem/GetDirectoryListingTask.cpp
dom/filesystem/GetFileOrDirectoryTask.cpp
dom/filesystem/GetFilesHelper.cpp
dom/filesystem/GetFilesTask.cpp
dom/filesystem/RemoveTask.cpp
--- a/dom/events/DataTransferItem.cpp
+++ b/dom/events/DataTransferItem.cpp
@@ -314,18 +314,20 @@ DataTransferItem::GetAsEntry(nsIPrincipa
     nsAutoString fullpath;
     impl->GetMozFullPathInternal(fullpath, aRv);
     if (aRv.Failed()) {
       aRv.SuppressException();
       return nullptr;
     }
 
     nsCOMPtr<nsIFile> directoryFile;
-    nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(fullpath),
-                                        true, getter_AddRefs(directoryFile));
+    // fullPath is already in unicode, we don't have to use
+    // NS_NewNativeLocalFile.
+    nsresult rv = NS_NewLocalFile(fullpath, true,
+                                  getter_AddRefs(directoryFile));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return nullptr;
     }
 
     RefPtr<Directory> directory = Directory::Create(global, directoryFile);
     entry = new FileSystemDirectoryEntry(global, directory, nullptr, fs);
   } else {
     entry = new FileSystemFileEntry(global, file, nullptr, fs);
--- a/dom/filesystem/CreateDirectoryTask.cpp
+++ b/dom/filesystem/CreateDirectoryTask.cpp
@@ -93,19 +93,18 @@ void
 CreateDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                   ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
 
   const FileSystemDirectoryResponse& r =
     aValue.get_FileSystemDirectoryResponse();
 
-  aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(r.realPath()), true,
-                              getter_AddRefs(mTargetPath));
-  NS_WARNING_ASSERTION(!aRv.Failed(), "NS_NewNativeLocalFile failed");
+  aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
+  NS_WARNING_ASSERTION(!aRv.Failed(), "NS_NewLocalFile failed");
 }
 
 void
 CreateDirectoryTaskChild::HandlerCallback()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
   if (mFileSystem->IsShutdown()) {
     mPromise = nullptr;
@@ -144,18 +143,18 @@ CreateDirectoryTaskParent::Create(FileSy
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<CreateDirectoryTaskParent> task =
     new CreateDirectoryTaskParent(aFileSystem, aParam, aParent);
 
-  aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(aParam.realPath()), true,
-                              getter_AddRefs(task->mTargetPath));
+  aRv = NS_NewLocalFile(aParam.realPath(), true,
+                        getter_AddRefs(task->mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   return task.forget();
 }
 
 CreateDirectoryTaskParent::CreateDirectoryTaskParent(FileSystemBase* aFileSystem,
--- a/dom/filesystem/CreateFileTask.cpp
+++ b/dom/filesystem/CreateFileTask.cpp
@@ -135,18 +135,17 @@ CreateFileTaskChild::GetRequestParams(co
 void
 CreateFileTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                              ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
 
   const FileSystemFileResponse& r = aValue.get_FileSystemFileResponse();
 
-  NS_ConvertUTF16toUTF8 path(r.realPath());
-  aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(mTargetPath));
+  aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 }
 
 void
 CreateFileTaskChild::HandlerCallback()
 {
@@ -189,18 +188,18 @@ CreateFileTaskParent::Create(FileSystemB
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<CreateFileTaskParent> task =
     new CreateFileTaskParent(aFileSystem, aParam, aParent);
 
-  NS_ConvertUTF16toUTF8 path(aParam.realPath());
-  aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
+  aRv = NS_NewLocalFile(aParam.realPath(), true,
+                        getter_AddRefs(task->mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   task->mReplace = aParam.replace();
 
   const FileSystemFileDataValue& data = aParam.data();
 
--- a/dom/filesystem/Directory.cpp
+++ b/dom/filesystem/Directory.cpp
@@ -95,18 +95,18 @@ Directory::WebkitBlinkDirectoryPickerEna
 /* static */ already_AddRefed<Promise>
 Directory::GetRoot(FileSystemBase* aFileSystem, ErrorResult& aRv)
 {
   // Only exposed for DeviceStorage.
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aFileSystem);
 
   nsCOMPtr<nsIFile> path;
-  aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(aFileSystem->LocalOrDeviceStorageRootPath()),
-                              true, getter_AddRefs(path));
+  aRv = NS_NewLocalFile(aFileSystem->LocalOrDeviceStorageRootPath(),
+                        true, getter_AddRefs(path));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   RefPtr<GetFileOrDirectoryTaskChild> task =
     GetFileOrDirectoryTaskChild::Create(aFileSystem, path, true, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
@@ -117,18 +117,17 @@ Directory::GetRoot(FileSystemBase* aFile
 }
 
 /* static */ already_AddRefed<Directory>
 Directory::Constructor(const GlobalObject& aGlobal,
                        const nsAString& aRealPath,
                        ErrorResult& aRv)
 {
   nsCOMPtr<nsIFile> path;
-  aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(aRealPath),
-                              true, getter_AddRefs(path));
+  aRv = NS_NewLocalFile(aRealPath, true, getter_AddRefs(path));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   return Create(aGlobal.GetAsSupports(), path);
 }
 
 /* static */ already_AddRefed<Directory>
--- a/dom/filesystem/FileSystemBase.cpp
+++ b/dom/filesystem/FileSystemBase.cpp
@@ -83,18 +83,17 @@ FileSystemBase::GetRealPath(BlobImpl* aF
   nsAutoString filePath;
   ErrorResult rv;
   aFile->GetMozFullPathInternal(filePath, rv);
   if (NS_WARN_IF(rv.Failed())) {
     rv.SuppressException();
     return false;
   }
 
-  rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(filePath),
-                             true, aPath);
+  rv = NS_NewLocalFile(filePath, true, aPath);
   if (NS_WARN_IF(rv.Failed())) {
     rv.SuppressException();
     return false;
   }
 
   return true;
 }
 
@@ -129,18 +128,18 @@ FileSystemBase::GetDOMPath(nsIFile* aFil
                            ErrorResult& aRv) const
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aFile);
 
   aRetval.Truncate();
 
   nsCOMPtr<nsIFile> fileSystemPath;
-  aRv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(LocalOrDeviceStorageRootPath()),
-                              true, getter_AddRefs(fileSystemPath));
+  aRv = NS_NewLocalFile(LocalOrDeviceStorageRootPath(),
+                        true, getter_AddRefs(fileSystemPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   nsCOMPtr<nsIFile> path;
   aRv = aFile->Clone(getter_AddRefs(path));
   if (NS_WARN_IF(aRv.Failed())) {
     return;
--- a/dom/filesystem/GetDirectoryListingTask.cpp
+++ b/dom/filesystem/GetDirectoryListingTask.cpp
@@ -161,18 +161,18 @@ GetDirectoryListingTaskChild::HandlerCal
   if (!listing.SetLength(count, mozilla::fallible_t())) {
     mPromise->MaybeReject(NS_ERROR_OUT_OF_MEMORY);
     mPromise = nullptr;
     return;
   }
 
   for (unsigned i = 0; i < count; i++) {
     nsCOMPtr<nsIFile> path;
-    NS_ConvertUTF16toUTF8 fullPath(mTargetData[i].mPath);
-    nsresult rv = NS_NewNativeLocalFile(fullPath, true, getter_AddRefs(path));
+    nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, true,
+                                  getter_AddRefs(path));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       mPromise->MaybeReject(rv);
       mPromise = nullptr;
       return;
     }
 
 #ifdef DEBUG
     nsCOMPtr<nsIFile> rootPath;
@@ -241,18 +241,18 @@ GetDirectoryListingTaskParent::Create(Fi
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<GetDirectoryListingTaskParent> task =
     new GetDirectoryListingTaskParent(aFileSystem, aParam, aParent);
 
-  NS_ConvertUTF16toUTF8 path(aParam.realPath());
-  aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
+  aRv = NS_NewLocalFile(aParam.realPath(), true,
+                        getter_AddRefs(task->mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   return task.forget();
 }
 
 GetDirectoryListingTaskParent::GetDirectoryListingTaskParent(FileSystemBase* aFileSystem,
--- a/dom/filesystem/GetFileOrDirectoryTask.cpp
+++ b/dom/filesystem/GetFileOrDirectoryTask.cpp
@@ -95,30 +95,28 @@ void
 GetFileOrDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                      ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
   switch (aValue.type()) {
     case FileSystemResponseValue::TFileSystemFileResponse: {
       FileSystemFileResponse r = aValue;
 
-      NS_ConvertUTF16toUTF8 path(r.realPath());
-      aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(mTargetPath));
+      aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
       if (NS_WARN_IF(aRv.Failed())) {
         return;
       }
 
       mIsDirectory = false;
       break;
     }
     case FileSystemResponseValue::TFileSystemDirectoryResponse: {
       FileSystemDirectoryResponse r = aValue;
 
-      NS_ConvertUTF16toUTF8 path(r.realPath());
-      aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(mTargetPath));
+      aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
       if (NS_WARN_IF(aRv.Failed())) {
         return;
       }
 
       mIsDirectory = true;
       break;
     }
     default: {
@@ -178,18 +176,18 @@ GetFileOrDirectoryTaskParent::Create(Fil
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<GetFileOrDirectoryTaskParent> task =
     new GetFileOrDirectoryTaskParent(aFileSystem, aParam, aParent);
 
-  NS_ConvertUTF16toUTF8 path(aParam.realPath());
-  aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
+  aRv = NS_NewLocalFile(aParam.realPath(), true,
+                        getter_AddRefs(task->mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   return task.forget();
 }
 
 GetFileOrDirectoryTaskParent::GetFileOrDirectoryTaskParent(FileSystemBase* aFileSystem,
--- a/dom/filesystem/GetFilesHelper.cpp
+++ b/dom/filesystem/GetFilesHelper.cpp
@@ -266,18 +266,17 @@ GetFilesHelper::OperationCompleted()
 void
 GetFilesHelper::RunIO()
 {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!mDirectoryPath.IsEmpty());
   MOZ_ASSERT(!mListingCompleted);
 
   nsCOMPtr<nsIFile> file;
-  mErrorResult = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(mDirectoryPath), true,
-                                       getter_AddRefs(file));
+  mErrorResult = NS_NewLocalFile(mDirectoryPath, true, getter_AddRefs(file));
   if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
     return;
   }
 
   nsAutoString path;
   mErrorResult = file->GetLeafName(path);
   if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
     return;
@@ -301,18 +300,18 @@ GetFilesHelper::RunMainThread()
   if (NS_FAILED(mErrorResult)) {
     return;
   }
 
   // Create the sequence of Files.
   for (uint32_t i = 0; i < mTargetPathArray.Length(); ++i) {
     nsCOMPtr<nsIFile> file;
     mErrorResult =
-      NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(mTargetPathArray[i].mRealPath),
-                            true, getter_AddRefs(file));
+      NS_NewLocalFile(mTargetPathArray[i].mRealPath, true,
+                      getter_AddRefs(file));
     if (NS_WARN_IF(NS_FAILED(mErrorResult))) {
       mFiles.Clear();
       return;
     }
 
     RefPtr<File> domFile =
       File::CreateFromFile(mGlobal, file);
     MOZ_ASSERT(domFile);
--- a/dom/filesystem/GetFilesTask.cpp
+++ b/dom/filesystem/GetFilesTask.cpp
@@ -149,18 +149,18 @@ GetFilesTaskChild::HandlerCallback()
   if (!listing.SetLength(count, mozilla::fallible_t())) {
     mPromise->MaybeReject(NS_ERROR_OUT_OF_MEMORY);
     mPromise = nullptr;
     return;
   }
 
   for (unsigned i = 0; i < count; i++) {
     nsCOMPtr<nsIFile> path;
-    NS_ConvertUTF16toUTF8 fullPath(mTargetData[i].mRealPath);
-    nsresult rv = NS_NewNativeLocalFile(fullPath, true, getter_AddRefs(path));
+    nsresult rv = NS_NewLocalFile(mTargetData[i].mRealPath, true,
+                                  getter_AddRefs(path));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       mPromise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
       mPromise = nullptr;
       return;
     }
 
 #ifdef DEBUG
     nsCOMPtr<nsIFile> rootPath;
@@ -205,18 +205,18 @@ GetFilesTaskParent::Create(FileSystemBas
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<GetFilesTaskParent> task =
     new GetFilesTaskParent(aFileSystem, aParam, aParent);
 
-  NS_ConvertUTF16toUTF8 path(aParam.realPath());
-  aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
+  aRv = NS_NewLocalFile(aParam.realPath(), true,
+                        getter_AddRefs(task->mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   return task.forget();
 }
 
 GetFilesTaskParent::GetFilesTaskParent(FileSystemBase* aFileSystem,
--- a/dom/filesystem/RemoveTask.cpp
+++ b/dom/filesystem/RemoveTask.cpp
@@ -157,27 +157,26 @@ RemoveTaskParent::Create(FileSystemBase*
 {
   MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<RemoveTaskParent> task =
     new RemoveTaskParent(aFileSystem, aParam, aParent);
 
-  NS_ConvertUTF16toUTF8 directoryPath(aParam.directory());
-  aRv = NS_NewNativeLocalFile(directoryPath, true,
-                              getter_AddRefs(task->mDirPath));
+  aRv = NS_NewLocalFile(aParam.directory(), true,
+                        getter_AddRefs(task->mDirPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   task->mRecursive = aParam.recursive();
 
-  NS_ConvertUTF16toUTF8 path(aParam.targetDirectory());
-  aRv = NS_NewNativeLocalFile(path, true, getter_AddRefs(task->mTargetPath));
+  aRv = NS_NewLocalFile(aParam.targetDirectory(), true,
+                        getter_AddRefs(task->mTargetPath));
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   if (!FileSystemUtils::IsDescendantPath(task->mDirPath, task->mTargetPath)) {
     aRv.Throw(NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR);
     return nullptr;
   }