Bug 1866894 - Update failing subtest for content-visibility-auto-resize.html. r=fredw
[gecko.git] / dom / filesystem / FileSystemBase.h
blobb78fe1736b9d1ec1a0b23d79efdb1eb2ee164ae3
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_FileSystemBase_h
8 #define mozilla_dom_FileSystemBase_h
10 #include "nsString.h"
11 #include "Directory.h"
13 namespace mozilla::dom {
15 class BlobImpl;
17 class FileSystemBase {
18 public:
19 NS_INLINE_DECL_REFCOUNTING(FileSystemBase)
21 FileSystemBase();
23 virtual void Shutdown();
25 // SerializeDOMPath the FileSystem to string.
26 virtual void SerializeDOMPath(nsAString& aOutput) const = 0;
28 virtual already_AddRefed<FileSystemBase> Clone() = 0;
30 virtual bool ShouldCreateDirectory() = 0;
32 virtual nsIGlobalObject* GetParentObject() const;
34 virtual void GetDirectoryName(nsIFile* aFile, nsAString& aRetval,
35 ErrorResult& aRv) const;
37 void GetDOMPath(nsIFile* aFile, nsAString& aRetval, ErrorResult& aRv) const;
40 * Return the local root path of the FileSystem implementation.
41 * For OSFileSystem, this is equal to the path of the root Directory;
42 * For DeviceStorageFileSystem, this is the path of the SDCard, parent
43 * directory of the exposed root Directory (per type).
45 const nsAString& LocalRootPath() const { return mLocalRootPath; }
47 bool IsShutdown() const { return mShutdown; }
49 virtual bool IsSafeFile(nsIFile* aFile) const;
51 virtual bool IsSafeDirectory(Directory* aDir) const;
53 bool GetRealPath(BlobImpl* aFile, nsIFile** aPath) const;
55 // CC methods
56 virtual void Unlink() {}
57 virtual void Traverse(nsCycleCollectionTraversalCallback& cb) {}
59 void AssertIsOnOwningThread() const;
61 protected:
62 virtual ~FileSystemBase();
64 // The local path of the root (i.e. the OS path, with OS path separators, of
65 // the OS directory that acts as the root of this OSFileSystem).
66 // This path must be set by the FileSystem implementation immediately
67 // because it will be used for the validation of any FileSystemTaskChildBase.
68 // The concept of this path is that, any task will never go out of it and this
69 // must be considered the OS 'root' of the current FileSystem. Different
70 // Directory object can have different OS 'root' path.
71 // To be more clear, any path managed by this FileSystem implementation must
72 // be discendant of this local root path.
73 nsString mLocalRootPath;
75 bool mShutdown;
78 } // namespace mozilla::dom
80 #endif // mozilla_dom_FileSystemBase_h