Bug 1526591 - Remove devtools.inspector.shapesHighlighter.enabled pref. r=rcaliman
[gecko.git] / dom / quota / QuotaObject.h
blob4fca229e24fefdd1915e16620ff2650635857e73
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 #include "mozilla/dom/quota/QuotaCommon.h"
12 #include "nsDataHashtable.h"
14 #include "PersistenceType.h"
16 BEGIN_QUOTA_NAMESPACE
18 class OriginInfo;
19 class QuotaManager;
21 class QuotaObject {
22 friend class OriginInfo;
23 friend class QuotaManager;
25 class StoragePressureRunnable;
27 public:
28 void AddRef();
30 void Release();
32 const nsAString& Path() const { return mPath; }
34 bool MaybeUpdateSize(int64_t aSize, bool aTruncate);
36 bool IncreaseSize(int64_t aDelta);
38 void DisableQuotaCheck();
40 void EnableQuotaCheck();
42 private:
43 QuotaObject(OriginInfo* aOriginInfo, const nsAString& aPath, int64_t aSize)
44 : mOriginInfo(aOriginInfo),
45 mPath(aPath),
46 mSize(aSize),
47 mQuotaCheckDisabled(false),
48 mWritingDone(false) {
49 MOZ_COUNT_CTOR(QuotaObject);
52 ~QuotaObject() { MOZ_COUNT_DTOR(QuotaObject); }
54 already_AddRefed<QuotaObject> LockedAddRef() {
55 AssertCurrentThreadOwnsQuotaMutex();
57 ++mRefCnt;
59 RefPtr<QuotaObject> result = dont_AddRef(this);
60 return result.forget();
63 bool LockedMaybeUpdateSize(int64_t aSize, bool aTruncate);
65 mozilla::ThreadSafeAutoRefCnt mRefCnt;
67 OriginInfo* mOriginInfo;
68 nsString mPath;
69 int64_t mSize;
71 bool mQuotaCheckDisabled;
72 bool mWritingDone;
75 END_QUOTA_NAMESPACE
77 #endif // mozilla_dom_quota_quotaobject_h__