Line data Source code
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 mozilla_dom_quota_quotaobject_h__
8 : #define mozilla_dom_quota_quotaobject_h__
9 :
10 : #include "mozilla/dom/quota/QuotaCommon.h"
11 :
12 : #include "nsDataHashtable.h"
13 :
14 : #include "PersistenceType.h"
15 :
16 : BEGIN_QUOTA_NAMESPACE
17 :
18 : class OriginInfo;
19 : class QuotaManager;
20 :
21 : class QuotaObject
22 : {
23 : friend class OriginInfo;
24 : friend class QuotaManager;
25 :
26 : class StoragePressureRunnable;
27 :
28 : public:
29 : void
30 : AddRef();
31 :
32 : void
33 : Release();
34 :
35 : const nsAString&
36 0 : Path() const
37 : {
38 0 : return mPath;
39 : }
40 :
41 : bool
42 : MaybeUpdateSize(int64_t aSize, bool aTruncate);
43 :
44 : void
45 : DisableQuotaCheck();
46 :
47 : void
48 : EnableQuotaCheck();
49 :
50 : private:
51 0 : QuotaObject(OriginInfo* aOriginInfo, const nsAString& aPath, int64_t aSize)
52 0 : : mOriginInfo(aOriginInfo)
53 : , mPath(aPath)
54 : , mSize(aSize)
55 0 : , mQuotaCheckDisabled(false)
56 : {
57 0 : MOZ_COUNT_CTOR(QuotaObject);
58 0 : }
59 :
60 0 : ~QuotaObject()
61 0 : {
62 0 : MOZ_COUNT_DTOR(QuotaObject);
63 0 : }
64 :
65 : already_AddRefed<QuotaObject>
66 0 : LockedAddRef()
67 : {
68 0 : AssertCurrentThreadOwnsQuotaMutex();
69 :
70 0 : ++mRefCnt;
71 :
72 0 : RefPtr<QuotaObject> result = dont_AddRef(this);
73 0 : return result.forget();
74 : }
75 :
76 : mozilla::ThreadSafeAutoRefCnt mRefCnt;
77 :
78 : OriginInfo* mOriginInfo;
79 : nsString mPath;
80 : int64_t mSize;
81 :
82 : bool mQuotaCheckDisabled;
83 : };
84 :
85 : END_QUOTA_NAMESPACE
86 :
87 : #endif // mozilla_dom_quota_quotaobject_h__
|