Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/quota/./../../../dom/quota/OriginInfo.cpp
Warning:line 339, column 11
Value stored to 'newTemporaryStorageUsage' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_dom_quota1.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/quota -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/quota -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/dom/quota -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/quota -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/toolkit/components/telemetry -I /root/firefox-clang/xpcom/base -I /root/firefox-clang/caps -I /root/firefox-clang/dom/fs/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c++ Unified_cpp_dom_quota1.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "OriginInfo.h"
6
7#include "DirtyTrackingAutoLock.h"
8#include "GroupInfo.h"
9#include "GroupInfoPair.h"
10#include "OriginUpserter.h"
11#include "mozIStorageConnection.h"
12#include "mozIStorageStatement.h"
13#include "mozilla/dom/quota/AssertionsImpl.h"
14#include "mozilla/dom/quota/QuotaCommon.h"
15#include "mozilla/dom/quota/ResultExtensions.h"
16#include "mozilla/dom/quota/UsageInfo.h"
17
18#if defined(NIGHTLY_BUILD1) || defined(DEBUG1)
19# define CHECK_USAGE() \
20 CheckIfUsageIsConsistent("OriginInfo::"_ns + nsDependentCString(__func__))
21#else
22# define CHECK_USAGE()
23#endif
24
25namespace mozilla::dom::quota {
26
27// This constructor is called from the "QuotaManager IO" thread and so we
28// can't check if the principal has a WebExtensionPolicy instance associated
29// to it, and even besides that if the extension is currently disabled (and so
30// no WebExtensionPolicy instance would actually exist) its stored data
31// shouldn't be cleared until the extension is uninstalled and so here we
32// resort to check the origin scheme instead to initialize mIsExtension.
33OriginInfo::OriginInfo(GroupInfo* aGroupInfo, const nsACString& aOrigin,
34 const nsACString& aStorageOrigin, bool aIsPrivate,
35 const ClientUsageArray& aClientUsages, uint64_t aUsage,
36 int64_t aAccessTime, int32_t aMaintenanceDate,
37 bool aPersisted, bool aDirectoryExists)
38 : mGroupInfo(aGroupInfo),
39 mOrigin(aOrigin),
40 mStorageOrigin(aStorageOrigin),
41 mAccessTime(aAccessTime),
42 mMaintenanceDate(aMaintenanceDate),
43 mIsPrivate(aIsPrivate),
44 mAccessed(false),
45 mPersisted(aPersisted),
46 mIsExtension(StringBeginsWith(aOrigin, "moz-extension://"_ns)),
47 mDirectoryExists(aDirectoryExists),
48 mClientUsages(aClientUsages),
49 mUsage(aUsage) {
50 MOZ_ASSERT(aGroupInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aGroupInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aGroupInfo))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aGroupInfo", "./../../../dom/quota/OriginInfo.cpp"
, 50); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aGroupInfo" ")"
); do { MOZ_CrashSequence(__null, 50); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
51 MOZ_ASSERT_IF(!aIsPrivate, aOrigin == aStorageOrigin)do { if (!aIsPrivate) { do { static_assert( mozilla::detail::
AssertionConditionType<decltype(aOrigin == aStorageOrigin)
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aOrigin == aStorageOrigin))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("aOrigin == aStorageOrigin", "./../../../dom/quota/OriginInfo.cpp"
, 51); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOrigin == aStorageOrigin"
")"); do { MOZ_CrashSequence(__null, 51); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
52 MOZ_ASSERT_IF(aIsPrivate, aOrigin != aStorageOrigin)do { if (aIsPrivate) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(aOrigin != aStorageOrigin)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aOrigin != aStorageOrigin)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("aOrigin != aStorageOrigin"
, "./../../../dom/quota/OriginInfo.cpp", 52); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aOrigin != aStorageOrigin" ")"); do { MOZ_CrashSequence
(__null, 52); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); } } while (false)
;
53 MOZ_ASSERT(aClientUsages.Length() == Client::TypeMax())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aClientUsages.Length() == Client::TypeMax())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(aClientUsages.Length() == Client::TypeMax()))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("aClientUsages.Length() == Client::TypeMax()"
, "./../../../dom/quota/OriginInfo.cpp", 53); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aClientUsages.Length() == Client::TypeMax()"
")"); do { MOZ_CrashSequence(__null, 53); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
54 MOZ_ASSERT_IF(aPersisted,do { if (aPersisted) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT"
, "./../../../dom/quota/OriginInfo.cpp", 55); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT"
")"); do { MOZ_CrashSequence(__null, 55); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
55 aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT)do { if (aPersisted) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT"
, "./../../../dom/quota/OriginInfo.cpp", 55); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT"
")"); do { MOZ_CrashSequence(__null, 55); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
56 CHECK_USAGE();
57 MOZ_COUNT_CTOR(OriginInfo)do { static_assert(std::is_class_v<OriginInfo>, "Token '"
"OriginInfo" "' is not a class type."); static_assert(!std::
is_base_of_v<nsISupports, OriginInfo>, "nsISupports classes don't need to call MOZ_COUNT_CTOR or "
"MOZ_COUNT_DTOR");; NS_LogCtor((void*)this, "OriginInfo", sizeof
(*this)); } while (0)
;
58}
59
60#if defined(NIGHTLY_BUILD1) || defined(DEBUG1)
61bool OriginInfo::CheckIfUsageIsConsistent(const nsACString& context) const {
62 return CheckClientUsagesConsistency(mClientUsages, mUsage, context);
63}
64#endif // defined(NIGHTLY_BUILD) || defined(DEBUG)
65
66int64_t OriginInfo::LockedUsage() const {
67 AssertCurrentThreadOwnsQuotaMutex();
68 CHECK_USAGE();
69 return mUsage;
70}
71
72OriginMetadata OriginInfo::FlattenToOriginMetadata() const {
73 MOZ_ASSERT(mGroupInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mGroupInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mGroupInfo))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mGroupInfo", "./../../../dom/quota/OriginInfo.cpp"
, 73); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mGroupInfo" ")"
); do { MOZ_CrashSequence(__null, 73); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
74 return {mGroupInfo->mGroupInfoPair->Suffix(),
75 mGroupInfo->mGroupInfoPair->Group(),
76 mOrigin,
77 mStorageOrigin,
78 mIsPrivate,
79 mGroupInfo->mPersistenceType};
80}
81
82OriginStateMetadata OriginInfo::LockedFlattenToOriginStateMetadata() const {
83 AssertCurrentThreadOwnsQuotaMutex();
84
85 return {mAccessTime, mMaintenanceDate, mAccessed, mPersisted, LockedDirty()};
86}
87
88FullOriginMetadata OriginInfo::LockedFlattenToFullOriginMetadata() const {
89 AssertCurrentThreadOwnsQuotaMutex();
90
91 return {FlattenToOriginMetadata(), LockedFlattenToOriginStateMetadata(),
92 mClientUsages, mUsage, kCurrentQuotaVersion};
93}
94
95nsresult OriginInfo::LockedBindToStatement(
96 mozIStorageStatement* aStatement) const {
97 AssertCurrentThreadOwnsQuotaMutex();
98 MOZ_ASSERT(mGroupInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mGroupInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mGroupInfo))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mGroupInfo", "./../../../dom/quota/OriginInfo.cpp"
, 98); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mGroupInfo" ")"
); do { MOZ_CrashSequence(__null, 98); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
99
100 QM_TRY(MOZ_TO_RESULT(aStatement->BindInt32ByName({auto tryResult42 = (ToResult(aStatement->BindInt32ByName(
"repository_id"_ns, mGroupInfo->mPersistenceType))); static_assert
(std::is_empty_v<typename decltype(tryResult42)::ok_type>
); if ((__builtin_expect(!!(tryResult42.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindInt32ByName( \"repository_id\"_ns, mGroupInfo->mPersistenceType))"
, tryResult42.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 101, mozilla::dom::quota::Severity::Error); return tryResult42
.propagateErr(); }}
101 "repository_id"_ns, mGroupInfo->mPersistenceType))){auto tryResult42 = (ToResult(aStatement->BindInt32ByName(
"repository_id"_ns, mGroupInfo->mPersistenceType))); static_assert
(std::is_empty_v<typename decltype(tryResult42)::ok_type>
); if ((__builtin_expect(!!(tryResult42.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindInt32ByName( \"repository_id\"_ns, mGroupInfo->mPersistenceType))"
, tryResult42.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 101, mozilla::dom::quota::Severity::Error); return tryResult42
.propagateErr(); }}
;
102
103 QM_TRY(MOZ_TO_RESULT(aStatement->BindUTF8StringByName({auto tryResult43 = (ToResult(aStatement->BindUTF8StringByName
( "suffix"_ns, mGroupInfo->mGroupInfoPair->Suffix())));
static_assert(std::is_empty_v<typename decltype(tryResult43
)::ok_type>); if ((__builtin_expect(!!(tryResult43.isErr()
), 0))) { mozilla::dom::quota::HandleError("ToResult(aStatement->BindUTF8StringByName( \"suffix\"_ns, mGroupInfo->mGroupInfoPair->Suffix()))"
, tryResult43.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 104, mozilla::dom::quota::Severity::Error); return tryResult43
.propagateErr(); }}
104 "suffix"_ns, mGroupInfo->mGroupInfoPair->Suffix()))){auto tryResult43 = (ToResult(aStatement->BindUTF8StringByName
( "suffix"_ns, mGroupInfo->mGroupInfoPair->Suffix())));
static_assert(std::is_empty_v<typename decltype(tryResult43
)::ok_type>); if ((__builtin_expect(!!(tryResult43.isErr()
), 0))) { mozilla::dom::quota::HandleError("ToResult(aStatement->BindUTF8StringByName( \"suffix\"_ns, mGroupInfo->mGroupInfoPair->Suffix()))"
, tryResult43.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 104, mozilla::dom::quota::Severity::Error); return tryResult43
.propagateErr(); }}
;
105 QM_TRY(MOZ_TO_RESULT(aStatement->BindUTF8StringByName({auto tryResult44 = (ToResult(aStatement->BindUTF8StringByName
( "group_"_ns, mGroupInfo->mGroupInfoPair->Group()))); static_assert
(std::is_empty_v<typename decltype(tryResult44)::ok_type>
); if ((__builtin_expect(!!(tryResult44.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindUTF8StringByName( \"group_\"_ns, mGroupInfo->mGroupInfoPair->Group()))"
, tryResult44.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 106, mozilla::dom::quota::Severity::Error); return tryResult44
.propagateErr(); }}
106 "group_"_ns, mGroupInfo->mGroupInfoPair->Group()))){auto tryResult44 = (ToResult(aStatement->BindUTF8StringByName
( "group_"_ns, mGroupInfo->mGroupInfoPair->Group()))); static_assert
(std::is_empty_v<typename decltype(tryResult44)::ok_type>
); if ((__builtin_expect(!!(tryResult44.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindUTF8StringByName( \"group_\"_ns, mGroupInfo->mGroupInfoPair->Group()))"
, tryResult44.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 106, mozilla::dom::quota::Severity::Error); return tryResult44
.propagateErr(); }}
;
107 QM_TRY(MOZ_TO_RESULT(aStatement->BindUTF8StringByName("origin"_ns, mOrigin))){auto tryResult45 = (ToResult(aStatement->BindUTF8StringByName
("origin"_ns, mOrigin))); static_assert(std::is_empty_v<typename
decltype(tryResult45)::ok_type>); if ((__builtin_expect(!
!(tryResult45.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aStatement->BindUTF8StringByName(\"origin\"_ns, mOrigin))"
, tryResult45.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 107, mozilla::dom::quota::Severity::Error); return tryResult45
.propagateErr(); }}
;
108
109 MOZ_ASSERT(!mIsPrivate)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mIsPrivate)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!mIsPrivate))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("!mIsPrivate", "./../../../dom/quota/OriginInfo.cpp"
, 109); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mIsPrivate"
")"); do { MOZ_CrashSequence(__null, 109); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
110
111 nsCString clientUsagesText;
112 mClientUsages.Serialize(clientUsagesText);
113
114 QM_TRY(MOZ_TO_RESULT({auto tryResult46 = (ToResult(aStatement->BindUTF8StringByName
("client_usages"_ns, clientUsagesText))); static_assert(std::
is_empty_v<typename decltype(tryResult46)::ok_type>); if
((__builtin_expect(!!(tryResult46.isErr()), 0))) { mozilla::
dom::quota::HandleError("ToResult(aStatement->BindUTF8StringByName(\"client_usages\"_ns, clientUsagesText))"
, tryResult46.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 115, mozilla::dom::quota::Severity::Error); return tryResult46
.propagateErr(); }}
115 aStatement->BindUTF8StringByName("client_usages"_ns, clientUsagesText))){auto tryResult46 = (ToResult(aStatement->BindUTF8StringByName
("client_usages"_ns, clientUsagesText))); static_assert(std::
is_empty_v<typename decltype(tryResult46)::ok_type>); if
((__builtin_expect(!!(tryResult46.isErr()), 0))) { mozilla::
dom::quota::HandleError("ToResult(aStatement->BindUTF8StringByName(\"client_usages\"_ns, clientUsagesText))"
, tryResult46.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 115, mozilla::dom::quota::Severity::Error); return tryResult46
.propagateErr(); }}
;
116 QM_TRY(MOZ_TO_RESULT(aStatement->BindInt64ByName("usage"_ns, mUsage))){auto tryResult47 = (ToResult(aStatement->BindInt64ByName(
"usage"_ns, mUsage))); static_assert(std::is_empty_v<typename
decltype(tryResult47)::ok_type>); if ((__builtin_expect(!
!(tryResult47.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aStatement->BindInt64ByName(\"usage\"_ns, mUsage))"
, tryResult47.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 116, mozilla::dom::quota::Severity::Error); return tryResult47
.propagateErr(); }}
;
117 QM_TRY(MOZ_TO_RESULT({auto tryResult48 = (ToResult(aStatement->BindInt64ByName(
"last_access_time"_ns, mAccessTime))); static_assert(std::is_empty_v
<typename decltype(tryResult48)::ok_type>); if ((__builtin_expect
(!!(tryResult48.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aStatement->BindInt64ByName(\"last_access_time\"_ns, mAccessTime))"
, tryResult48.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 118, mozilla::dom::quota::Severity::Error); return tryResult48
.propagateErr(); }}
118 aStatement->BindInt64ByName("last_access_time"_ns, mAccessTime))){auto tryResult48 = (ToResult(aStatement->BindInt64ByName(
"last_access_time"_ns, mAccessTime))); static_assert(std::is_empty_v
<typename decltype(tryResult48)::ok_type>); if ((__builtin_expect
(!!(tryResult48.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aStatement->BindInt64ByName(\"last_access_time\"_ns, mAccessTime))"
, tryResult48.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 118, mozilla::dom::quota::Severity::Error); return tryResult48
.propagateErr(); }}
;
119 QM_TRY(MOZ_TO_RESULT(aStatement->BindInt32ByName("last_maintenance_date"_ns,{auto tryResult49 = (ToResult(aStatement->BindInt32ByName(
"last_maintenance_date"_ns, mMaintenanceDate))); static_assert
(std::is_empty_v<typename decltype(tryResult49)::ok_type>
); if ((__builtin_expect(!!(tryResult49.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindInt32ByName(\"last_maintenance_date\"_ns, mMaintenanceDate))"
, tryResult49.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 120, mozilla::dom::quota::Severity::Error); return tryResult49
.propagateErr(); }}
120 mMaintenanceDate))){auto tryResult49 = (ToResult(aStatement->BindInt32ByName(
"last_maintenance_date"_ns, mMaintenanceDate))); static_assert
(std::is_empty_v<typename decltype(tryResult49)::ok_type>
); if ((__builtin_expect(!!(tryResult49.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindInt32ByName(\"last_maintenance_date\"_ns, mMaintenanceDate))"
, tryResult49.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 120, mozilla::dom::quota::Severity::Error); return tryResult49
.propagateErr(); }}
;
121 OriginStateMetadata stateMetadata = LockedFlattenToOriginStateMetadata();
122 QM_TRY(MOZ_TO_RESULT(aStatement->BindInt32ByName({auto tryResult50 = (ToResult(aStatement->BindInt32ByName(
"metadata_flags"_ns, stateMetadata.ToMetadataFlags()))); static_assert
(std::is_empty_v<typename decltype(tryResult50)::ok_type>
); if ((__builtin_expect(!!(tryResult50.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindInt32ByName( \"metadata_flags\"_ns, stateMetadata.ToMetadataFlags()))"
, tryResult50.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 123, mozilla::dom::quota::Severity::Error); return tryResult50
.propagateErr(); }}
123 "metadata_flags"_ns, stateMetadata.ToMetadataFlags()))){auto tryResult50 = (ToResult(aStatement->BindInt32ByName(
"metadata_flags"_ns, stateMetadata.ToMetadataFlags()))); static_assert
(std::is_empty_v<typename decltype(tryResult50)::ok_type>
); if ((__builtin_expect(!!(tryResult50.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(aStatement->BindInt32ByName( \"metadata_flags\"_ns, stateMetadata.ToMetadataFlags()))"
, tryResult50.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 123, mozilla::dom::quota::Severity::Error); return tryResult50
.propagateErr(); }}
;
124
125 return NS_OK;
126}
127
128nsresult OriginInfo::UpdateDirtyMetadata(mozIStorageConnection* aConnection,
129 uint32_t aMetadataFlags,
130 int64_t aLastAccessTime) const {
131 MOZ_ASSERT(aConnection)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aConnection)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(aConnection))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("aConnection", "./../../../dom/quota/OriginInfo.cpp"
, 131); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aConnection"
")"); do { MOZ_CrashSequence(__null, 131); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
132
133 nsCOMPtr<mozIStorageStatement> stmt;
134 QM_TRY(MOZ_TO_RESULT(aConnection->CreateStatement({auto tryResult51 = (ToResult(aConnection->CreateStatement
( "UPDATE origin SET metadata_flags = :metadata_flags, " "last_access_time = :last_access_time "
"WHERE repository_id = :repository_id " "AND origin = :origin;"_ns
, getter_AddRefs(stmt)))); static_assert(std::is_empty_v<typename
decltype(tryResult51)::ok_type>); if ((__builtin_expect(!
!(tryResult51.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection->CreateStatement( \"UPDATE origin SET metadata_flags = :metadata_flags, \" \"last_access_time = :last_access_time \" \"WHERE repository_id = :repository_id \" \"AND origin = :origin;\"_ns, getter_AddRefs(stmt)))"
, tryResult51.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 139, mozilla::dom::quota::Severity::Error); return tryResult51
.propagateErr(); }}
135 "UPDATE origin SET metadata_flags = :metadata_flags, "{auto tryResult51 = (ToResult(aConnection->CreateStatement
( "UPDATE origin SET metadata_flags = :metadata_flags, " "last_access_time = :last_access_time "
"WHERE repository_id = :repository_id " "AND origin = :origin;"_ns
, getter_AddRefs(stmt)))); static_assert(std::is_empty_v<typename
decltype(tryResult51)::ok_type>); if ((__builtin_expect(!
!(tryResult51.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection->CreateStatement( \"UPDATE origin SET metadata_flags = :metadata_flags, \" \"last_access_time = :last_access_time \" \"WHERE repository_id = :repository_id \" \"AND origin = :origin;\"_ns, getter_AddRefs(stmt)))"
, tryResult51.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 139, mozilla::dom::quota::Severity::Error); return tryResult51
.propagateErr(); }}
136 "last_access_time = :last_access_time "{auto tryResult51 = (ToResult(aConnection->CreateStatement
( "UPDATE origin SET metadata_flags = :metadata_flags, " "last_access_time = :last_access_time "
"WHERE repository_id = :repository_id " "AND origin = :origin;"_ns
, getter_AddRefs(stmt)))); static_assert(std::is_empty_v<typename
decltype(tryResult51)::ok_type>); if ((__builtin_expect(!
!(tryResult51.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection->CreateStatement( \"UPDATE origin SET metadata_flags = :metadata_flags, \" \"last_access_time = :last_access_time \" \"WHERE repository_id = :repository_id \" \"AND origin = :origin;\"_ns, getter_AddRefs(stmt)))"
, tryResult51.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 139, mozilla::dom::quota::Severity::Error); return tryResult51
.propagateErr(); }}
137 "WHERE repository_id = :repository_id "{auto tryResult51 = (ToResult(aConnection->CreateStatement
( "UPDATE origin SET metadata_flags = :metadata_flags, " "last_access_time = :last_access_time "
"WHERE repository_id = :repository_id " "AND origin = :origin;"_ns
, getter_AddRefs(stmt)))); static_assert(std::is_empty_v<typename
decltype(tryResult51)::ok_type>); if ((__builtin_expect(!
!(tryResult51.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection->CreateStatement( \"UPDATE origin SET metadata_flags = :metadata_flags, \" \"last_access_time = :last_access_time \" \"WHERE repository_id = :repository_id \" \"AND origin = :origin;\"_ns, getter_AddRefs(stmt)))"
, tryResult51.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 139, mozilla::dom::quota::Severity::Error); return tryResult51
.propagateErr(); }}
138 "AND origin = :origin;"_ns,{auto tryResult51 = (ToResult(aConnection->CreateStatement
( "UPDATE origin SET metadata_flags = :metadata_flags, " "last_access_time = :last_access_time "
"WHERE repository_id = :repository_id " "AND origin = :origin;"_ns
, getter_AddRefs(stmt)))); static_assert(std::is_empty_v<typename
decltype(tryResult51)::ok_type>); if ((__builtin_expect(!
!(tryResult51.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection->CreateStatement( \"UPDATE origin SET metadata_flags = :metadata_flags, \" \"last_access_time = :last_access_time \" \"WHERE repository_id = :repository_id \" \"AND origin = :origin;\"_ns, getter_AddRefs(stmt)))"
, tryResult51.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 139, mozilla::dom::quota::Severity::Error); return tryResult51
.propagateErr(); }}
139 getter_AddRefs(stmt)))){auto tryResult51 = (ToResult(aConnection->CreateStatement
( "UPDATE origin SET metadata_flags = :metadata_flags, " "last_access_time = :last_access_time "
"WHERE repository_id = :repository_id " "AND origin = :origin;"_ns
, getter_AddRefs(stmt)))); static_assert(std::is_empty_v<typename
decltype(tryResult51)::ok_type>); if ((__builtin_expect(!
!(tryResult51.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(aConnection->CreateStatement( \"UPDATE origin SET metadata_flags = :metadata_flags, \" \"last_access_time = :last_access_time \" \"WHERE repository_id = :repository_id \" \"AND origin = :origin;\"_ns, getter_AddRefs(stmt)))"
, tryResult51.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 139, mozilla::dom::quota::Severity::Error); return tryResult51
.propagateErr(); }}
;
140
141 QM_TRY(MOZ_TO_RESULT({auto tryResult52 = (ToResult(stmt->BindInt32ByName("metadata_flags"_ns
, aMetadataFlags))); static_assert(std::is_empty_v<typename
decltype(tryResult52)::ok_type>); if ((__builtin_expect(!
!(tryResult52.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(stmt->BindInt32ByName(\"metadata_flags\"_ns, aMetadataFlags))"
, tryResult52.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 142, mozilla::dom::quota::Severity::Error); return tryResult52
.propagateErr(); }}
142 stmt->BindInt32ByName("metadata_flags"_ns, aMetadataFlags))){auto tryResult52 = (ToResult(stmt->BindInt32ByName("metadata_flags"_ns
, aMetadataFlags))); static_assert(std::is_empty_v<typename
decltype(tryResult52)::ok_type>); if ((__builtin_expect(!
!(tryResult52.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(stmt->BindInt32ByName(\"metadata_flags\"_ns, aMetadataFlags))"
, tryResult52.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 142, mozilla::dom::quota::Severity::Error); return tryResult52
.propagateErr(); }}
;
143 QM_TRY(MOZ_TO_RESULT({auto tryResult53 = (ToResult(stmt->BindInt64ByName("last_access_time"_ns
, aLastAccessTime))); static_assert(std::is_empty_v<typename
decltype(tryResult53)::ok_type>); if ((__builtin_expect(!
!(tryResult53.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(stmt->BindInt64ByName(\"last_access_time\"_ns, aLastAccessTime))"
, tryResult53.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 144, mozilla::dom::quota::Severity::Error); return tryResult53
.propagateErr(); }}
144 stmt->BindInt64ByName("last_access_time"_ns, aLastAccessTime))){auto tryResult53 = (ToResult(stmt->BindInt64ByName("last_access_time"_ns
, aLastAccessTime))); static_assert(std::is_empty_v<typename
decltype(tryResult53)::ok_type>); if ((__builtin_expect(!
!(tryResult53.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(stmt->BindInt64ByName(\"last_access_time\"_ns, aLastAccessTime))"
, tryResult53.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 144, mozilla::dom::quota::Severity::Error); return tryResult53
.propagateErr(); }}
;
145 QM_TRY(MOZ_TO_RESULT({auto tryResult54 = (ToResult(stmt->BindInt32ByName("repository_id"_ns
, mGroupInfo->mPersistenceType))); static_assert(std::is_empty_v
<typename decltype(tryResult54)::ok_type>); if ((__builtin_expect
(!!(tryResult54.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(stmt->BindInt32ByName(\"repository_id\"_ns, mGroupInfo->mPersistenceType))"
, tryResult54.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 146, mozilla::dom::quota::Severity::Error); return tryResult54
.propagateErr(); }}
146 stmt->BindInt32ByName("repository_id"_ns, mGroupInfo->mPersistenceType))){auto tryResult54 = (ToResult(stmt->BindInt32ByName("repository_id"_ns
, mGroupInfo->mPersistenceType))); static_assert(std::is_empty_v
<typename decltype(tryResult54)::ok_type>); if ((__builtin_expect
(!!(tryResult54.isErr()), 0))) { mozilla::dom::quota::HandleError
("ToResult(stmt->BindInt32ByName(\"repository_id\"_ns, mGroupInfo->mPersistenceType))"
, tryResult54.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 146, mozilla::dom::quota::Severity::Error); return tryResult54
.propagateErr(); }}
;
147 QM_TRY(MOZ_TO_RESULT(stmt->BindUTF8StringByName("origin"_ns, mOrigin))){auto tryResult55 = (ToResult(stmt->BindUTF8StringByName("origin"_ns
, mOrigin))); static_assert(std::is_empty_v<typename decltype
(tryResult55)::ok_type>); if ((__builtin_expect(!!(tryResult55
.isErr()), 0))) { mozilla::dom::quota::HandleError("ToResult(stmt->BindUTF8StringByName(\"origin\"_ns, mOrigin))"
, tryResult55.inspectErr(), "./../../../dom/quota/OriginInfo.cpp"
, 147, mozilla::dom::quota::Severity::Error); return tryResult55
.propagateErr(); }}
;
148
149 QM_TRY(MOZ_TO_RESULT(stmt->Execute())){auto tryResult56 = (ToResult(stmt->Execute())); static_assert
(std::is_empty_v<typename decltype(tryResult56)::ok_type>
); if ((__builtin_expect(!!(tryResult56.isErr()), 0))) { mozilla
::dom::quota::HandleError("ToResult(stmt->Execute())", tryResult56
.inspectErr(), "./../../../dom/quota/OriginInfo.cpp", 149, mozilla
::dom::quota::Severity::Error); return tryResult56.propagateErr
(); }}
;
150
151 return NS_OK;
152}
153
154void OriginInfo::LockedDecreaseUsage(Client::Type aClientType, int64_t aSize,
155 DirtyTrackingAutoLock& aProofOfLock) {
156 AssertCurrentThreadOwnsQuotaMutex();
157
158 MOZ_ASSERT(mClientUsages[aClientType].isSome())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mClientUsages[aClientType].isSome())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mClientUsages[aClientType].isSome
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("mClientUsages[aClientType].isSome()", "./../../../dom/quota/OriginInfo.cpp"
, 158); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mClientUsages[aClientType].isSome()"
")"); do { MOZ_CrashSequence(__null, 158); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
159 QM_ASSERT_NO_UNDERFLOW_2(mozilla::dom::quota::AssertNoUnderflow( mClientUsages[aClientType
].value(), aSize, nsDependentCString(__func__) + "::"_ns + nsAutoCString
("mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns
))
160 mClientUsages[aClientType].value(), aSize,mozilla::dom::quota::AssertNoUnderflow( mClientUsages[aClientType
].value(), aSize, nsDependentCString(__func__) + "::"_ns + nsAutoCString
("mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns
))
161 "mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns)mozilla::dom::quota::AssertNoUnderflow( mClientUsages[aClientType
].value(), aSize, nsDependentCString(__func__) + "::"_ns + nsAutoCString
("mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns
))
;
162 mClientUsages[aClientType] = Some(mClientUsages[aClientType].value() - aSize);
163
164 QM_ASSERT_NO_UNDERFLOW(mUsage, aSize)mozilla::dom::quota::AssertNoUnderflow( mUsage, aSize, nsDependentCString
(__func__) + "::"_ns + nsDependentCString("mUsage"))
;
165 mUsage -= aSize;
166 MakeDirty(aProofOfLock);
167
168 if (!LockedPersisted()) {
169 QM_ASSERT_NO_UNDERFLOW(mGroupInfo->mUsage, aSize)mozilla::dom::quota::AssertNoUnderflow( mGroupInfo->mUsage
, aSize, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("mGroupInfo->mUsage"))
;
170 mGroupInfo->mUsage -= aSize;
171 }
172
173 QuotaManager* quotaManager = QuotaManager::Get();
174 MOZ_ASSERT(quotaManager)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(quotaManager)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(quotaManager))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("quotaManager", "./../../../dom/quota/OriginInfo.cpp"
, 174); AnnotateMozCrashReason("MOZ_ASSERT" "(" "quotaManager"
")"); do { MOZ_CrashSequence(__null, 174); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
175
176 QM_ASSERT_NO_UNDERFLOW(quotaManager->mTemporaryStorageUsage, aSize)mozilla::dom::quota::AssertNoUnderflow( quotaManager->mTemporaryStorageUsage
, aSize, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("quotaManager->mTemporaryStorageUsage"))
;
177 quotaManager->mTemporaryStorageUsage -= aSize;
178}
179
180void OriginInfo::LockedResetUsageForClient(
181 Client::Type aClientType, DirtyTrackingAutoLock& aProofOfLock) {
182 AssertCurrentThreadOwnsQuotaMutex();
183
184 uint64_t size = mClientUsages[aClientType].valueOr(0);
185
186 mClientUsages[aClientType].reset();
187
188 QM_ASSERT_NO_UNDERFLOW(mUsage, size)mozilla::dom::quota::AssertNoUnderflow( mUsage, size, nsDependentCString
(__func__) + "::"_ns + nsDependentCString("mUsage"))
;
189 mUsage -= size;
190 MakeDirty(aProofOfLock);
191
192 if (!LockedPersisted()) {
193 QM_ASSERT_NO_UNDERFLOW(mGroupInfo->mUsage, size)mozilla::dom::quota::AssertNoUnderflow( mGroupInfo->mUsage
, size, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("mGroupInfo->mUsage"))
;
194 mGroupInfo->mUsage -= size;
195 }
196
197 QuotaManager* quotaManager = QuotaManager::Get();
198 MOZ_ASSERT(quotaManager)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(quotaManager)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(quotaManager))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("quotaManager", "./../../../dom/quota/OriginInfo.cpp"
, 198); AnnotateMozCrashReason("MOZ_ASSERT" "(" "quotaManager"
")"); do { MOZ_CrashSequence(__null, 198); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
199
200 QM_ASSERT_NO_UNDERFLOW(quotaManager->mTemporaryStorageUsage, size)mozilla::dom::quota::AssertNoUnderflow( quotaManager->mTemporaryStorageUsage
, size, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("quotaManager->mTemporaryStorageUsage"))
;
201 quotaManager->mTemporaryStorageUsage -= size;
202}
203
204UsageInfo OriginInfo::LockedGetUsageForClient(Client::Type aClientType) {
205 AssertCurrentThreadOwnsQuotaMutex();
206
207 // The current implementation of this method only supports DOMCACHE and LS,
208 // which only use DatabaseUsage. If this assertion is lifted, the logic below
209 // must be adapted.
210 MOZ_ASSERT(aClientType == Client::Type::DOMCACHE ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aClientType == Client::Type::DOMCACHE || aClientType
== Client::Type::LS || aClientType == Client::Type::FILESYSTEM
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aClientType == Client::Type::DOMCACHE || aClientType
== Client::Type::LS || aClientType == Client::Type::FILESYSTEM
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"aClientType == Client::Type::DOMCACHE || aClientType == Client::Type::LS || aClientType == Client::Type::FILESYSTEM"
, "./../../../dom/quota/OriginInfo.cpp", 212); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aClientType == Client::Type::DOMCACHE || aClientType == Client::Type::LS || aClientType == Client::Type::FILESYSTEM"
")"); do { MOZ_CrashSequence(__null, 212); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
211 aClientType == Client::Type::LS ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aClientType == Client::Type::DOMCACHE || aClientType
== Client::Type::LS || aClientType == Client::Type::FILESYSTEM
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aClientType == Client::Type::DOMCACHE || aClientType
== Client::Type::LS || aClientType == Client::Type::FILESYSTEM
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"aClientType == Client::Type::DOMCACHE || aClientType == Client::Type::LS || aClientType == Client::Type::FILESYSTEM"
, "./../../../dom/quota/OriginInfo.cpp", 212); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aClientType == Client::Type::DOMCACHE || aClientType == Client::Type::LS || aClientType == Client::Type::FILESYSTEM"
")"); do { MOZ_CrashSequence(__null, 212); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
212 aClientType == Client::Type::FILESYSTEM)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(aClientType == Client::Type::DOMCACHE || aClientType
== Client::Type::LS || aClientType == Client::Type::FILESYSTEM
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(aClientType == Client::Type::DOMCACHE || aClientType
== Client::Type::LS || aClientType == Client::Type::FILESYSTEM
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"aClientType == Client::Type::DOMCACHE || aClientType == Client::Type::LS || aClientType == Client::Type::FILESYSTEM"
, "./../../../dom/quota/OriginInfo.cpp", 212); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "aClientType == Client::Type::DOMCACHE || aClientType == Client::Type::LS || aClientType == Client::Type::FILESYSTEM"
")"); do { MOZ_CrashSequence(__null, 212); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
213
214 return UsageInfo{DatabaseUsageType{mClientUsages[aClientType]}};
215}
216
217void OriginInfo::LockedPersist(DirtyTrackingAutoLock& aProofOfLock) {
218 AssertCurrentThreadOwnsQuotaMutex();
219 MOZ_ASSERT(mGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(mGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"mGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT"
, "./../../../dom/quota/OriginInfo.cpp", 219); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "mGroupInfo->mPersistenceType == PERSISTENCE_TYPE_DEFAULT"
")"); do { MOZ_CrashSequence(__null, 219); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
220 MOZ_ASSERT(!mPersisted)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mPersisted)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!mPersisted))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("!mPersisted", "./../../../dom/quota/OriginInfo.cpp"
, 220); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mPersisted"
")"); do { MOZ_CrashSequence(__null, 220); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
221
222 mPersisted = true;
223 MakeDirty(aProofOfLock);
224
225 // Remove Usage from GroupInfo
226 QM_ASSERT_NO_UNDERFLOW(mGroupInfo->mUsage, mUsage)mozilla::dom::quota::AssertNoUnderflow( mGroupInfo->mUsage
, mUsage, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("mGroupInfo->mUsage"))
;
227 mGroupInfo->mUsage -= mUsage;
228}
229
230void OriginInfo::LockedTruncateUsages(Client::Type aClientType, uint64_t aDelta,
231 DirtyTrackingAutoLock& aProofOfLock) {
232 AssertCurrentThreadOwnsQuotaMutex();
233
234 QuotaManager* quotaManager = QuotaManager::Get();
235 MOZ_ASSERT(quotaManager)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(quotaManager)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(quotaManager))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("quotaManager", "./../../../dom/quota/OriginInfo.cpp"
, 235); AnnotateMozCrashReason("MOZ_ASSERT" "(" "quotaManager"
")"); do { MOZ_CrashSequence(__null, 235); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
236
237 QM_ASSERT_NO_UNDERFLOW(quotaManager->mTemporaryStorageUsage, aDelta)mozilla::dom::quota::AssertNoUnderflow( quotaManager->mTemporaryStorageUsage
, aDelta, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("quotaManager->mTemporaryStorageUsage"))
;
238 quotaManager->mTemporaryStorageUsage -= aDelta;
239
240 if (!LockedPersisted()) {
241 QM_ASSERT_NO_UNDERFLOW(mGroupInfo->mUsage, aDelta)mozilla::dom::quota::AssertNoUnderflow( mGroupInfo->mUsage
, aDelta, nsDependentCString(__func__) + "::"_ns + nsDependentCString
("mGroupInfo->mUsage"))
;
242 mGroupInfo->mUsage -= aDelta;
243 }
244
245 QM_ASSERT_NO_UNDERFLOW(mUsage, aDelta)mozilla::dom::quota::AssertNoUnderflow( mUsage, aDelta, nsDependentCString
(__func__) + "::"_ns + nsDependentCString("mUsage"))
;
246 mUsage -= aDelta;
247 MakeDirty(aProofOfLock);
248
249 MOZ_ASSERT(mClientUsages[aClientType].isSome())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mClientUsages[aClientType].isSome())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mClientUsages[aClientType].isSome
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("mClientUsages[aClientType].isSome()", "./../../../dom/quota/OriginInfo.cpp"
, 249); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mClientUsages[aClientType].isSome()"
")"); do { MOZ_CrashSequence(__null, 249); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
250 QM_ASSERT_NO_UNDERFLOW_2(mozilla::dom::quota::AssertNoUnderflow( mClientUsages[aClientType
].value(), aDelta, nsDependentCString(__func__) + "::"_ns + nsAutoCString
("mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns
))
251 mClientUsages[aClientType].value(), aDelta,mozilla::dom::quota::AssertNoUnderflow( mClientUsages[aClientType
].value(), aDelta, nsDependentCString(__func__) + "::"_ns + nsAutoCString
("mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns
))
252 "mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns)mozilla::dom::quota::AssertNoUnderflow( mClientUsages[aClientType
].value(), aDelta, nsDependentCString(__func__) + "::"_ns + nsAutoCString
("mClientUsages["_ns + Client::TypeToText(aClientType) + "]"_ns
))
;
253 mClientUsages[aClientType] =
254 Some(mClientUsages[aClientType].value() - aDelta);
255};
256
257Maybe<bool> OriginInfo::LockedUpdateUsages(
258 Client::Type aClientType, uint64_t aDelta,
259 DirtyTrackingAutoLock& aProofOfLock) {
260 AssertCurrentThreadOwnsQuotaMutex();
261
262 QuotaManager* quotaManager = QuotaManager::Get();
263 MOZ_ASSERT(quotaManager)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(quotaManager)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(quotaManager))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("quotaManager", "./../../../dom/quota/OriginInfo.cpp"
, 263); AnnotateMozCrashReason("MOZ_ASSERT" "(" "quotaManager"
")"); do { MOZ_CrashSequence(__null, 263); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
264
265 const auto& complementaryPersistenceTypes =
266 ComplementaryPersistenceTypes(mGroupInfo->mPersistenceType);
267
268 AssertNoOverflow(mClientUsages[aClientType].valueOr(0), aDelta);
269 uint64_t newClientUsage = mClientUsages[aClientType].valueOr(0) + aDelta;
270
271 AssertNoOverflow(mUsage, aDelta);
272 uint64_t newUsage = mUsage + aDelta;
273 MakeDirty(aProofOfLock);
274
275 // Temporary storage has no limit for origin usage (there's a group and the
276 // global limit though).
277
278 uint64_t newGroupUsage = mGroupInfo->mUsage;
279 if (!LockedPersisted()) {
280 AssertNoOverflow(mGroupInfo->mUsage, aDelta);
281 newGroupUsage += aDelta;
282
283 uint64_t groupUsage = mGroupInfo->mUsage;
284 for (const auto& complementaryPersistenceType :
285 complementaryPersistenceTypes) {
286 const auto& complementaryGroupInfo =
287 mGroupInfo->mGroupInfoPair->LockedGetGroupInfo(
288 complementaryPersistenceType);
289
290 if (complementaryGroupInfo) {
291 AssertNoOverflow(groupUsage, complementaryGroupInfo->mUsage);
292 groupUsage += complementaryGroupInfo->mUsage;
293 }
294 }
295
296 // Temporary storage has a hard limit for group usage (20 % of the global
297 // limit).
298 AssertNoOverflow(groupUsage, aDelta);
299 if (groupUsage + aDelta > quotaManager->GetGroupLimit()) {
300 return Some(false);
301 }
302 }
303
304 AssertNoOverflow(quotaManager->mTemporaryStorageUsage, aDelta);
305 int64_t newTemporaryStorageUsage =
306 quotaManager->mTemporaryStorageUsage + AssertedCast<int64_t>(aDelta);
307
308 if (newTemporaryStorageUsage <= quotaManager->mTemporaryStorageLimit) {
309 mClientUsages[aClientType] = Some(newClientUsage);
310
311 mUsage = newUsage;
312 if (!LockedPersisted()) {
313 mGroupInfo->mUsage = newGroupUsage;
314 }
315 quotaManager->mTemporaryStorageUsage = newTemporaryStorageUsage;
316
317 return Some(true);
318 }
319
320 return Nothing();
321}
322
323bool OriginInfo::LockedUpdateUsagesForEviction(
324 Client::Type aClientType, uint64_t aDelta,
325 DirtyTrackingAutoLock& aProofOfLock) {
326 AssertCurrentThreadOwnsQuotaMutex();
327
328 QuotaManager* quotaManager = QuotaManager::Get();
329 MOZ_ASSERT(quotaManager)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(quotaManager)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(quotaManager))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("quotaManager", "./../../../dom/quota/OriginInfo.cpp"
, 329); AnnotateMozCrashReason("MOZ_ASSERT" "(" "quotaManager"
")"); do { MOZ_CrashSequence(__null, 329); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
330
331 AssertNoOverflow(mUsage, aDelta);
332 uint64_t newUsage = mUsage + aDelta;
333 MakeDirty(aProofOfLock);
334
335 AssertNoOverflow(mClientUsages[aClientType].valueOr(0), aDelta);
336 uint64_t newClientUsage = mClientUsages[aClientType].valueOr(0) + aDelta;
337
338 AssertNoOverflow(quotaManager->mTemporaryStorageUsage, aDelta);
339 int64_t newTemporaryStorageUsage =
Value stored to 'newTemporaryStorageUsage' during its initialization is never read
340 quotaManager->mTemporaryStorageUsage + AssertedCast<int64_t>(aDelta);
341
342 uint64_t newGroupUsage = mGroupInfo->mUsage;
343 if (!LockedPersisted()) {
344 AssertNoOverflow(mGroupInfo->mUsage, aDelta);
345 newGroupUsage += aDelta;
346
347 uint64_t groupUsage = mGroupInfo->mUsage;
348
349 const auto& complementaryPersistenceTypes =
350 ComplementaryPersistenceTypes(mGroupInfo->mPersistenceType);
351 for (const auto& complementaryPersistenceType :
352 complementaryPersistenceTypes) {
353 const auto& complementaryGroupInfo =
354 mGroupInfo->mGroupInfoPair->LockedGetGroupInfo(
355 complementaryPersistenceType);
356
357 if (complementaryGroupInfo) {
358 AssertNoOverflow(groupUsage, complementaryGroupInfo->mUsage);
359 groupUsage += complementaryGroupInfo->mUsage;
360 }
361 }
362
363 AssertNoOverflow(groupUsage, aDelta);
364 if (groupUsage + aDelta > quotaManager->GetGroupLimit()) {
365 // Unfortunately some other thread increased the group usage in the
366 // meantime and we are not below the group limit anymore.
367 return false;
368 }
369 }
370
371 AssertNoOverflow(quotaManager->mTemporaryStorageUsage, aDelta);
372 newTemporaryStorageUsage =
373 quotaManager->mTemporaryStorageUsage + AssertedCast<int64_t>(aDelta);
374
375 NS_ASSERTION(newTemporaryStorageUsage <= quotaManager->mTemporaryStorageLimit,do { if (!(newTemporaryStorageUsage <= quotaManager->mTemporaryStorageLimit
)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "How come?!", "newTemporaryStorageUsage <= quotaManager->mTemporaryStorageLimit"
, "./../../../dom/quota/OriginInfo.cpp", 376); MOZ_PretendNoReturn
(); } } while (0)
376 "How come?!")do { if (!(newTemporaryStorageUsage <= quotaManager->mTemporaryStorageLimit
)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "How come?!", "newTemporaryStorageUsage <= quotaManager->mTemporaryStorageLimit"
, "./../../../dom/quota/OriginInfo.cpp", 376); MOZ_PretendNoReturn
(); } } while (0)
;
377
378 // Ok, we successfully freed enough space and the operation can continue
379 // without throwing the quota error.
380 mClientUsages[aClientType] = Some(newClientUsage);
381
382 mUsage = newUsage;
383 if (!LockedPersisted()) {
384 MOZ_ASSERT(mGroupInfo)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mGroupInfo)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mGroupInfo))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("mGroupInfo", "./../../../dom/quota/OriginInfo.cpp"
, 384); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mGroupInfo" ")"
); do { MOZ_CrashSequence(__null, 384); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
385 mGroupInfo->mUsage = newGroupUsage;
386 }
387 quotaManager->mTemporaryStorageUsage = newTemporaryStorageUsage;
388
389 return true;
390};
391
392void OriginInfo::MakeDirty(DirtyTrackingAutoLock& aProofOfLock) {
393 AssertCurrentThreadOwnsQuotaMutex();
394
395 mLastModifiedTime = TimeStamp::Now();
396 if (!mMetadataDirty) {
397 auto* const quotaManager = QuotaManager::Get();
398 MOZ_ASSERT(quotaManager)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(quotaManager)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(quotaManager))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("quotaManager", "./../../../dom/quota/OriginInfo.cpp"
, 398); AnnotateMozCrashReason("MOZ_ASSERT" "(" "quotaManager"
")"); do { MOZ_CrashSequence(__null, 398); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
399
400 quotaManager->RegisterDirtyOriginInfo(aProofOfLock);
401 mMetadataDirty = true;
402 }
403}
404
405void OriginInfo::LockedDirectoryCreated() {
406 AssertCurrentThreadOwnsQuotaMutex();
407 MOZ_ASSERT(!mDirectoryExists)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!mDirectoryExists)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!mDirectoryExists))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("!mDirectoryExists"
, "./../../../dom/quota/OriginInfo.cpp", 407); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!mDirectoryExists" ")"); do { MOZ_CrashSequence
(__null, 407); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
408
409 mDirectoryExists = true;
410}
411
412} // namespace mozilla::dom::quota
413
414#undef CHECK_USAGE