Bug 1610775 [wpt PR 21336] - Update urllib3 to 1.25.8, a=testonly
[gecko.git] / dom / filesystem / GetDirectoryListingTask.h
blob23e05848048a15099835d5cb17d4bc1f275b852b
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"
14 namespace mozilla {
15 namespace dom {
17 class BlobImpl;
18 class FileSystemGetDirectoryListingParams;
19 class OwningFileOrDirectory;
21 class GetDirectoryListingTaskChild final : public FileSystemTaskChildBase {
22 public:
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();
31 private:
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;
49 nsString mFilters;
51 FallibleTArray<OwningFileOrDirectory> mTargetData;
54 class GetDirectoryListingTaskParent final : public FileSystemTaskParentBase {
55 public:
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;
63 private:
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;
75 nsString mDOMPath;
76 nsString mFilters;
78 struct FileOrDirectoryPath {
79 nsString mPath;
81 enum { eFilePath, eDirectoryPath } mType;
84 FallibleTArray<FileOrDirectoryPath> mTargetData;
87 } // namespace dom
88 } // namespace mozilla
90 #endif // mozilla_dom_GetDirectoryListing_h