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_GetFilesTask_h
8 : #define mozilla_dom_GetFilesTask_h
9 :
10 : #include "mozilla/dom/Directory.h"
11 : #include "mozilla/dom/FileSystemTaskBase.h"
12 : #include "mozilla/dom/GetFilesHelper.h"
13 : #include "mozilla/ErrorResult.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class BlobImpl;
19 : class FileSystemGetFilesParams;
20 :
21 : class GetFilesTaskChild final : public FileSystemTaskChildBase
22 : {
23 : public:
24 : static already_AddRefed<GetFilesTaskChild>
25 : Create(FileSystemBase* aFileSystem,
26 : Directory* aDirectory,
27 : nsIFile* aTargetPath,
28 : bool aRecursiveFlag,
29 : ErrorResult& aRv);
30 :
31 : virtual
32 : ~GetFilesTaskChild();
33 :
34 : already_AddRefed<Promise>
35 : GetPromise();
36 :
37 : private:
38 : // If aDirectoryOnly is set, we should ensure that the target is a directory.
39 : GetFilesTaskChild(nsIGlobalObject* aGlobalObject,
40 : FileSystemBase* aFileSystem,
41 : Directory* aDirectory,
42 : nsIFile* aTargetPath,
43 : bool aRecursiveFlag);
44 :
45 : virtual FileSystemParams
46 : GetRequestParams(const nsString& aSerializedDOMPath,
47 : ErrorResult& aRv) const override;
48 :
49 : virtual void
50 : SetSuccessRequestResult(const FileSystemResponseValue& aValue,
51 : ErrorResult& aRv) override;
52 :
53 : virtual void
54 : HandlerCallback() override;
55 :
56 : RefPtr<Promise> mPromise;
57 : RefPtr<Directory> mDirectory;
58 : nsCOMPtr<nsIFile> mTargetPath;
59 : bool mRecursiveFlag;
60 :
61 : // We store the fullpath and the dom path of Files.
62 : FallibleTArray<RefPtr<File>> mTargetData;
63 : };
64 :
65 0 : class GetFilesTaskParent final : public FileSystemTaskParentBase
66 : , public GetFilesHelperBase
67 : {
68 : public:
69 : static already_AddRefed<GetFilesTaskParent>
70 : Create(FileSystemBase* aFileSystem,
71 : const FileSystemGetFilesParams& aParam,
72 : FileSystemRequestParent* aParent,
73 : ErrorResult& aRv);
74 :
75 : nsresult
76 : GetTargetPath(nsAString& aPath) const override;
77 :
78 : private:
79 : GetFilesTaskParent(FileSystemBase* aFileSystem,
80 : const FileSystemGetFilesParams& aParam,
81 : FileSystemRequestParent* aParent);
82 :
83 : virtual FileSystemResponseValue
84 : GetSuccessRequestResult(ErrorResult& aRv) const override;
85 :
86 : virtual nsresult
87 : IOWork() override;
88 :
89 : nsString mDirectoryDOMPath;
90 : nsCOMPtr<nsIFile> mTargetPath;
91 : };
92 :
93 : } // namespace dom
94 : } // namespace mozilla
95 :
96 : #endif // mozilla_dom_GetFilesTask_h
|