DBSchema.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_cache_DBSchema_h
  6. #define mozilla_dom_cache_DBSchema_h
  7. #include "mozilla/Attributes.h"
  8. #include "mozilla/dom/cache/Types.h"
  9. #include "nsError.h"
  10. #include "nsString.h"
  11. #include "nsTArrayForwardDeclare.h"
  12. class mozIStorageConnection;
  13. struct nsID;
  14. namespace mozilla {
  15. namespace dom {
  16. namespace cache {
  17. class CacheQueryParams;
  18. class CacheRequest;
  19. class CacheRequestOrVoid;
  20. class CacheResponse;
  21. struct SavedRequest;
  22. struct SavedResponse;
  23. namespace db {
  24. // Note, this cannot be executed within a transaction.
  25. nsresult
  26. CreateOrMigrateSchema(mozIStorageConnection* aConn);
  27. // Note, this cannot be executed within a transaction.
  28. nsresult
  29. InitializeConnection(mozIStorageConnection* aConn);
  30. nsresult
  31. CreateCacheId(mozIStorageConnection* aConn, CacheId* aCacheIdOut);
  32. nsresult
  33. DeleteCacheId(mozIStorageConnection* aConn, CacheId aCacheId,
  34. nsTArray<nsID>& aDeletedBodyIdListOut);
  35. // TODO: Consider removing unused IsCacheOrphaned after writing cleanup code. (bug 1110446)
  36. nsresult
  37. IsCacheOrphaned(mozIStorageConnection* aConn, CacheId aCacheId,
  38. bool* aOrphanedOut);
  39. nsresult
  40. FindOrphanedCacheIds(mozIStorageConnection* aConn,
  41. nsTArray<CacheId>& aOrphanedListOut);
  42. nsresult
  43. GetKnownBodyIds(mozIStorageConnection* aConn, nsTArray<nsID>& aBodyIdListOut);
  44. nsresult
  45. CacheMatch(mozIStorageConnection* aConn, CacheId aCacheId,
  46. const CacheRequest& aRequest, const CacheQueryParams& aParams,
  47. bool* aFoundResponseOut, SavedResponse* aSavedResponseOut);
  48. nsresult
  49. CacheMatchAll(mozIStorageConnection* aConn, CacheId aCacheId,
  50. const CacheRequestOrVoid& aRequestOrVoid,
  51. const CacheQueryParams& aParams,
  52. nsTArray<SavedResponse>& aSavedResponsesOut);
  53. nsresult
  54. CachePut(mozIStorageConnection* aConn, CacheId aCacheId,
  55. const CacheRequest& aRequest,
  56. const nsID* aRequestBodyId,
  57. const CacheResponse& aResponse,
  58. const nsID* aResponseBodyId,
  59. nsTArray<nsID>& aDeletedBodyIdListOut);
  60. nsresult
  61. CacheDelete(mozIStorageConnection* aConn, CacheId aCacheId,
  62. const CacheRequest& aRequest,
  63. const CacheQueryParams& aParams,
  64. nsTArray<nsID>& aDeletedBodyIdListOut,
  65. bool* aSuccessOut);
  66. nsresult
  67. CacheKeys(mozIStorageConnection* aConn, CacheId aCacheId,
  68. const CacheRequestOrVoid& aRequestOrVoid,
  69. const CacheQueryParams& aParams,
  70. nsTArray<SavedRequest>& aSavedRequestsOut);
  71. nsresult
  72. StorageMatch(mozIStorageConnection* aConn,
  73. Namespace aNamespace,
  74. const CacheRequest& aRequest,
  75. const CacheQueryParams& aParams,
  76. bool* aFoundResponseOut,
  77. SavedResponse* aSavedResponseOut);
  78. nsresult
  79. StorageGetCacheId(mozIStorageConnection* aConn, Namespace aNamespace,
  80. const nsAString& aKey, bool* aFoundCacheOut,
  81. CacheId* aCacheIdOut);
  82. nsresult
  83. StoragePutCache(mozIStorageConnection* aConn, Namespace aNamespace,
  84. const nsAString& aKey, CacheId aCacheId);
  85. nsresult
  86. StorageForgetCache(mozIStorageConnection* aConn, Namespace aNamespace,
  87. const nsAString& aKey);
  88. nsresult
  89. StorageGetKeys(mozIStorageConnection* aConn, Namespace aNamespace,
  90. nsTArray<nsString>& aKeysOut);
  91. // Note, this works best when its NOT executed within a transaction.
  92. nsresult
  93. IncrementalVacuum(mozIStorageConnection* aConn);
  94. // We will wipe out databases with a schema versions less than this. Newer
  95. // versions will be migrated on open to the latest schema version.
  96. extern const int32_t kFirstShippedSchemaVersion;
  97. } // namespace db
  98. } // namespace cache
  99. } // namespace dom
  100. } // namespace mozilla
  101. #endif // mozilla_dom_cache_DBSchema_h