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"
20 class FileSystemGetFilesParams
;
22 class GetFilesTaskChild final
: public FileSystemTaskChildBase
{
24 static already_AddRefed
<GetFilesTaskChild
> Create(FileSystemBase
* aFileSystem
,
25 Directory
* aDirectory
,
30 virtual ~GetFilesTaskChild();
32 already_AddRefed
<Promise
> GetPromise();
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
,
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
;
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
{
60 static already_AddRefed
<GetFilesTaskParent
> Create(
61 FileSystemBase
* aFileSystem
, const FileSystemGetFilesParams
& aParam
,
62 FileSystemRequestParent
* aParent
, ErrorResult
& aRv
);
64 nsresult
GetTargetPath(nsAString
& aPath
) const override
;
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
;
81 } // namespace mozilla
83 #endif // mozilla_dom_GetFilesTask_h