/work/obj-fuzz/dist/include/mozilla/dom/FileSystemBase.h
Line | Count | Source (jump to first uncovered line) |
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_FileSystemBase_h |
8 | | #define mozilla_dom_FileSystemBase_h |
9 | | |
10 | | #include "nsString.h" |
11 | | #include "Directory.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | class BlobImpl; |
17 | | |
18 | | class FileSystemBase |
19 | | { |
20 | | public: |
21 | | NS_INLINE_DECL_REFCOUNTING(FileSystemBase) |
22 | | |
23 | | FileSystemBase(); |
24 | | |
25 | | virtual void |
26 | | Shutdown(); |
27 | | |
28 | | // SerializeDOMPath the FileSystem to string. |
29 | | virtual void |
30 | | SerializeDOMPath(nsAString& aOutput) const = 0; |
31 | | |
32 | | virtual already_AddRefed<FileSystemBase> |
33 | | Clone() = 0; |
34 | | |
35 | | virtual bool |
36 | | ShouldCreateDirectory() = 0; |
37 | | |
38 | | virtual nsISupports* |
39 | | GetParentObject() const; |
40 | | |
41 | | virtual void |
42 | | GetDirectoryName(nsIFile* aFile, nsAString& aRetval, |
43 | | ErrorResult& aRv) const; |
44 | | |
45 | | void |
46 | | GetDOMPath(nsIFile* aFile, nsAString& aRetval, ErrorResult& aRv) const; |
47 | | |
48 | | /* |
49 | | * Return the local root path of the FileSystem implementation. |
50 | | * For OSFileSystem, this is equal to the path of the root Directory; |
51 | | * For DeviceStorageFileSystem, this is the path of the SDCard, parent |
52 | | * directory of the exposed root Directory (per type). |
53 | | */ |
54 | | const nsAString& |
55 | | LocalRootPath() const |
56 | 0 | { |
57 | 0 | return mLocalRootPath; |
58 | 0 | } |
59 | | |
60 | | bool |
61 | | IsShutdown() const |
62 | 0 | { |
63 | 0 | return mShutdown; |
64 | 0 | } |
65 | | |
66 | | virtual bool |
67 | | IsSafeFile(nsIFile* aFile) const; |
68 | | |
69 | | virtual bool |
70 | | IsSafeDirectory(Directory* aDir) const; |
71 | | |
72 | | bool |
73 | | GetRealPath(BlobImpl* aFile, nsIFile** aPath) const; |
74 | | |
75 | | // CC methods |
76 | 0 | virtual void Unlink() {} |
77 | 0 | virtual void Traverse(nsCycleCollectionTraversalCallback &cb) {} |
78 | | |
79 | | void |
80 | | AssertIsOnOwningThread() const; |
81 | | |
82 | | protected: |
83 | | virtual ~FileSystemBase(); |
84 | | |
85 | | // The local path of the root (i.e. the OS path, with OS path separators, of |
86 | | // the OS directory that acts as the root of this OSFileSystem). |
87 | | // This path must be set by the FileSystem implementation immediately |
88 | | // because it will be used for the validation of any FileSystemTaskChildBase. |
89 | | // The concept of this path is that, any task will never go out of it and this |
90 | | // must be considered the OS 'root' of the current FileSystem. Different |
91 | | // Directory object can have different OS 'root' path. |
92 | | // To be more clear, any path managed by this FileSystem implementation must |
93 | | // be discendant of this local root path. |
94 | | nsString mLocalRootPath; |
95 | | |
96 | | bool mShutdown; |
97 | | }; |
98 | | |
99 | | } // namespace dom |
100 | | } // namespace mozilla |
101 | | |
102 | | #endif // mozilla_dom_FileSystemBase_h |