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