Bug 1842773 - Part 5: Add ArrayBuffer.prototype.{maxByteLength,resizable} getters...
[gecko.git] / dom / cache / Types.h
blob0e66b13984d5733c9763e190c6fd7a0a19cbc1a0
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
10 #include <functional>
11 #include <stdint.h>
12 #include "mozilla/dom/quota/CommonMetadata.h"
13 #include "mozilla/dom/quota/PersistenceType.h"
14 #include "nsCOMPtr.h"
15 #include "nsIFile.h"
16 #include "nsIInputStream.h"
17 #include "nsString.h"
19 namespace mozilla::dom::cache {
21 enum Namespace {
22 DEFAULT_NAMESPACE,
23 CHROME_ONLY_NAMESPACE,
24 NUMBER_OF_NAMESPACES
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);
52 struct DeletionInfo {
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