tor-browser

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

Constants.h (3517B)


      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/. */
      6 
      7 #ifndef DOM_QUOTA_CONSTANTS_H_
      8 #define DOM_QUOTA_CONSTANTS_H_
      9 
     10 #include "nsLiteralString.h"
     11 #include "prtime.h"
     12 
     13 // The name of the file that we use to load/save the last access time of an
     14 // origin.
     15 // XXX We should get rid of old metadata files at some point, bug 1343576.
     16 #define METADATA_FILE_NAME u".metadata"
     17 #define METADATA_TMP_FILE_NAME u".metadata-tmp"
     18 #define METADATA_V2_FILE_NAME u".metadata-v2"
     19 #define METADATA_V2_TMP_FILE_NAME u".metadata-v2-tmp"
     20 
     21 namespace mozilla::dom::quota {
     22 
     23 // Seconds in one day (24 * 60 * 60). Used for time based calculations across
     24 // quota manager code.
     25 constexpr int64_t kSecPerDay = 86400;
     26 
     27 // Seconds in one week.
     28 constexpr int64_t kSecPerWeek = 7 * kSecPerDay;
     29 
     30 // Default cutoff access time (in microseconds) used for temporary storage
     31 // cleanup. Corresponds to "one week ago" and is used as the threshold when
     32 // clearing non persisted zero usage origins.
     33 constexpr int64_t aDefaultCutoffAccessTime = kSecPerWeek * PR_USEC_PER_SEC;
     34 
     35 const char kChromeOrigin[] = "chrome";
     36 
     37 constexpr auto kSQLiteSuffix = u".sqlite"_ns;
     38 
     39 constexpr nsLiteralCString kUUIDOriginScheme = "uuid"_ns;
     40 
     41 // Special value used when quota version is unknown or not applicable.
     42 //
     43 // This is used in the following cases:
     44 // - When loading quota info from the L1 cache (see LoadQuota)
     45 // - When reading a metadata file that hasn't yet been upgraded to include the
     46 //   quota version field
     47 // - When the metadata file is missing or corrupted and must be restored
     48 //
     49 // In these situations, the quota version is effectively undefined and cannot
     50 // be trusted.
     51 const uint32_t kNoQuotaVersion = 0;
     52 
     53 // Current version of the quota management.
     54 //
     55 // This value is written to disk when a metadata file is created for a new
     56 // (empty) origin directory or after performing a full origin directory scan.
     57 // It represents the version of quota tracking logic used to generate the
     58 // originUsage and clientUsages values.
     59 //
     60 // The version must be incremented whenever the quota management logic changes
     61 // in a way that could invalidate existing cached usage data. This includes:
     62 // - Adding a new quota client
     63 // - Removing an existing quota client
     64 // - Changing how usage is calculated or stored
     65 // - Any other change that could cause a mismatch between actual on-disk usage
     66 //   and the cached originUsage/clientUsages values
     67 //
     68 // At present, it is the responsibility of patch authors and reviewers to
     69 // decide when a bump is required. However, in the future, a test will verify
     70 // the correctness of cached usage data by comparing it against real usage,
     71 // using a pre-packaged or conditioned profile.
     72 //
     73 // If you're unsure whether a bump is needed, it's safer to do one. However,
     74 // keep in mind that increasing this version will invalidate the L2 quota info
     75 // cache. When the L1 quota info cache can't be used, such as when the build ID
     76 // changes, after a crash, or on Android in general, and the L2 quota info
     77 // cache is also unavailable due to the version bump, storage initialization
     78 // will have to fall back to the slowest path: a full storage scan.
     79 const uint32_t kCurrentQuotaVersion = 1;
     80 
     81 }  // namespace mozilla::dom::quota
     82 
     83 #endif  // DOM_QUOTA_CONSTANTS_H_