tor-browser

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

QuotaManagerTestHelpers.h (5375B)


      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 #include "nsStringFwd.h"
      8 
      9 namespace mozilla::dom::quota {
     10 
     11 struct PrincipalMetadata;
     12 struct OriginMetadata;
     13 struct OriginStateMetadata;
     14 struct FullOriginMetadata;
     15 
     16 namespace test {
     17 
     18 /**
     19 * Creates a PrincipalMetadata object for a principal without an origin suffix.
     20 *
     21 * This function takes a group (without suffix) and origin (without suffix) and
     22 * returns a PrincipalMetadata object with these values. The suffix and private
     23 * browsing flag are set to their default values: an empty string and false,
     24 * respectively.
     25 *
     26 * @param aGroupNoSuffix The group associated with the principal, without the
     27 * suffix.
     28 * @param aOriginNoSuffix The origin without the suffix.
     29 *
     30 * @returns A PrincipalMetadata object containing the given group and origin,
     31 * with an empty origin suffix and a false private browsing flag.
     32 */
     33 PrincipalMetadata GetPrincipalMetadata(const nsCString& aGroupNoSuffix,
     34                                       const nsCString& aOriginNoSuffix);
     35 
     36 /**
     37 * Creates a PrincipalMetadata object for a principal with an origin suffix.
     38 *
     39 * This function takes an origin suffix, a group (without suffix), and an origin
     40 * (without suffix), and returns a PrincipalMetadata object with these values,
     41 * including the origin suffix. The private browsing flag is set to false by
     42 * default.
     43 *
     44 * @param aOriginSuffix The suffix to be added to the group and origin.
     45 * @param aGroupNoSuffix The group associated with the principal, without the
     46 * suffix.
     47 * @param aOriginNoSuffix The origin without the suffix.
     48 *
     49 * @returns A PrincipalMetadata object containing the given suffix, group, and
     50 * origin, with a false private browsing flag.
     51 */
     52 PrincipalMetadata GetPrincipalMetadata(const nsCString& aOriginSuffix,
     53                                       const nsCString& aGroupNoSuffix,
     54                                       const nsCString& aOriginNoSuffix);
     55 
     56 /**
     57 * Creates a PrincipalMetadata object for a principal with an origin suffix.
     58 *
     59 * This function takes an origin suffix, a group (without suffix), an origin
     60 * (without suffix), and a private browsing flag, and returns a
     61 * PrincipalMetadata object with these values, including the origin suffix.
     62 *
     63 * For private browsing contexts, a randomly generated UUID is used as the
     64 * storage origin to satisfy the PrincipalMetadata invariant that requires
     65 * origin and storageOrigin to differ when aIsPrivate is true.
     66 *
     67 * @param aOriginSuffix The suffix to be added to the group and origin.
     68 * @param aGroupNoSuffix The group associated with the principal, without the
     69 * suffix.
     70 * @param aOriginNoSuffix The origin without the suffix.
     71 * @param aIsPrivate A boolean flag indicating whether the principal is from
     72 * a private browsing context.
     73 *
     74 * @returns A PrincipalMetadata object containing the given suffix, group,
     75 * origin, and private browsing flag.
     76 */
     77 PrincipalMetadata GetPrincipalMetadata(const nsCString& aOriginSuffix,
     78                                       const nsCString& aGroupNoSuffix,
     79                                       const nsCString& aOriginNoSuffix,
     80                                       bool aIsPrivate);
     81 
     82 /**
     83 * Creates an OriginMetadata object for a principal with an origin suffix.
     84 *
     85 * This function takes the same parameters as GetPrincipalMetadata, but
     86 * returns an OriginMetadata object. The additional fields in OriginMetadata
     87 * are set as follows:
     88 * - The PERSISTENCE_TYPE_DEFAULT is used as the persistence type.
     89 *
     90 * @param aOriginSuffix The suffix to be added to the group and origin.
     91 * @param aGroupNoSuffix The group associated with the principal, without the
     92 * suffix.
     93 * @param aOriginNoSuffix The origin without the suffix.
     94 *
     95 * @returns An OriginMetadata object containing the principal metadata from
     96 * GetPrincipalMetadata, with the PERSISTENCE_TYPE_DEFAULT persistence type.
     97 */
     98 OriginMetadata GetOriginMetadata(const nsCString& aOriginSuffix,
     99                                 const nsCString& aGroupNoSuffix,
    100                                 const nsCString& aOriginNoSuffix);
    101 
    102 /**
    103 * Creates a FullOriginMetadata object for a principal with an origin suffix.
    104 *
    105 * This function takes the same parameters as GetOriginMetadata, but returns
    106 * a FullOriginMetadata object. The additional fields in FullOriginMetadata
    107 * are set as follows:
    108 * - The false value is used for the persisted flag.
    109 * - The 0 value is used for the last access time.
    110 *
    111 * @param aOriginSuffix The suffix to be added to the group and origin.
    112 * @param aGroupNoSuffix The group associated with the principal, without the
    113 * suffix.
    114 * @param aOriginNoSuffix The origin without the suffix.
    115 *
    116 * @returns A FullOriginMetadata object containing the origin metadata from
    117 * GetOriginMetadata, with a false persisted flag and a zero last access time.
    118 */
    119 FullOriginMetadata GetFullOriginMetadata(const nsCString& aOriginSuffix,
    120                                         const nsCString& aGroupNoSuffix,
    121                                         const nsCString& aOriginNoSuffix);
    122 
    123 }  //  namespace test
    124 }  //  namespace mozilla::dom::quota