/src/mozilla-central/dom/indexedDB/FileManager.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 |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_indexeddb_filemanager_h__ |
8 | | #define mozilla_dom_indexeddb_filemanager_h__ |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "mozilla/dom/quota/PersistenceType.h" |
12 | | #include "nsDataHashtable.h" |
13 | | #include "nsHashKeys.h" |
14 | | #include "nsISupportsImpl.h" |
15 | | |
16 | | class nsIFile; |
17 | | class mozIStorageConnection; |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | namespace indexedDB { |
22 | | |
23 | | class FileInfo; |
24 | | |
25 | | // Implemented in ActorsParent.cpp. |
26 | | class FileManager final |
27 | | { |
28 | | friend class FileInfo; |
29 | | |
30 | | typedef mozilla::dom::quota::PersistenceType PersistenceType; |
31 | | |
32 | | PersistenceType mPersistenceType; |
33 | | nsCString mGroup; |
34 | | nsCString mOrigin; |
35 | | nsString mDatabaseName; |
36 | | |
37 | | nsString mDirectoryPath; |
38 | | nsString mJournalDirectoryPath; |
39 | | |
40 | | int64_t mLastFileId; |
41 | | |
42 | | // Protected by IndexedDatabaseManager::FileMutex() |
43 | | nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos; |
44 | | |
45 | | const bool mEnforcingQuota; |
46 | | bool mInvalidated; |
47 | | |
48 | | public: |
49 | | static already_AddRefed<nsIFile> |
50 | | GetFileForId(nsIFile* aDirectory, int64_t aId); |
51 | | |
52 | | static already_AddRefed<nsIFile> |
53 | | GetCheckedFileForId(nsIFile* aDirectory, int64_t aId); |
54 | | |
55 | | static nsresult |
56 | | InitDirectory(nsIFile* aDirectory, |
57 | | nsIFile* aDatabaseFile, |
58 | | PersistenceType aPersistenceType, |
59 | | const nsACString& aGroup, |
60 | | const nsACString& aOrigin, |
61 | | uint32_t aTelemetryId); |
62 | | |
63 | | static nsresult |
64 | | GetUsage(nsIFile* aDirectory, uint64_t* aUsage); |
65 | | |
66 | | FileManager(PersistenceType aPersistenceType, |
67 | | const nsACString& aGroup, |
68 | | const nsACString& aOrigin, |
69 | | const nsAString& aDatabaseName, |
70 | | bool aEnforcingQuota); |
71 | | |
72 | | PersistenceType |
73 | | Type() const |
74 | 0 | { |
75 | 0 | return mPersistenceType; |
76 | 0 | } |
77 | | |
78 | | const nsACString& |
79 | | Group() const |
80 | 0 | { |
81 | 0 | return mGroup; |
82 | 0 | } |
83 | | |
84 | | const nsACString& |
85 | | Origin() const |
86 | 0 | { |
87 | 0 | return mOrigin; |
88 | 0 | } |
89 | | |
90 | | const nsAString& |
91 | | DatabaseName() const |
92 | 0 | { |
93 | 0 | return mDatabaseName; |
94 | 0 | } |
95 | | |
96 | | bool |
97 | | EnforcingQuota() const |
98 | 0 | { |
99 | 0 | return mEnforcingQuota; |
100 | 0 | } |
101 | | |
102 | | bool |
103 | | Invalidated() const |
104 | 0 | { |
105 | 0 | return mInvalidated; |
106 | 0 | } |
107 | | |
108 | | nsresult |
109 | | Init(nsIFile* aDirectory, mozIStorageConnection* aConnection); |
110 | | |
111 | | nsresult |
112 | | Invalidate(); |
113 | | |
114 | | already_AddRefed<nsIFile> |
115 | | GetDirectory(); |
116 | | |
117 | | already_AddRefed<nsIFile> |
118 | | GetCheckedDirectory(); |
119 | | |
120 | | already_AddRefed<nsIFile> |
121 | | GetJournalDirectory(); |
122 | | |
123 | | already_AddRefed<nsIFile> |
124 | | EnsureJournalDirectory(); |
125 | | |
126 | | already_AddRefed<FileInfo> |
127 | | GetFileInfo(int64_t aId); |
128 | | |
129 | | already_AddRefed<FileInfo> |
130 | | GetNewFileInfo(); |
131 | | |
132 | | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileManager) |
133 | | |
134 | | private: |
135 | 0 | ~FileManager() = default; |
136 | | }; |
137 | | |
138 | | } // namespace indexedDB |
139 | | } // namespace dom |
140 | | } // namespace mozilla |
141 | | |
142 | | #endif // mozilla_dom_indexeddb_filemanager_h__ |