tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GetFilesTask.h (2848B)


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