Bug 1704628 Part 4: Avoid use of ESC to close context menu in browser_toolbox_content...
[gecko.git] / dom / quota / QuotaObject.h
blob10d05e68da4cf2a0fd2b79df72ab58704a15066b
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__
10 // Local includes
11 #include "Client.h"
13 // Global includes
14 #include <cstdint>
15 #include "mozilla/AlreadyAddRefed.h"
16 #include "mozilla/RefPtr.h"
17 #include "nsCOMPtr.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 {
26 class OriginInfo;
27 class QuotaManager;
29 class QuotaObject {
30 friend class OriginInfo;
31 friend class QuotaManager;
33 class StoragePressureRunnable;
35 public:
36 void AddRef();
38 void Release();
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();
50 private:
51 QuotaObject(OriginInfo* aOriginInfo, Client::Type aClientType,
52 const nsAString& aPath, int64_t aSize)
53 : mOriginInfo(aOriginInfo),
54 mPath(aPath),
55 mSize(aSize),
56 mClientType(aClientType),
57 mQuotaCheckDisabled(false),
58 mWritingDone(false) {
59 MOZ_COUNT_CTOR(QuotaObject);
62 MOZ_COUNTED_DTOR(QuotaObject)
64 already_AddRefed<QuotaObject> LockedAddRef() {
65 AssertCurrentThreadOwnsQuotaMutex();
67 ++mRefCnt;
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;
78 nsString mPath;
79 int64_t mSize;
80 Client::Type mClientType;
81 bool mQuotaCheckDisabled;
82 bool mWritingDone;
85 } // namespace mozilla::dom::quota
87 #endif // mozilla_dom_quota_quotaobject_h__