Bug 1299500 - Get rid of DeviceStorage API - part 9 - Directory::GetRoot, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Mar 2017 20:15:45 +0100
changeset 346583 3364716e5765cfe44b16cb1d25c5a9ed43b8b45f
parent 346582 f4c12243de1898567212361d896f5412dee1b089
child 346584 6d0ea58121800a09bec9acb208649a38695bec7d
push id87844
push useramarchesini@mozilla.com
push dateWed, 08 Mar 2017 19:31:23 +0000
treeherdermozilla-inbound@c539b2e9f9c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1299500
milestone55.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 1299500 - Get rid of DeviceStorage API - part 9 - Directory::GetRoot, r=ehsan
dom/devicestorage/nsDeviceStorage.cpp
dom/filesystem/Directory.cpp
dom/filesystem/Directory.h
dom/filesystem/GetFileOrDirectoryTask.cpp
dom/filesystem/GetFileOrDirectoryTask.h
dom/filesystem/PFileSystemParams.ipdlh
dom/filesystem/PFileSystemRequest.ipdl
dom/filesystem/compat/CallbackRunnables.cpp
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -3466,17 +3466,17 @@ nsDOMDeviceStorage::LowDiskSpace()
 
 already_AddRefed<Promise>
 nsDOMDeviceStorage::GetRoot(ErrorResult& aRv)
 {
   if (!mFileSystem) {
     mFileSystem = new DeviceStorageFileSystem(mStorageType, mStorageName);
     mFileSystem->Init(this);
   }
-  return mozilla::dom::Directory::GetRoot(mFileSystem, aRv);
+  return nullptr;
 }
 
 void
 nsDOMDeviceStorage::GetStorageName(nsAString& aStorageName)
 {
   aStorageName = mStorageName;
 }
 
--- a/dom/filesystem/Directory.cpp
+++ b/dom/filesystem/Directory.cpp
@@ -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/. */
 
 #include "mozilla/dom/Directory.h"
 
 #include "FileSystemPermissionRequest.h"
 #include "GetDirectoryListingTask.h"
-#include "GetFileOrDirectoryTask.h"
 #include "GetFilesTask.h"
 #include "WorkerPrivate.h"
 
 #include "nsCharSeparatedTokenizer.h"
 #include "nsString.h"
 #include "mozilla/dom/DirectoryBinding.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemUtils.h"
@@ -62,40 +61,16 @@ Directory::WebkitBlinkDirectoryPickerEna
     workers::GetCurrentThreadWorkerPrivate();
   if (!workerPrivate) {
     return false;
   }
 
   return workerPrivate->WebkitBlinkDirectoryPickerEnabled();
 }
 
