Skip to content

Commit

Permalink
Bug 1299500 - Get rid of DeviceStorage API - part 9 - Directory::GetR…
Browse files Browse the repository at this point in the history
…oot, r=ehsan
  • Loading branch information
bakulf committed Mar 8, 2017
1 parent 13baecd commit 88f21fa
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 50 deletions.
2 changes: 1 addition & 1 deletion dom/devicestorage/nsDeviceStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3471,7 +3471,7 @@ nsDOMDeviceStorage::GetRoot(ErrorResult& aRv)
mFileSystem = new DeviceStorageFileSystem(mStorageType, mStorageName);
mFileSystem->Init(this);
}
return mozilla::dom::Directory::GetRoot(mFileSystem, aRv);
return nullptr;
}

void
Expand Down
25 changes: 0 additions & 25 deletions dom/filesystem/Directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "FileSystemPermissionRequest.h"
#include "GetDirectoryListingTask.h"
#include "GetFileOrDirectoryTask.h"
#include "GetFilesTask.h"
#include "WorkerPrivate.h"

Expand Down Expand Up @@ -67,30 +66,6 @@ Directory::WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj)
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,
Expand Down
3 changes: 0 additions & 3 deletions dom/filesystem/Directory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class Directory final
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,
Expand Down
6 changes: 2 additions & 4 deletions dom/filesystem/GetFileOrDirectoryTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ namespace dom {
/* 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.

Expand All @@ -54,8 +53,7 @@ GetFileOrDirectoryTaskChild::Create(FileSystemBase* aFileSystem,
}

GetFileOrDirectoryTaskChild::GetFileOrDirectoryTaskChild(FileSystemBase* aFileSystem,
nsIFile* aTargetPath,
bool aDirectoryOnly)
nsIFile* aTargetPath)
: FileSystemTaskChildBase(aFileSystem)
, mTargetPath(aTargetPath)
{
Expand Down
5 changes: 1 addition & 4 deletions dom/filesystem/GetFileOrDirectoryTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase
static already_AddRefed<GetFileOrDirectoryTaskChild>
Create(FileSystemBase* aFileSystem,
nsIFile* aTargetPath,
bool aDirectoryOnly,
ErrorResult& aRv);

virtual
Expand All @@ -47,10 +46,8 @@ class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase
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;
Expand Down
6 changes: 0 additions & 6 deletions dom/filesystem/PFileSystemParams.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ include protocol PBlob;
namespace mozilla {
namespace dom {

union FileSystemFileDataValue
{
uint8_t[];
PBlob;
};

struct FileSystemGetDirectoryListingParams
{
nsString filesystem;
Expand Down
6 changes: 0 additions & 6 deletions dom/filesystem/PFileSystemRequest.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,8 @@ struct FileSystemErrorResponse
nsresult error;
};

struct FileSystemBooleanResponse
{
bool success;
};

union FileSystemResponseValue
{
FileSystemBooleanResponse;
FileSystemDirectoryResponse;
FileSystemDirectoryListingResponse;
FileSystemFileResponse;
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/compat/CallbackRunnables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ GetEntryHelper::Run()
}

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);
Expand Down

0 comments on commit 88f21fa

Please sign in to comment.