/src/mozilla-central/dom/quota/QuotaObject.h
Line | Count | Source (jump to first uncovered line) |
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 | | Path() const |
37 | | { |
38 | | return mPath; |
39 | | } |
40 | | |
41 | | bool |
42 | | MaybeUpdateSize(int64_t aSize, bool aTruncate); |
43 | | |
44 | | bool |
45 | | IncreaseSize(int64_t aDelta); |
46 | | |
47 | | void |
48 | | DisableQuotaCheck(); |
49 | | |
50 | | void |
51 | | EnableQuotaCheck(); |
52 | | |
53 | | private: |
54 | | QuotaObject(OriginInfo* aOriginInfo, const nsAString& aPath, int64_t aSize) |
55 | | : mOriginInfo(aOriginInfo) |
56 | | , mPath(aPath) |
57 | | , mSize(aSize) |
58 | | , mQuotaCheckDisabled(false) |
59 | | , mWritingDone(false) |
60 | 0 | { |
61 | 0 | MOZ_COUNT_CTOR(QuotaObject); |
62 | 0 | } |
63 | | |
64 | | ~QuotaObject() |
65 | 0 | { |
66 | 0 | MOZ_COUNT_DTOR(QuotaObject); |
67 | 0 | } |
68 | | |
69 | | already_AddRefed<QuotaObject> |
70 | | LockedAddRef() |
71 | 0 | { |
72 | 0 | AssertCurrentThreadOwnsQuotaMutex(); |
73 | 0 |
|
74 | 0 | ++mRefCnt; |
75 | 0 |
|
76 | 0 | RefPtr<QuotaObject> result = dont_AddRef(this); |
77 | 0 | return result.forget(); |
78 | 0 | } |
79 | | |
80 | | bool |
81 | | LockedMaybeUpdateSize(int64_t aSize, bool aTruncate); |
82 | | |
83 | | mozilla::ThreadSafeAutoRefCnt mRefCnt; |
84 | | |
85 | | OriginInfo* mOriginInfo; |
86 | | nsString mPath; |
87 | | int64_t mSize; |
88 | | |
89 | | bool mQuotaCheckDisabled; |
90 | | bool mWritingDone; |
91 | | }; |
92 | | |
93 | | END_QUOTA_NAMESPACE |
94 | | |
95 | | #endif // mozilla_dom_quota_quotaobject_h__ |