tor-browser

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

FileSystemEntry.h (2090B)


      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_FileSystemEntry_h
      8 #define mozilla_dom_FileSystemEntry_h
      9 
     10 #include "mozilla/dom/BindingDeclarations.h"
     11 #include "mozilla/dom/FileSystemBinding.h"
     12 #include "nsCycleCollectionParticipant.h"
     13 #include "nsIGlobalObject.h"
     14 #include "nsWrapperCache.h"
     15 
     16 namespace mozilla {
     17 class ErrorResult;
     18 
     19 namespace dom {
     20 
     21 class FileSystem;
     22 class OwningFileOrDirectory;
     23 
     24 class FileSystemEntry : public nsISupports, public nsWrapperCache {
     25 public:
     26  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     27  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(FileSystemEntry)
     28 
     29  static already_AddRefed<FileSystemEntry> Create(
     30      nsIGlobalObject* aGlobalObject,
     31      const OwningFileOrDirectory& aFileOrDirectory, FileSystem* aFileSystem);
     32 
     33  nsIGlobalObject* GetParentObject() const { return mParent; }
     34 
     35  virtual JSObject* WrapObject(JSContext* aCx,
     36                               JS::Handle<JSObject*> aGivenProto) override;
     37 
     38  virtual bool IsFile() const { return false; }
     39 
     40  virtual bool IsDirectory() const { return false; }
     41 
     42  virtual void GetName(nsAString& aName, ErrorResult& aRv) const = 0;
     43 
     44  virtual void GetFullPath(nsAString& aFullPath, ErrorResult& aRv) const = 0;
     45 
     46  void GetParent(
     47      const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
     48      const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback);
     49 
     50  FileSystem* Filesystem() const { return mFileSystem; }
     51 
     52 protected:
     53  FileSystemEntry(nsIGlobalObject* aGlobalObject, FileSystemEntry* aParentEntry,
     54                  FileSystem* aFileSystem);
     55  virtual ~FileSystemEntry();
     56 
     57 private:
     58  nsCOMPtr<nsIGlobalObject> mParent;
     59  RefPtr<FileSystemEntry> mParentEntry;
     60  RefPtr<FileSystem> mFileSystem;
     61 };
     62 
     63 }  // namespace dom
     64 }  // namespace mozilla
     65 
     66 #endif  // mozilla_dom_FileSystemEntry_h