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_GetDirectoryListing_h
8 #define mozilla_dom_GetDirectoryListing_h
10 #include "mozilla/dom/Directory.h"
11 #include "mozilla/dom/FileSystemTaskBase.h"
12 #include "mozilla/ErrorResult.h"
18 class FileSystemGetDirectoryListingParams
;
19 class OwningFileOrDirectory
;
21 class GetDirectoryListingTaskChild final
: public FileSystemTaskChildBase
{
23 static already_AddRefed
<GetDirectoryListingTaskChild
> Create(
24 FileSystemBase
* aFileSystem
, Directory
* aDirectory
, nsIFile
* aTargetPath
,
25 const nsAString
& aFilters
, ErrorResult
& aRv
);
27 virtual ~GetDirectoryListingTaskChild();
29 already_AddRefed
<Promise
> GetPromise();
32 // If aDirectoryOnly is set, we should ensure that the target is a directory.
33 GetDirectoryListingTaskChild(nsIGlobalObject
* aGlobalObject
,
34 FileSystemBase
* aFileSystem
,
35 Directory
* aDirectory
, nsIFile
* aTargetPath
,
36 const nsAString
& aFilters
);
38 virtual FileSystemParams
GetRequestParams(const nsString
& aSerializedDOMPath
,
39 ErrorResult
& aRv
) const override
;
41 virtual void SetSuccessRequestResult(const FileSystemResponseValue
& aValue
,
42 ErrorResult
& aRv
) override
;
44 virtual void HandlerCallback() override
;
46 RefPtr
<Promise
> mPromise
;
47 RefPtr
<Directory
> mDirectory
;
48 nsCOMPtr
<nsIFile
> mTargetPath
;
51 FallibleTArray
<OwningFileOrDirectory
> mTargetData
;
54 class GetDirectoryListingTaskParent final
: public FileSystemTaskParentBase
{
56 static already_AddRefed
<GetDirectoryListingTaskParent
> Create(
57 FileSystemBase
* aFileSystem
,
58 const FileSystemGetDirectoryListingParams
& aParam
,
59 FileSystemRequestParent
* aParent
, ErrorResult
& aRv
);
61 nsresult
GetTargetPath(nsAString
& aPath
) const override
;
64 GetDirectoryListingTaskParent(
65 FileSystemBase
* aFileSystem
,
66 const FileSystemGetDirectoryListingParams
& aParam
,
67 FileSystemRequestParent
* aParent
);
69 virtual FileSystemResponseValue
GetSuccessRequestResult(
70 ErrorResult
& aRv
) const override
;
72 virtual nsresult
IOWork() override
;
74 nsCOMPtr
<nsIFile
> mTargetPath
;
78 struct FileOrDirectoryPath
{
81 enum { eFilePath
, eDirectoryPath
} mType
;
84 FallibleTArray
<FileOrDirectoryPath
> mTargetData
;
88 } // namespace mozilla
90 #endif // mozilla_dom_GetDirectoryListing_h