Bug 1771337 [wpt PR 34217] - Convert `popup=popup` to `popup=auto` or just `popup...
[gecko.git] / dom / filesystem / GetFileOrDirectoryTask.h
blob8d15d9804f40d0db29a433fb313947136fa39a50
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_GetFileOrDirectory_h
8 #define mozilla_dom_GetFileOrDirectory_h
10 #include "mozilla/dom/Directory.h"
11 #include "mozilla/dom/FileSystemTaskBase.h"
13 namespace mozilla {
14 class ErrorResult;
16 namespace dom {
18 class BlobImpl;
19 class FileSystemGetFileOrDirectoryParams;
21 class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase {
22 public:
23 static already_AddRefed<GetFileOrDirectoryTaskChild> Create(
24 FileSystemBase* aFileSystem, nsIFile* aTargetPath, ErrorResult& aRv);
26 virtual ~GetFileOrDirectoryTaskChild();
28 already_AddRefed<Promise> GetPromise();
30 protected:
31 virtual FileSystemParams GetRequestParams(const nsString& aSerializedDOMPath,
32 ErrorResult& aRv) const override;
34 virtual void SetSuccessRequestResult(const FileSystemResponseValue& aValue,
35 ErrorResult& aRv) override;
36 virtual void HandlerCallback() override;
38 private:
39 GetFileOrDirectoryTaskChild(nsIGlobalObject* aGlobalObject,
40 FileSystemBase* aFileSystem,
41 nsIFile* aTargetPath);
43 RefPtr<Promise> mPromise;
44 nsCOMPtr<nsIFile> mTargetPath;
46 RefPtr<File> mResultFile;
47 RefPtr<Directory> mResultDirectory;
50 class GetFileOrDirectoryTaskParent final : public FileSystemTaskParentBase {
51 public:
52 static already_AddRefed<GetFileOrDirectoryTaskParent> Create(
53 FileSystemBase* aFileSystem,
54 const FileSystemGetFileOrDirectoryParams& aParam,
55 FileSystemRequestParent* aParent, ErrorResult& aRv);
57 nsresult GetTargetPath(nsAString& aPath) const override;
59 protected:
60 virtual FileSystemResponseValue GetSuccessRequestResult(
61 ErrorResult& aRv) const override;
63 virtual nsresult IOWork() override;
65 private:
66 GetFileOrDirectoryTaskParent(FileSystemBase* aFileSystem,
67 const FileSystemGetFileOrDirectoryParams& aParam,
68 FileSystemRequestParent* aParent);
70 nsCOMPtr<nsIFile> mTargetPath;
72 // Whether we get a directory.
73 bool mIsDirectory;
76 } // namespace dom
77 } // namespace mozilla
79 #endif // mozilla_dom_GetFileOrDirectory_h