Bug 1787199 [wpt PR 35620] - Add tests for `VisibilityStateEntry`, a=testonly
[gecko.git] / dom / cache / DBSchema.h
blobe8b864f3c9e1840e4e5e080d8540bd5765def6a9
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/. */
7 #ifndef mozilla_dom_cache_DBSchema_h
8 #define mozilla_dom_cache_DBSchema_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/cache/Types.h"
12 #include "nsError.h"
13 #include "nsString.h"
14 #include "nsTArrayForwardDeclare.h"
16 class mozIStorageConnection;
17 struct nsID;
19 namespace mozilla::dom::cache {
21 class CacheQueryParams;
22 class CacheRequest;
23 class CacheResponse;
24 struct SavedRequest;
25 struct SavedResponse;
27 namespace db {
29 // Note, this cannot be executed within a transaction.
30 nsresult CreateOrMigrateSchema(mozIStorageConnection& aConn);
32 // Note, this cannot be executed within a transaction.
33 nsresult InitializeConnection(mozIStorageConnection& aConn);
35 Result<CacheId, nsresult> CreateCacheId(mozIStorageConnection& aConn);
37 Result<DeletionInfo, nsresult> DeleteCacheId(mozIStorageConnection& aConn,
38 CacheId aCacheId);
40 Result<AutoTArray<CacheId, 8>, nsresult> FindOrphanedCacheIds(
41 mozIStorageConnection& aConn);
43 Result<int64_t, nsresult> FindOverallPaddingSize(mozIStorageConnection& aConn);
45 Result<nsTArray<nsID>, nsresult> GetKnownBodyIds(mozIStorageConnection& aConn);
47 Result<Maybe<SavedResponse>, nsresult> CacheMatch(
48 mozIStorageConnection& aConn, CacheId aCacheId,
49 const CacheRequest& aRequest, const CacheQueryParams& aParams);
51 Result<nsTArray<SavedResponse>, nsresult> CacheMatchAll(
52 mozIStorageConnection& aConn, CacheId aCacheId,
53 const Maybe<CacheRequest>& aMaybeRequest, const CacheQueryParams& aParams);
55 Result<DeletionInfo, nsresult> CachePut(mozIStorageConnection& aConn,
56 CacheId aCacheId,
57 const CacheRequest& aRequest,
58 const nsID* aRequestBodyId,
59 const CacheResponse& aResponse,
60 const nsID* aResponseBodyId);
62 Result<Maybe<DeletionInfo>, nsresult> CacheDelete(
63 mozIStorageConnection& aConn, CacheId aCacheId,
64 const CacheRequest& aRequest, const CacheQueryParams& aParams);
66 Result<nsTArray<SavedRequest>, nsresult> CacheKeys(
67 mozIStorageConnection& aConn, CacheId aCacheId,
68 const Maybe<CacheRequest>& aMaybeRequest, const CacheQueryParams& aParams);
70 Result<Maybe<SavedResponse>, nsresult> StorageMatch(
71 mozIStorageConnection& aConn, Namespace aNamespace,
72 const CacheRequest& aRequest, const CacheQueryParams& aParams);
74 Result<Maybe<CacheId>, nsresult> StorageGetCacheId(mozIStorageConnection& aConn,
75 Namespace aNamespace,
76 const nsAString& aKey);
78 nsresult StoragePutCache(mozIStorageConnection& aConn, Namespace aNamespace,
79 const nsAString& aKey, CacheId aCacheId);
81 nsresult StorageForgetCache(mozIStorageConnection& aConn, Namespace aNamespace,
82 const nsAString& aKey);
84 Result<nsTArray<nsString>, nsresult> StorageGetKeys(
85 mozIStorageConnection& aConn, Namespace aNamespace);
87 // Note, this works best when its NOT executed within a transaction.
88 nsresult IncrementalVacuum(mozIStorageConnection& aConn);
90 // We will wipe out databases with a schema versions less than this. Newer
91 // versions will be migrated on open to the latest schema version.
92 extern const int32_t kFirstShippedSchemaVersion;
94 } // namespace db
95 } // namespace mozilla::dom::cache
97 #endif // mozilla_dom_cache_DBSchema_h