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_Types_h
8 #define mozilla_dom_cache_Types_h
12 #include "mozilla/dom/quota/CommonMetadata.h"
15 #include "nsIInputStream.h"
18 namespace mozilla::dom::cache
{
22 CHROME_ONLY_NAMESPACE
,
25 static const Namespace INVALID_NAMESPACE
= NUMBER_OF_NAMESPACES
;
27 using CacheId
= int64_t;
28 static const CacheId INVALID_CACHE_ID
= -1;
30 struct CacheDirectoryMetadata
: quota::ClientMetadata
{
31 nsCOMPtr
<nsIFile
> mDir
;
32 int64_t mDirectoryLockId
= -1;
34 explicit CacheDirectoryMetadata(quota::PrincipalMetadata aPrincipalMetadata
)
35 : quota::ClientMetadata(
36 quota::OriginMetadata
{std::move(aPrincipalMetadata
),
37 quota::PERSISTENCE_TYPE_DEFAULT
},
38 quota::Client::Type::DOMCACHE
) {}
40 explicit CacheDirectoryMetadata(quota::OriginMetadata aOriginMetadata
)
41 : quota::ClientMetadata(std::move(aOriginMetadata
),
42 quota::Client::Type::DOMCACHE
) {
43 MOZ_DIAGNOSTIC_ASSERT(aOriginMetadata
.mPersistenceType
==
44 quota::PERSISTENCE_TYPE_DEFAULT
);
49 nsTArray
<nsID
> mDeletedBodyIdList
;
50 int64_t mDeletedPaddingSize
= 0;
53 using InputStreamResolver
= std::function
<void(nsCOMPtr
<nsIInputStream
>&&)>;
55 enum class OpenMode
: uint8_t { Eager
, Lazy
, NumTypes
};
57 } // namespace mozilla::dom::cache
59 #endif // mozilla_dom_cache_Types_h