tor-browser

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

DBSchema.h (3870B)


      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_DBSchema_h
      8 #define mozilla_dom_cache_DBSchema_h
      9 
     10 #include "mozilla/dom/cache/Types.h"
     11 #include "nsError.h"
     12 #include "nsString.h"
     13 #include "nsTArrayForwardDeclare.h"
     14 
     15 class mozIStorageConnection;
     16 struct nsID;
     17 
     18 namespace mozilla::dom::cache {
     19 
     20 class CacheQueryParams;
     21 class CacheRequest;
     22 class CacheResponse;
     23 struct SavedRequest;
     24 struct SavedResponse;
     25 
     26 namespace db {
     27 
     28 // Note, this cannot be executed within a transaction.
     29 nsresult CreateOrMigrateSchema(nsIFile& aDBDir, mozIStorageConnection& aConn);
     30 
     31 // Note, this cannot be executed within a transaction.
     32 nsresult InitializeConnection(mozIStorageConnection& aConn);
     33 
     34 Result<CacheId, nsresult> CreateCacheId(mozIStorageConnection& aConn);
     35 
     36 Result<DeletionInfo, nsresult> DeleteCacheId(mozIStorageConnection& aConn,
     37                                             CacheId aCacheId);
     38 
     39 Result<AutoTArray<CacheId, 8>, nsresult> FindOrphanedCacheIds(
     40    mozIStorageConnection& aConn);
     41 
     42 Result<int64_t, nsresult> FindOverallPaddingSize(mozIStorageConnection& aConn);
     43 
     44 Result<int64_t, nsresult> GetTotalDiskUsage(mozIStorageConnection& aConn);
     45 
     46 Result<nsTHashSet<nsID>, nsresult> GetKnownBodyIds(
     47    mozIStorageConnection& aConn);
     48 
     49 Result<Maybe<SavedResponse>, nsresult> CacheMatch(
     50    mozIStorageConnection& aConn, CacheId aCacheId,
     51    const CacheRequest& aRequest, const CacheQueryParams& aParams);
     52 
     53 Result<nsTArray<SavedResponse>, nsresult> CacheMatchAll(
     54    mozIStorageConnection& aConn, CacheId aCacheId,
     55    const Maybe<CacheRequest>& aMaybeRequest, const CacheQueryParams& aParams);
     56 
     57 Result<DeletionInfo, nsresult> CachePut(mozIStorageConnection& aConn,
     58                                        CacheId aCacheId,
     59                                        const CacheRequest& aRequest,
     60                                        const nsID* aRequestBodyId,
     61                                        const CacheResponse& aResponse,
     62                                        const nsID* aResponseBodyId);
     63 
     64 Result<Maybe<DeletionInfo>, nsresult> CacheDelete(
     65    mozIStorageConnection& aConn, CacheId aCacheId,
     66    const CacheRequest& aRequest, const CacheQueryParams& aParams);
     67 
     68 Result<nsTArray<SavedRequest>, nsresult> CacheKeys(
     69    mozIStorageConnection& aConn, CacheId aCacheId,
     70    const Maybe<CacheRequest>& aMaybeRequest, const CacheQueryParams& aParams);
     71 
     72 Result<Maybe<SavedResponse>, nsresult> StorageMatch(
     73    mozIStorageConnection& aConn, Namespace aNamespace,
     74    const CacheRequest& aRequest, const CacheQueryParams& aParams);
     75 
     76 Result<Maybe<CacheId>, nsresult> StorageGetCacheId(mozIStorageConnection& aConn,
     77                                                   Namespace aNamespace,
     78                                                   const nsAString& aKey);
     79 
     80 nsresult StoragePutCache(mozIStorageConnection& aConn, Namespace aNamespace,
     81                         const nsAString& aKey, CacheId aCacheId);
     82 
     83 nsresult StorageForgetCache(mozIStorageConnection& aConn, Namespace aNamespace,
     84                            const nsAString& aKey);
     85 
     86 Result<nsTArray<nsString>, nsresult> StorageGetKeys(
     87    mozIStorageConnection& aConn, Namespace aNamespace);
     88 
     89 // Note, this works best when its NOT executed within a transaction.
     90 nsresult IncrementalVacuum(mozIStorageConnection& aConn);
     91 
     92 // We will wipe out databases with a schema versions less than this.  Newer
     93 // versions will be migrated on open to the latest schema version.
     94 extern const int32_t kFirstShippedSchemaVersion;
     95 
     96 }  // namespace db
     97 }  // namespace mozilla::dom::cache
     98 
     99 #endif  // mozilla_dom_cache_DBSchema_h