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"
19 class FileSystemGetFileOrDirectoryParams
;
21 class GetFileOrDirectoryTaskChild final
: public FileSystemTaskChildBase
{
23 static already_AddRefed
<GetFileOrDirectoryTaskChild
> Create(
24 FileSystemBase
* aFileSystem
, nsIFile
* aTargetPath
, ErrorResult
& aRv
);
26 virtual ~GetFileOrDirectoryTaskChild();
28 already_AddRefed
<Promise
> GetPromise();
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
;
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
{
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
;
60 virtual FileSystemResponseValue
GetSuccessRequestResult(
61 ErrorResult
& aRv
) const override
;
63 virtual nsresult
IOWork() override
;
66 GetFileOrDirectoryTaskParent(FileSystemBase
* aFileSystem
,
67 const FileSystemGetFileOrDirectoryParams
& aParam
,
68 FileSystemRequestParent
* aParent
);
70 nsCOMPtr
<nsIFile
> mTargetPath
;
72 // Whether we get a directory.
77 } // namespace mozilla
79 #endif // mozilla_dom_GetFileOrDirectory_h