-/* 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_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;
-  }
-
-  FileSystemPermissionRequest::RequestForTask(task);
-  return task->GetPromise();
-}
-
 /* static */ already_AddRefed<Directory>
 Directory::Constructor(const GlobalObject& aGlobal,
                        const nsAString& aRealPath,
                        ErrorResult& aRv)
 {
   nsCOMPtr<nsIFile> path;
   aRv = NS_NewLocalFile(aRealPath, true, getter_AddRefs(path));
   if (NS_WARN_IF(aRv.Failed())) {
--- a/dom/filesystem/Directory.h
+++ b/dom/filesystem/Directory.h
@@ -27,19 +27,16 @@ class Directory final
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
 
   static bool
   WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
 
-  static already_AddRefed<Promise>
-  GetRoot(FileSystemBase* aFileSystem, ErrorResult& aRv);
-
   static already_AddRefed<Directory>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aRealPath,
               ErrorResult& aRv);
 
   static already_AddRefed<Directory>
   Create(nsISupports* aParent, nsIFile* aDirectory,
          FileSystemBase* aFileSystem = 0);
--- a/dom/filesystem/GetFileOrDirectoryTask.cpp
+++ b/dom/filesystem/GetFileOrDirectoryTask.cpp
@@ -22,24 +22,23 @@ namespace dom {
 
 /**
  * GetFileOrDirectoryTaskChild
  */
 
 /* static */ already_AddRefed<GetFileOrDirectoryTaskChild>
 GetFileOrDirectoryTaskChild::Create(FileSystemBase* aFileSystem,
                                     nsIFile* aTargetPath,
-                                    bool aDirectoryOnly,
                                     ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
   MOZ_ASSERT(aFileSystem);
 
   RefPtr<GetFileOrDirectoryTaskChild> task =
-    new GetFileOrDirectoryTaskChild(aFileSystem, aTargetPath, aDirectoryOnly);
+    new GetFileOrDirectoryTaskChild(aFileSystem, aTargetPath);
 
   // aTargetPath can be null. In this case SetError will be called.
 
   nsCOMPtr<nsIGlobalObject> globalObject =
     do_QueryInterface(aFileSystem->GetParentObject());
   if (NS_WARN_IF(!globalObject)) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
@@ -49,18 +48,17 @@ GetFileOrDirectoryTaskChild::Create(File
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   return task.forget();
 }
 
 GetFileOrDirectoryTaskChild::GetFileOrDirectoryTaskChild(FileSystemBase* aFileSystem,
-                                                         nsIFile* aTargetPath,
-                                                         bool aDirectoryOnly)
+                                                         nsIFile* aTargetPath)
   : FileSystemTaskChildBase(aFileSystem)
   , mTargetPath(aTargetPath)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
   MOZ_ASSERT(aFileSystem);
 }
 
 GetFileOrDirectoryTaskChild::~GetFileOrDirectoryTaskChild()
--- a/dom/filesystem/GetFileOrDirectoryTask.h
+++ b/dom/filesystem/GetFileOrDirectoryTask.h
@@ -18,17 +18,16 @@ class BlobImpl;
 class FileSystemGetFileOrDirectoryParams;
 
 class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase
 {
 public:
   static already_AddRefed<GetFileOrDirectoryTaskChild>
   Create(FileSystemBase* aFileSystem,
          nsIFile* aTargetPath,
-         bool aDirectoryOnly,
          ErrorResult& aRv);
 
   virtual
   ~GetFileOrDirectoryTaskChild();
 
   already_AddRefed<Promise>
   GetPromise();
 
@@ -42,20 +41,18 @@ protected:
 
   virtual void
   SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                           ErrorResult& aRv) override;
   virtual void
   HandlerCallback() override;
 
 private:
-  // If aDirectoryOnly is set, we should ensure that the target is a directory.
   GetFileOrDirectoryTaskChild(FileSystemBase* aFileSystem,
-                              nsIFile* aTargetPath,
-                              bool aDirectoryOnly);
+                              nsIFile* aTargetPath);
 
   RefPtr<Promise> mPromise;
   nsCOMPtr<nsIFile> mTargetPath;
 
   RefPtr<File> mResultFile;
   RefPtr<Directory> mResultDirectory;
 };
 
--- a/dom/filesystem/PFileSystemParams.ipdlh
+++ b/dom/filesystem/PFileSystemParams.ipdlh
@@ -2,22 +2,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 protocol PBlob;
 
 namespace mozilla {
 namespace dom {
 
-union FileSystemFileDataValue
-{
-  uint8_t[];
-  PBlob;
-};
-
 struct FileSystemGetDirectoryListingParams
 {
   nsString filesystem;
   nsString realPath;
   nsString domPath;
 
   // 'filters' could be an array rather than a semicolon separated string
   // (we'd then use InfallibleTArray<nsString> internally), but that is
--- a/dom/filesystem/PFileSystemRequest.ipdl
+++ b/dom/filesystem/PFileSystemRequest.ipdl
@@ -47,24 +47,18 @@ struct FileSystemFilesResponse
   FileSystemFileResponse[] data;
 };
 
 struct FileSystemErrorResponse
 {
   nsresult error;
 };
 
-struct FileSystemBooleanResponse
-{
-  bool success;
-};
-
 union FileSystemResponseValue
 {
-  FileSystemBooleanResponse;
   FileSystemDirectoryResponse;
   FileSystemDirectoryListingResponse;
   FileSystemFileResponse;
   FileSystemFilesResponse;
   FileSystemErrorResponse;
 };
 
 protocol PFileSystemRequest
--- a/dom/filesystem/compat/CallbackRunnables.cpp
+++ b/dom/filesystem/compat/CallbackRunnables.cpp
@@ -150,17 +150,17 @@ GetEntryHelper::Run()
   RefPtr<FileSystemBase> fs = mDirectory->GetFileSystem(rv);
   if (NS_WARN_IF(rv.Failed())) {
     rv.SuppressException();
     Error(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   RefPtr<GetFileOrDirectoryTaskChild> task =
-    GetFileOrDirectoryTaskChild::Create(fs, realPath, false, rv);
+    GetFileOrDirectoryTaskChild::Create(fs, realPath, rv);
   if (NS_WARN_IF(rv.Failed())) {
     rv.SuppressException();
     Error(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   task->SetError(error);
   FileSystemPermissionRequest::RequestForTask(task);