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 mozilla_dom_quota_quotaobject_h__
8 #define mozilla_dom_quota_quotaobject_h__
15 #include "mozilla/AlreadyAddRefed.h"
16 #include "mozilla/RefPtr.h"
18 #include "nsISupports.h"
19 #include "nsStringFwd.h"
21 // XXX Avoid including this here by moving function bodies to the cpp file.
22 #include "mozilla/dom/quota/QuotaCommon.h"
24 namespace mozilla::dom::quota
{
30 friend class OriginInfo
;
31 friend class QuotaManager
;
33 class StoragePressureRunnable
;
40 const nsAString
& Path() const { return mPath
; }
42 [[nodiscard
]] bool MaybeUpdateSize(int64_t aSize
, bool aTruncate
);
44 bool IncreaseSize(int64_t aDelta
);
46 void DisableQuotaCheck();
48 void EnableQuotaCheck();
51 QuotaObject(OriginInfo
* aOriginInfo
, Client::Type aClientType
,
52 const nsAString
& aPath
, int64_t aSize
)
53 : mOriginInfo(aOriginInfo
),
56 mClientType(aClientType
),
57 mQuotaCheckDisabled(false),
59 MOZ_COUNT_CTOR(QuotaObject
);
62 MOZ_COUNTED_DTOR(QuotaObject
)
64 already_AddRefed
<QuotaObject
> LockedAddRef() {
65 AssertCurrentThreadOwnsQuotaMutex();
69 RefPtr
<QuotaObject
> result
= dont_AddRef(this);
70 return result
.forget();
73 bool LockedMaybeUpdateSize(int64_t aSize
, bool aTruncate
);
75 mozilla::ThreadSafeAutoRefCnt mRefCnt
;
77 OriginInfo
* mOriginInfo
;
80 Client::Type mClientType
;
81 bool mQuotaCheckDisabled
;
85 } // namespace mozilla::dom::quota
87 #endif // mozilla_dom_quota_quotaobject_h__