Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_GetFileOrDirectory_h
8 : #define mozilla_dom_GetFileOrDirectory_h
9 :
10 : #include "mozilla/dom/Directory.h"
11 : #include "mozilla/dom/FileSystemTaskBase.h"
12 : #include "mozilla/ErrorResult.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class BlobImpl;
18 : class FileSystemGetFileOrDirectoryParams;
19 :
20 : class GetFileOrDirectoryTaskChild final : public FileSystemTaskChildBase
21 : {
22 : public:
23 : static already_AddRefed<GetFileOrDirectoryTaskChild>
24 : Create(FileSystemBase* aFileSystem,
25 : nsIFile* aTargetPath,
26 : ErrorResult& aRv);
27 :
28 : virtual
29 : ~GetFileOrDirectoryTaskChild();
30 :
31 : already_AddRefed<Promise>
32 : GetPromise();
33 :
34 : protected:
35 : virtual FileSystemParams
36 : GetRequestParams(const nsString& aSerializedDOMPath,
37 : ErrorResult& aRv) const override;
38 :
39 : virtual void
40 : SetSuccessRequestResult(const FileSystemResponseValue& aValue,
41 : ErrorResult& aRv) override;
42 : virtual void
43 : HandlerCallback() override;
44 :
45 : private:
46 : GetFileOrDirectoryTaskChild(nsIGlobalObject* aGlobalObject,
47 : FileSystemBase* aFileSystem,
48 : nsIFile* aTargetPath);
49 :
50 : RefPtr<Promise> mPromise;
51 : nsCOMPtr<nsIFile> mTargetPath;
52 :
53 : RefPtr<File> mResultFile;
54 : RefPtr<Directory> mResultDirectory;
55 : };
56 :
57 0 : class GetFileOrDirectoryTaskParent final : public FileSystemTaskParentBase
58 : {
59 : public:
60 : static already_AddRefed<GetFileOrDirectoryTaskParent>
61 : Create(FileSystemBase* aFileSystem,
62 : const FileSystemGetFileOrDirectoryParams& aParam,
63 : FileSystemRequestParent* aParent,
64 : ErrorResult& aRv);
65 :
66 : nsresult
67 : GetTargetPath(nsAString& aPath) const override;
68 :
69 : protected:
70 : virtual FileSystemResponseValue
71 : GetSuccessRequestResult(ErrorResult& aRv) const override;
72 :
73 : virtual nsresult
74 : IOWork() override;
75 :
76 : private:
77 : GetFileOrDirectoryTaskParent(FileSystemBase* aFileSystem,
78 : const FileSystemGetFileOrDirectoryParams& aParam,
79 : FileSystemRequestParent* aParent);
80 :
81 : nsCOMPtr<nsIFile> mTargetPath;
82 :
83 : // Whether we get a directory.
84 : bool mIsDirectory;
85 : };
86 :
87 : } // namespace dom
88 : } // namespace mozilla
89 :
90 : #endif // mozilla_dom_GetFileOrDirectory_h
|