Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / quota / PersistenceType.h
blobdd2f09ecbdf387a52b0e4edc06219d4b7396cd18
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/. */
7 #ifndef mozilla_dom_quota_persistencetype_h__
8 #define mozilla_dom_quota_persistencetype_h__
10 #include <array>
11 #include <cstdint>
12 #include "mozilla/Assertions.h"
13 #include "mozilla/Maybe.h"
14 #include "mozilla/fallible.h"
15 #include "nsStringFwd.h"
17 class nsIFile;
19 namespace mozilla::dom::quota {
21 enum PersistenceType {
22 PERSISTENCE_TYPE_PERSISTENT = 0,
23 PERSISTENCE_TYPE_TEMPORARY,
24 PERSISTENCE_TYPE_DEFAULT,
25 PERSISTENCE_TYPE_PRIVATE,
27 // Only needed for IPC serialization helper, should never be used in code.
28 PERSISTENCE_TYPE_INVALID
31 static const PersistenceType kAllPersistenceTypes[] = {
32 PERSISTENCE_TYPE_PERSISTENT, PERSISTENCE_TYPE_TEMPORARY,
33 PERSISTENCE_TYPE_DEFAULT, PERSISTENCE_TYPE_PRIVATE};
35 static const PersistenceType kBestEffortPersistenceTypes[] = {
36 PERSISTENCE_TYPE_TEMPORARY, PERSISTENCE_TYPE_DEFAULT,
37 PERSISTENCE_TYPE_PRIVATE};
39 static const PersistenceType kInitializableBestEffortPersistenceTypes[] = {
40 PERSISTENCE_TYPE_TEMPORARY, PERSISTENCE_TYPE_DEFAULT};
42 bool IsValidPersistenceType(PersistenceType aPersistenceType);
44 bool IsBestEffortPersistenceType(const PersistenceType aPersistenceType);
46 nsLiteralCString PersistenceTypeToString(PersistenceType aPersistenceType);
48 Maybe<PersistenceType> PersistenceTypeFromString(const nsACString& aString,
49 const fallible_t&);
51 PersistenceType PersistenceTypeFromString(const nsACString& aString);
53 Maybe<PersistenceType> PersistenceTypeFromInt32(int32_t aInt32,
54 const fallible_t&);
56 // aFile is expected to be a repository directory (not some file or directory
57 // within that).
58 Maybe<PersistenceType> PersistenceTypeFromFile(nsIFile& aFile,
59 const fallible_t&);
61 std::array<PersistenceType, 2> ComplementaryPersistenceTypes(
62 const PersistenceType aPersistenceType);
64 } // namespace mozilla::dom::quota
66 #endif // mozilla_dom_quota_persistencetype_h__