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"
19 already_AddRefed
<quota::Client
> CreateQuotaClient();
22 * The following functions are used to access the directory padding file. The
23 * directory padding file lives in DOM Cache base directory
24 * (e.g. foo.com/cache/.padding). It is used to keep the current overall padding
25 * size for an origin, so that the QuotaManager doesn't need to access the
26 * database when getting quota clients' usage.
28 * For the directory padding file, it's only accessed on Quota IO thread
29 * (for getting current usage) and Cache IO threads (for tracking padding size
30 * change). Besides, the padding file is protected by a mutex lock held by
33 * Each padding file should only take 8 bytes (int64_t) to record the overall
34 * padding size. Besides, we use the temporary padding file to indicate if the
35 * previous action is completed successfully. If the temporary file exists, it
36 * represents that the previous action is failed and the content of padding file
37 * cannot be trusted, and we need to restore the padding file from the database.
40 nsresult
RestorePaddingFile(nsIFile
* aBaseDir
, mozIStorageConnection
* aConn
);
42 nsresult
WipePaddingFile(const QuotaInfo
& aQuotaInfo
, nsIFile
* aBaseDir
);
44 extern const nsLiteralString kCachesSQLiteFilename
;
48 } // namespace mozilla
50 #endif // mozilla_dom_cache_QuotaClient_h