Bug 1824753 [wpt PR 39216] - [FLEDGE] Add WPT test that FLEDGE is not allowed in...
[gecko.git] / dom / filesystem / GetFilesTask.h
blob6f6f15e8796aab489b98a18ebd1e862228948f85
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_GetFilesTask_h
8 #define mozilla_dom_GetFilesTask_h
10 #include "mozilla/dom/Directory.h"
11 #include "mozilla/dom/FileSystemTaskBase.h"
12 #include "mozilla/dom/GetFilesHelper.h"
14 namespace mozilla {
15 class ErrorResult;
17 namespace dom {
19 class BlobImpl;
20 class FileSystemGetFilesParams;
22 class GetFilesTaskChild final : public FileSystemTaskChildBase {
23 public:
24 static already_AddRefed<GetFilesTaskChild> Create(FileSystemBase* aFileSystem,
25 Directory* aDirectory,
26 nsIFile* aTargetPath,
27 bool aRecursiveFlag,
28 ErrorResult& aRv);
30 virtual ~GetFilesTaskChild();
32 already_AddRefed<Promise> GetPromise();
34 private:
35 // If aDirectoryOnly is set, we should ensure that the target is a directory.
36 GetFilesTaskChild(nsIGlobalObject* aGlobalObject, FileSystemBase* aFileSystem,
37 Directory* aDirectory, nsIFile* aTargetPath,
38 bool aRecursiveFlag);
40 virtual FileSystemParams GetRequestParams(const nsString& aSerializedDOMPath,
41 ErrorResult& aRv) const override;
43 virtual void SetSuccessRequestResult(const FileSystemResponseValue& aValue,
44 ErrorResult& aRv) override;
46 virtual void HandlerCallback() override;
48 RefPtr<Promise> mPromise;
49 RefPtr<Directory> mDirectory;
50 nsCOMPtr<nsIFile> mTargetPath;
51 bool mRecursiveFlag;
53 // We store the fullpath and the dom path of Files.
54 FallibleTArray<RefPtr<File>> mTargetData;
57 class GetFilesTaskParent final : public FileSystemTaskParentBase,
58 public GetFilesHelperBase {
59 public:
60 static already_AddRefed<GetFilesTaskParent> Create(
61 FileSystemBase* aFileSystem, const FileSystemGetFilesParams& aParam,
62 FileSystemRequestParent* aParent, ErrorResult& aRv);
64 nsresult GetTargetPath(nsAString& aPath) const override;
66 private:
67 GetFilesTaskParent(FileSystemBase* aFileSystem,
68 const FileSystemGetFilesParams& aParam,
69 FileSystemRequestParent* aParent);
71 virtual FileSystemResponseValue GetSuccessRequestResult(
72 ErrorResult& aRv) const override;
74 virtual nsresult IOWork() override;
76 nsString mDirectoryDOMPath;
77 nsCOMPtr<nsIFile> mTargetPath;
80 } // namespace dom
81 } // namespace mozilla
83 #endif // mozilla_dom_GetFilesTask_h