2016-04-13 14:15:56 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_GetFilesTask_h
|
|
|
|
#define mozilla_dom_GetFilesTask_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/Directory.h"
|
|
|
|
#include "mozilla/dom/FileSystemTaskBase.h"
|
2016-07-23 11:35:06 +03:00
|
|
|
#include "mozilla/dom/GetFilesHelper.h"
|
2016-04-13 14:15:56 +03:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class BlobImpl;
|
2017-03-08 22:15:44 +03:00
|
|
|
class FileSystemGetFilesParams;
|
2016-04-13 14:15:56 +03:00
|
|
|
|
|
|
|
class GetFilesTaskChild final : public FileSystemTaskChildBase {
|
|
|
|
public:
|
|
|
|
static already_AddRefed<GetFilesTaskChild> Create(FileSystemBase* aFileSystem,
|
2016-05-13 14:11:38 +03:00
|
|
|
Directory* aDirectory,
|
2016-04-13 14:15:56 +03:00
|
|
|
nsIFile* aTargetPath,
|
|
|
|
bool aRecursiveFlag,
|
|
|
|
ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-04-13 14:15:56 +03:00
|
|
|
virtual ~GetFilesTaskChild();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-04-13 14:15:56 +03:00
|
|
|
already_AddRefed<Promise> GetPromise();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-04-13 14:15:56 +03:00
|
|
|
private:
|
|
|
|
// If aDirectoryOnly is set, we should ensure that the target is a directory.
|
2017-04-05 10:47:56 +03:00
|
|
|
GetFilesTaskChild(nsIGlobalObject* aGlobalObject, FileSystemBase* aFileSystem,
|
2016-05-13 14:11:38 +03:00
|
|
|
Directory* aDirectory, nsIFile* aTargetPath,
|
2016-04-13 14:15:56 +03:00
|
|
|
bool aRecursiveFlag);
|
|
|
|
|
|
|
|
virtual FileSystemParams GetRequestParams(const nsString& aSerializedDOMPath,
|
|
|
|
ErrorResult& aRv) const override;
|
|
|
|
|
|
|
|
virtual void SetSuccessRequestResult(const FileSystemResponseValue& aValue,
|
|
|
|
ErrorResult& aRv) override;
|
|
|
|
|
|
|
|
virtual void HandlerCallback() override;
|
|
|
|
|
|
|
|
RefPtr<Promise> mPromise;
|
2016-05-13 14:11:38 +03:00
|
|
|
RefPtr<Directory> mDirectory;
|
2016-04-13 14:15:56 +03:00
|
|
|
nsCOMPtr<nsIFile> mTargetPath;
|
|
|
|
bool mRecursiveFlag;
|
|
|
|
|
2016-05-13 14:11:38 +03:00
|
|
|
// We store the fullpath and the dom path of Files.
|
2017-02-01 09:33:18 +03:00
|
|
|
FallibleTArray<RefPtr<File>> mTargetData;
|
2016-04-13 14:15:56 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class GetFilesTaskParent final : public FileSystemTaskParentBase,
|
2016-07-23 11:35:06 +03:00
|
|
|
public GetFilesHelperBase {
|
2016-04-13 14:15:56 +03:00
|
|
|
public:
|
|
|
|
static already_AddRefed<GetFilesTaskParent> Create(
|
|
|
|
FileSystemBase* aFileSystem, const FileSystemGetFilesParams& aParam,
|
|
|
|
FileSystemRequestParent* aParent, ErrorResult& aRv);
|
|
|
|
|
2017-03-16 10:53:49 +03:00
|
|
|
nsresult GetTargetPath(nsAString& aPath) const override;
|
|
|
|
|
2016-04-13 14:15:56 +03:00
|
|
|
private:
|
|
|
|
GetFilesTaskParent(FileSystemBase* aFileSystem,
|
|
|
|
const FileSystemGetFilesParams& aParam,
|
|
|
|
FileSystemRequestParent* aParent);
|
|
|
|
|
|
|
|
virtual FileSystemResponseValue GetSuccessRequestResult(
|
|
|
|
ErrorResult& aRv) const override;
|
|
|
|
|
|
|
|
virtual nsresult IOWork() override;
|
|
|
|
|
2016-05-13 14:11:38 +03:00
|
|
|
nsString mDirectoryDOMPath;
|
2016-04-13 14:15:56 +03:00
|
|
|
nsCOMPtr<nsIFile> mTargetPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_GetFilesTask_h
|