GroupInfoPairImpl.h (1806B)
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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef DOM_QUOTA_GROUPINFOPAIRIMPL_H_ 8 #define DOM_QUOTA_GROUPINFOPAIRIMPL_H_ 9 10 #include <algorithm> 11 12 #include "GroupInfo.h" 13 #include "GroupInfoPair.h" 14 #include "OriginInfo.h" 15 16 namespace mozilla::dom::quota { 17 18 template <typename Iterator, typename Pred> 19 void GroupInfoPair::MaybeInsertOriginInfos(Iterator aDest, Pred aPred) const { 20 const auto copy = [&aDest, &aPred](const GroupInfo& groupInfo) { 21 std::copy_if(groupInfo.mOriginInfos.cbegin(), groupInfo.mOriginInfos.cend(), 22 aDest, aPred); 23 }; 24 25 if (mTemporaryStorageGroupInfo) { 26 copy(*mTemporaryStorageGroupInfo); 27 } 28 if (mDefaultStorageGroupInfo) { 29 copy(*mDefaultStorageGroupInfo); 30 } 31 if (mPrivateStorageGroupInfo) { 32 copy(*mPrivateStorageGroupInfo); 33 } 34 } 35 36 template <typename Iterator> 37 void GroupInfoPair::MaybeInsertNonPersistedOriginInfos(Iterator aDest) const { 38 MaybeInsertOriginInfos(aDest, [](const auto& originInfo) { 39 return !originInfo->LockedPersisted(); 40 }); 41 } 42 43 template <typename Iterator> 44 void GroupInfoPair::MaybeInsertNonPersistedZeroUsageOriginInfos( 45 Iterator aDest, const Maybe<int64_t>& aCutoffAccessTime) const { 46 MaybeInsertOriginInfos(aDest, [aCutoffAccessTime](const auto& originInfo) { 47 return !originInfo->LockedPersisted() && originInfo->LockedUsage() == 0 && 48 (!aCutoffAccessTime || 49 originInfo->LockedAccessTime() < *aCutoffAccessTime); 50 }); 51 } 52 53 } // namespace mozilla::dom::quota 54 55 #endif // DOM_QUOTA_GROUPINFOPAIRIMPL_H_