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/. */
7 #ifndef DOM_QUOTA_GROUPINFOPAIR_H_
8 #define DOM_QUOTA_GROUPINFOPAIR_H_
10 #include "GroupInfo.h"
11 #include "mozilla/dom/quota/Assertions.h"
12 #include "mozilla/dom/quota/PersistenceType.h"
13 #include "nsISupportsImpl.h"
16 namespace mozilla::dom::quota
{
20 // XXX Consider a new name for this class, it has other data members now and an
21 // additional GroupInfo (it's not a pair of GroupInfo objects anymore).
24 GroupInfoPair(const nsACString
& aSuffix
, const nsACString
& aGroup
)
25 : mSuffix(aSuffix
), mGroup(aGroup
) {
26 MOZ_COUNT_CTOR(GroupInfoPair
);
29 MOZ_COUNTED_DTOR(GroupInfoPair
)
31 const nsCString
& Suffix() const { return mSuffix
; }
33 const nsCString
& Group() const { return mGroup
; }
35 RefPtr
<GroupInfo
> LockedGetGroupInfo(PersistenceType aPersistenceType
) {
36 AssertCurrentThreadOwnsQuotaMutex();
37 MOZ_ASSERT(aPersistenceType
!= PERSISTENCE_TYPE_PERSISTENT
);
39 return GetGroupInfoForPersistenceType(aPersistenceType
);
42 void LockedSetGroupInfo(PersistenceType aPersistenceType
,
43 GroupInfo
* aGroupInfo
) {
44 AssertCurrentThreadOwnsQuotaMutex();
45 MOZ_ASSERT(aPersistenceType
!= PERSISTENCE_TYPE_PERSISTENT
);
47 RefPtr
<GroupInfo
>& groupInfo
=
48 GetGroupInfoForPersistenceType(aPersistenceType
);
49 groupInfo
= aGroupInfo
;
52 void LockedClearGroupInfo(PersistenceType aPersistenceType
) {
53 AssertCurrentThreadOwnsQuotaMutex();
54 MOZ_ASSERT(aPersistenceType
!= PERSISTENCE_TYPE_PERSISTENT
);
56 RefPtr
<GroupInfo
>& groupInfo
=
57 GetGroupInfoForPersistenceType(aPersistenceType
);
61 bool LockedHasGroupInfos() {
62 AssertCurrentThreadOwnsQuotaMutex();
64 return mTemporaryStorageGroupInfo
|| mDefaultStorageGroupInfo
||
65 mPrivateStorageGroupInfo
;
69 RefPtr
<GroupInfo
>& GetGroupInfoForPersistenceType(
70 PersistenceType aPersistenceType
);
72 const nsCString mSuffix
;
73 const nsCString mGroup
;
74 RefPtr
<GroupInfo
> mTemporaryStorageGroupInfo
;
75 RefPtr
<GroupInfo
> mDefaultStorageGroupInfo
;
76 RefPtr
<GroupInfo
> mPrivateStorageGroupInfo
;
79 } // namespace mozilla::dom::quota
81 #endif // DOM_QUOTA_GROUPINFOPAIR_H_