tor-browser

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

Types.h (2423B)


      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 mozilla_dom_cache_Types_h
      8 #define mozilla_dom_cache_Types_h
      9 
     10 #include <stdint.h>
     11 
     12 #include <functional>
     13 
     14 #include "mozilla/dom/quota/CommonMetadata.h"
     15 #include "mozilla/dom/quota/PersistenceType.h"
     16 #include "nsCOMPtr.h"
     17 #include "nsIFile.h"
     18 #include "nsIInputStream.h"
     19 #include "nsString.h"
     20 
     21 namespace mozilla {
     22 namespace ipc {
     23 class PBackgroundParent;
     24 }  // namespace ipc
     25 
     26 namespace dom::cache {
     27 class PBoundStorageKeyParent;
     28 
     29 enum Namespace {
     30  DEFAULT_NAMESPACE,
     31  CHROME_ONLY_NAMESPACE,
     32  NUMBER_OF_NAMESPACES
     33 };
     34 static const Namespace INVALID_NAMESPACE = NUMBER_OF_NAMESPACES;
     35 
     36 using CacheId = int64_t;
     37 static const CacheId INVALID_CACHE_ID = -1;
     38 
     39 struct CacheDirectoryMetadata : quota::ClientMetadata {
     40  nsCOMPtr<nsIFile> mDir;
     41  int64_t mDirectoryLockId = -1;
     42 
     43  explicit CacheDirectoryMetadata(
     44      const quota::PrincipalMetadata& aPrincipalMetadata)
     45      : quota::ClientMetadata(
     46            quota::OriginMetadata{aPrincipalMetadata,
     47                                  aPrincipalMetadata.mIsPrivate
     48                                      ? quota::PERSISTENCE_TYPE_PRIVATE
     49                                      : quota::PERSISTENCE_TYPE_DEFAULT},
     50            quota::Client::Type::DOMCACHE) {}
     51 
     52  explicit CacheDirectoryMetadata(quota::OriginMetadata aOriginMetadata)
     53      : quota::ClientMetadata(std::move(aOriginMetadata),
     54                              quota::Client::Type::DOMCACHE) {
     55    MOZ_DIAGNOSTIC_ASSERT(mPersistenceType == quota::PERSISTENCE_TYPE_DEFAULT ||
     56                          mPersistenceType == quota::PERSISTENCE_TYPE_PRIVATE);
     57  }
     58 };
     59 
     60 struct DeletionInfo {
     61  nsTArray<nsID> mDeletedBodyIdList;
     62  int64_t mDeletedPaddingSize = 0;
     63 };
     64 
     65 using InputStreamResolver = std::function<void(nsCOMPtr<nsIInputStream>&&)>;
     66 
     67 enum class OpenMode : uint8_t { Eager, Lazy, NumTypes };
     68 
     69 using pPBackgroundParent = mozilla::ipc::PBackgroundParent*;
     70 using pPBoundStorageKeyParent = PBoundStorageKeyParent*;
     71 using WeakRefParentType = Variant<pPBackgroundParent, pPBoundStorageKeyParent>;
     72 }  // namespace dom::cache
     73 }  // namespace mozilla
     74 
     75 #endif  // mozilla_dom_cache_Types_h