Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / quota / QuotaManagerImpl.h
blobaead8672fd2e9770ac7494ddfdaa56465770f2f0
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 DOM_QUOTA_QUOTAMANAGERIMPL_H_
8 #define DOM_QUOTA_QUOTAMANAGERIMPL_H_
10 #include "GroupInfo.h"
11 #include "GroupInfoPair.h"
12 #include "mozilla/dom/quota/QuotaManager.h"
13 #include "OriginInfo.h"
15 namespace mozilla::dom::quota {
17 template <typename P>
18 void QuotaManager::CollectPendingOriginsForListing(P aPredicate) {
19 MutexAutoLock lock(mQuotaMutex);
21 for (const auto& entry : mGroupInfoPairs) {
22 const auto& pair = entry.GetData();
24 MOZ_ASSERT(!entry.GetKey().IsEmpty());
25 MOZ_ASSERT(pair);
27 RefPtr<GroupInfo> groupInfo =
28 pair->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
29 if (groupInfo) {
30 for (const auto& originInfo : groupInfo->mOriginInfos) {
31 if (!originInfo->mDirectoryExists) {
32 aPredicate(originInfo);
39 template <typename F>
40 void QuotaManager::MaybeRecordQuotaManagerShutdownStepWith(F&& aFunc) {
41 // Callable on any thread.
43 if (IsShuttingDown()) {
44 RecordShutdownStep(Nothing{}, std::forward<F>(aFunc)());
48 } // namespace mozilla::dom::quota
50 #endif // DOM_QUOTA_QUOTAMANAGERIMPL_H_