QuotaClient.h (1941B)
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_cache_QuotaClient_h 8 #define mozilla_dom_cache_QuotaClient_h 9 10 #include "mozIStorageConnection.h" 11 #include "mozilla/dom/cache/Types.h" 12 #include "mozilla/dom/quota/Client.h" 13 14 namespace mozilla::dom::cache { 15 16 already_AddRefed<quota::Client> CreateQuotaClient(); 17 18 /** 19 * The following functions are used to access the directory padding file. The 20 * directory padding file lives in DOM Cache base directory 21 * (e.g. foo.com/cache/.padding). It is used to keep the current overall padding 22 * size for an origin, so that the QuotaManager doesn't need to access the 23 * database when getting quota clients' usage. 24 * 25 * For the directory padding file, it's only accessed on Quota IO thread 26 * (for getting current usage) and Cache IO threads (for tracking padding size 27 * change). Besides, the padding file is protected by a mutex lock held by 28 * CacheQuotaClient. 29 * 30 * Each padding file should only take 8 bytes (int64_t) to record the overall 31 * padding size. Besides, we use the temporary padding file to indicate if the 32 * previous action is completed successfully. If the temporary file exists, it 33 * represents that the previous action is failed and the content of padding file 34 * cannot be trusted, and we need to restore the padding file from the database. 35 */ 36 37 nsresult RestorePaddingFile(nsIFile* aBaseDir, mozIStorageConnection* aConn); 38 39 nsresult WipePaddingFile(const CacheDirectoryMetadata& aDirectoryMetadata, 40 nsIFile* aBaseDir); 41 42 extern const nsLiteralString kCachesSQLiteFilename; 43 44 } // namespace mozilla::dom::cache 45 46 #endif // mozilla_dom_cache_QuotaClient_h