2013-03-26 11:13:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 19:32:37 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-26 11:13:17 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_quota_quotaobject_h__
|
|
|
|
#define mozilla_dom_quota_quotaobject_h__
|
|
|
|
|
|
|
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
|
|
|
|
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
|
2019-08-22 13:06:48 +00:00
|
|
|
#include "Client.h"
|
2013-09-11 04:18:36 +00:00
|
|
|
#include "PersistenceType.h"
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
class OriginInfo;
|
|
|
|
class QuotaManager;
|
|
|
|
|
|
|
|
class QuotaObject {
|
|
|
|
friend class OriginInfo;
|
|
|
|
friend class QuotaManager;
|
|
|
|
|
2017-04-26 13:43:44 +00:00
|
|
|
class StoragePressureRunnable;
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
public:
|
|
|
|
void AddRef();
|
|
|
|
|
|
|
|
void Release();
|
|
|
|
|
2016-03-15 06:00:37 +00:00
|
|
|
const nsAString& Path() const { return mPath; }
|
|
|
|
|
2015-02-16 17:48:14 +00:00
|
|
|
bool MaybeUpdateSize(int64_t aSize, bool aTruncate);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2017-07-10 09:02:44 +00:00
|
|
|
bool IncreaseSize(int64_t aDelta);
|
|
|
|
|
2016-03-15 06:00:37 +00:00
|
|
|
void DisableQuotaCheck();
|
|
|
|
|
|
|
|
void EnableQuotaCheck();
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
private:
|
2019-08-22 13:06:48 +00:00
|
|
|
QuotaObject(OriginInfo* aOriginInfo, Client::Type aClientType,
|
|
|
|
const nsAString& aPath, int64_t aSize)
|
2016-03-15 06:00:37 +00:00
|
|
|
: mOriginInfo(aOriginInfo),
|
|
|
|
mPath(aPath),
|
|
|
|
mSize(aSize),
|
2019-08-22 13:06:48 +00:00
|
|
|
mClientType(aClientType),
|
2016-03-15 06:00:37 +00:00
|
|
|
mQuotaCheckDisabled(false),
|
2018-04-18 16:19:13 +00:00
|
|
|
mWritingDone(false) {
|
2013-09-11 04:18:36 +00:00
|
|
|
MOZ_COUNT_CTOR(QuotaObject);
|
|
|
|
}
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2020-02-20 11:40:14 +00:00
|
|
|
MOZ_COUNTED_DTOR(QuotaObject)
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2014-01-13 18:27:19 +00:00
|
|
|
already_AddRefed<QuotaObject> LockedAddRef() {
|
|
|
|
AssertCurrentThreadOwnsQuotaMutex();
|
|
|
|
|
|
|
|
++mRefCnt;
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<QuotaObject> result = dont_AddRef(this);
|
2014-01-13 18:27:19 +00:00
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
2017-07-10 09:02:44 +00:00
|
|
|
bool LockedMaybeUpdateSize(int64_t aSize, bool aTruncate);
|
|
|
|
|
2013-07-19 02:21:20 +00:00
|
|
|
mozilla::ThreadSafeAutoRefCnt mRefCnt;
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
OriginInfo* mOriginInfo;
|
|
|
|
nsString mPath;
|
|
|
|
int64_t mSize;
|
2019-08-22 13:06:48 +00:00
|
|
|
Client::Type mClientType;
|
2016-03-15 06:00:37 +00:00
|
|
|
bool mQuotaCheckDisabled;
|
2018-04-18 16:19:13 +00:00
|
|
|
bool mWritingDone;
|
2013-03-26 11:13:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_quota_quotaobject_h__
|