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__
12 #include "mozilla/Assertions.h"
13 #include "mozilla/Maybe.h"
14 #include "mozilla/fallible.h"
15 #include "nsStringFwd.h"
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
,
51 PersistenceType
PersistenceTypeFromString(const nsACString
& aString
);
53 Maybe
<PersistenceType
> PersistenceTypeFromInt32(int32_t aInt32
,
56 // aFile is expected to be a repository directory (not some file or directory
58 Maybe
<PersistenceType
> PersistenceTypeFromFile(nsIFile
& aFile
,
61 std::array
<PersistenceType
, 2> ComplementaryPersistenceTypes(
62 const PersistenceType aPersistenceType
);
64 } // namespace mozilla::dom::quota
66 #endif // mozilla_dom_quota_persistencetype_h__