Bug 1299500 - Get rid of DeviceStorage API - part 9 - Directory::GetRoot, r=ehsan, a=jcristau
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Mar 2017 20:15:45 +0100
changeset 355511 d63f3b14e5718b62c0adad2eab81b785250f3d4a
parent 355510 e95a26cf7a42f58d623f3de590aed900808b666c
child 355512 08f2bc167ae82a6f86e427283d8b972ba794b846
push id6987
push userryanvm@gmail.com
push dateWed, 29 Mar 2017 15:48:26 +0000
treeherdermozilla-esr52@84b774afcf41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, jcristau
bugs1299500
milestone52.0.2
Bug 1299500 - Get rid of DeviceStorage API - part 9 - Directory::GetRoot, r=ehsan, a=jcristau
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
@@ -3464,17 +3464,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"
@@ -63,40 +62,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
@@ -155,17 +155,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);