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"
13 #include "mozilla/dom/quota/PersistenceType.h"
16 #include "nsIInputStream.h"
19 namespace mozilla::dom::cache
{
23 CHROME_ONLY_NAMESPACE
,
26 static const Namespace INVALID_NAMESPACE
= NUMBER_OF_NAMESPACES
;
28 using CacheId
= int64_t;
29 static const CacheId INVALID_CACHE_ID
= -1;
31 struct CacheDirectoryMetadata
: quota::ClientMetadata
{
32 nsCOMPtr
<nsIFile
> mDir
;
33 int64_t mDirectoryLockId
= -1;
35 explicit CacheDirectoryMetadata(
36 const quota::PrincipalMetadata
& aPrincipalMetadata
)
37 : quota::ClientMetadata(
38 quota::OriginMetadata
{aPrincipalMetadata
,
39 aPrincipalMetadata
.mIsPrivate
40 ? quota::PERSISTENCE_TYPE_PRIVATE
41 : quota::PERSISTENCE_TYPE_DEFAULT
},
42 quota::Client::Type::DOMCACHE
) {}
44 explicit CacheDirectoryMetadata(quota::OriginMetadata aOriginMetadata
)
45 : quota::ClientMetadata(std::move(aOriginMetadata
),
46 quota::Client::Type::DOMCACHE
) {
47 MOZ_DIAGNOSTIC_ASSERT(mPersistenceType
== quota::PERSISTENCE_TYPE_DEFAULT
||
48 mPersistenceType
== quota::PERSISTENCE_TYPE_PRIVATE
);
53 nsTArray
<nsID
> mDeletedBodyIdList
;
54 int64_t mDeletedPaddingSize
= 0;
57 using InputStreamResolver
= std::function
<void(nsCOMPtr
<nsIInputStream
>&&)>;
59 enum class OpenMode
: uint8_t { Eager
, Lazy
, NumTypes
};
61 } // namespace mozilla::dom::cache
63 #endif // mozilla_dom_cache_Types_h