2013-03-26 15:13:17 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-26 15:13:17 +04: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"
|
|
|
|
|
2013-09-11 08:18:36 +04:00
|
|
|
#include "PersistenceType.h"
|
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
class OriginInfo;
|
|
|
|
class QuotaManager;
|
|
|
|
|
|
|
|
class QuotaObject
|
|
|
|
{
|
|
|
|
friend class OriginInfo;
|
|
|
|
friend class QuotaManager;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void
|
|
|
|
AddRef();
|
|
|
|
|
|
|
|
void
|
|
|
|
Release();
|
|
|
|
|
2016-03-15 09:00:37 +03:00
|
|
|
const nsAString&
|
|
|
|
Path() const
|
|
|
|
{
|
|
|
|
return mPath;
|
|
|
|
}
|
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
bool
|
2015-02-16 20:48:14 +03:00
|
|
|
MaybeUpdateSize(int64_t aSize, bool aTruncate);
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2016-03-15 09:00:37 +03:00
|
|
|
void
|
|
|
|
DisableQuotaCheck();
|
|
|
|
|
|
|
|
void
|
|
|
|
EnableQuotaCheck();
|
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
private:
|
|
|
|
QuotaObject(OriginInfo* aOriginInfo, const nsAString& aPath, int64_t aSize)
|
2016-03-15 09:00:37 +03:00
|
|
|
: mOriginInfo(aOriginInfo)
|
|
|
|
, mPath(aPath)
|
|
|
|
, mSize(aSize)
|
|
|
|
, mQuotaCheckDisabled(false)
|
2013-09-11 08:18:36 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(QuotaObject);
|
|
|
|
}
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2013-09-11 08:18:36 +04:00
|
|
|
~QuotaObject()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(QuotaObject);
|
|
|
|
}
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2014-01-13 22:27:19 +04:00
|
|
|
already_AddRefed<QuotaObject>
|
|
|
|
LockedAddRef()
|
|
|
|
{
|
|
|
|
AssertCurrentThreadOwnsQuotaMutex();
|
|
|
|
|
|
|
|
++mRefCnt;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<QuotaObject> result = dont_AddRef(this);
|
2014-01-13 22:27:19 +04:00
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
2013-07-19 06:21:20 +04:00
|
|
|
mozilla::ThreadSafeAutoRefCnt mRefCnt;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
|
|
|
OriginInfo* mOriginInfo;
|
|
|
|
nsString mPath;
|
|
|
|
int64_t mSize;
|
2016-03-15 09:00:37 +03:00
|
|
|
|
|
|
|
bool mQuotaCheckDisabled;
|
2013-03-26 15:13:17 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_quota_quotaobject_h__
|