2013-03-26 04:13:17 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2013-09-10 21:18:36 -07:00
|
|
|
#ifndef mozilla_dom_quota_usageinfo_h__
|
|
|
|
#define mozilla_dom_quota_usageinfo_h__
|
2013-03-26 04:13:17 -07:00
|
|
|
|
|
|
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
|
|
|
|
2013-08-12 02:51:49 -07:00
|
|
|
#include "mozilla/Atomics.h"
|
2013-03-26 04:13:17 -07:00
|
|
|
#include "Utilities.h"
|
|
|
|
|
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
2013-09-10 21:18:36 -07:00
|
|
|
class UsageInfo
|
2013-03-26 04:13:17 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-09-10 21:18:36 -07:00
|
|
|
UsageInfo()
|
2014-02-06 22:17:07 -08:00
|
|
|
: mCanceled(false), mDatabaseUsage(0), mFileUsage(0)
|
2013-03-26 04:13:17 -07:00
|
|
|
{ }
|
|
|
|
|
2013-09-10 21:18:36 -07:00
|
|
|
virtual ~UsageInfo()
|
2013-03-26 04:13:17 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
|
|
|
Canceled()
|
|
|
|
{
|
|
|
|
return mCanceled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AppendToDatabaseUsage(uint64_t aUsage)
|
|
|
|
{
|
|
|
|
IncrementUsage(&mDatabaseUsage, aUsage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AppendToFileUsage(uint64_t aUsage)
|
|
|
|
{
|
|
|
|
IncrementUsage(&mFileUsage, aUsage);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
DatabaseUsage()
|
|
|
|
{
|
|
|
|
return mDatabaseUsage;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
FileUsage()
|
|
|
|
{
|
|
|
|
return mFileUsage;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
TotalUsage()
|
|
|
|
{
|
|
|
|
uint64_t totalUsage = mDatabaseUsage;
|
|
|
|
IncrementUsage(&totalUsage, mFileUsage);
|
|
|
|
return totalUsage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ResetUsage()
|
|
|
|
{
|
|
|
|
mDatabaseUsage = 0;
|
|
|
|
mFileUsage = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-02-06 22:17:07 -08:00
|
|
|
mozilla::Atomic<bool> mCanceled;
|
2013-03-26 04:13:17 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t mDatabaseUsage;
|
|
|
|
uint64_t mFileUsage;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
2013-09-10 21:18:36 -07:00
|
|
|
#endif // mozilla_dom_quota_usageinfo_h__
|