tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GroupInfo.h (1992B)


      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_GROUPINFO_H_
      8 #define DOM_QUOTA_GROUPINFO_H_
      9 
     10 #include "OriginInfo.h"
     11 #include "mozilla/NotNull.h"
     12 #include "mozilla/dom/quota/Assertions.h"
     13 #include "mozilla/dom/quota/PersistenceType.h"
     14 #include "nsISupportsImpl.h"
     15 #include "nsTArray.h"
     16 
     17 namespace mozilla::dom::quota {
     18 
     19 class GroupInfoPair;
     20 class OriginInfo;
     21 
     22 class GroupInfo final {
     23  friend class CanonicalQuotaObject;
     24  friend class GroupInfoPair;
     25  friend class OriginInfo;
     26  friend class QuotaManager;
     27 
     28 public:
     29  GroupInfo(GroupInfoPair* aGroupInfoPair, PersistenceType aPersistenceType)
     30      : mGroupInfoPair(aGroupInfoPair),
     31        mPersistenceType(aPersistenceType),
     32        mUsage(0) {
     33    MOZ_ASSERT(aPersistenceType != PERSISTENCE_TYPE_PERSISTENT);
     34 
     35    MOZ_COUNT_CTOR(GroupInfo);
     36  }
     37 
     38  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GroupInfo)
     39 
     40  PersistenceType GetPersistenceType() const { return mPersistenceType; }
     41 
     42 private:
     43  // Private destructor, to discourage deletion outside of Release():
     44  MOZ_COUNTED_DTOR(GroupInfo)
     45 
     46  already_AddRefed<OriginInfo> LockedGetOriginInfo(const nsACString& aOrigin);
     47 
     48  void LockedAddOriginInfo(NotNull<RefPtr<OriginInfo>>&& aOriginInfo);
     49 
     50  void LockedAdjustUsageForRemovedOriginInfo(const OriginInfo& aOriginInfo);
     51 
     52  void LockedRemoveOriginInfo(const nsACString& aOrigin);
     53 
     54  void LockedRemoveOriginInfos();
     55 
     56  bool LockedHasOriginInfos() {
     57    AssertCurrentThreadOwnsQuotaMutex();
     58 
     59    return !mOriginInfos.IsEmpty();
     60  }
     61 
     62  nsTArray<NotNull<RefPtr<OriginInfo>>> mOriginInfos;
     63 
     64  GroupInfoPair* mGroupInfoPair;
     65  PersistenceType mPersistenceType;
     66  uint64_t mUsage;
     67 };
     68 
     69 }  // namespace mozilla::dom::quota
     70 
     71 #endif  // DOM_QUOTA_GROUPINFO_H_