tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PersistenceType.h (2451B)


      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/. */
      6 
      7 #ifndef mozilla_dom_quota_persistencetype_h__
      8 #define mozilla_dom_quota_persistencetype_h__
      9 
     10 #include <array>
     11 #include <cstdint>
     12 
     13 #include "mozilla/Maybe.h"
     14 #include "mozilla/fallible.h"
     15 #include "nsStringFwd.h"
     16 
     17 class nsIFile;
     18 
     19 namespace mozilla::dom::quota {
     20 
     21 enum PersistenceType {
     22  PERSISTENCE_TYPE_PERSISTENT = 0,
     23  PERSISTENCE_TYPE_TEMPORARY,
     24  PERSISTENCE_TYPE_DEFAULT,
     25  PERSISTENCE_TYPE_PRIVATE,
     26 
     27  // Only needed for IPC serialization helper, should never be used in code.
     28  PERSISTENCE_TYPE_INVALID
     29 };
     30 
     31 static const PersistenceType kAllPersistenceTypes[] = {
     32    PERSISTENCE_TYPE_PERSISTENT, PERSISTENCE_TYPE_TEMPORARY,
     33    PERSISTENCE_TYPE_DEFAULT, PERSISTENCE_TYPE_PRIVATE};
     34 
     35 static const PersistenceType kAllPersistenceTypesButPrivate[] = {
     36    PERSISTENCE_TYPE_PERSISTENT, PERSISTENCE_TYPE_TEMPORARY,
     37    PERSISTENCE_TYPE_DEFAULT};
     38 
     39 static const PersistenceType kBestEffortPersistenceTypes[] = {
     40    PERSISTENCE_TYPE_TEMPORARY, PERSISTENCE_TYPE_DEFAULT,
     41    PERSISTENCE_TYPE_PRIVATE};
     42 
     43 static const PersistenceType kInitializableBestEffortPersistenceTypes[] = {
     44    PERSISTENCE_TYPE_TEMPORARY, PERSISTENCE_TYPE_DEFAULT};
     45 
     46 bool IsValidPersistenceType(PersistenceType aPersistenceType);
     47 
     48 bool IsBestEffortPersistenceType(const PersistenceType aPersistenceType);
     49 
     50 nsLiteralCString PersistenceTypeToString(PersistenceType aPersistenceType);
     51 
     52 Maybe<PersistenceType> PersistenceTypeFromString(const nsACString& aString,
     53                                                 const fallible_t&);
     54 
     55 PersistenceType PersistenceTypeFromString(const nsACString& aString);
     56 
     57 Maybe<PersistenceType> PersistenceTypeFromInt32(int32_t aInt32,
     58                                                const fallible_t&);
     59 
     60 // aFile is expected to be a repository directory (not some file or directory
     61 // within that).
     62 Maybe<PersistenceType> PersistenceTypeFromFile(nsIFile& aFile,
     63                                               const fallible_t&);
     64 
     65 std::array<PersistenceType, 2> ComplementaryPersistenceTypes(
     66    const PersistenceType aPersistenceType);
     67 
     68 }  // namespace mozilla::dom::quota
     69 
     70 #endif  // mozilla_dom_quota_persistencetype_h__