#ifndef COMPONENTS_BROWSING_DATA_CONTENT_BROWSING_DATA_QUOTA_HELPER_H_
#define COMPONENTS_BROWSING_DATA_CONTENT_BROWSING_DATA_QUOTA_HELPER_H_
#include <stdint.h>
#include <list>
#include <string>
#include "base/functional/callback.h"
#include "base/memory/ref_counted.h"
#include "base/task/sequenced_task_runner_helpers.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
class BrowsingDataQuotaHelper;
namespace content {
class StoragePartition;
}
struct BrowsingDataQuotaHelperDeleter {
static void Destruct(const BrowsingDataQuotaHelper* helper);
};
class BrowsingDataQuotaHelper
: public base::RefCountedThreadSafe<BrowsingDataQuotaHelper,
BrowsingDataQuotaHelperDeleter> {
public:
struct QuotaInfo {
QuotaInfo();
explicit QuotaInfo(const blink::StorageKey& storage_key);
QuotaInfo(const blink::StorageKey& storage_key, int64_t usage);
~QuotaInfo();
bool operator<(const QuotaInfo& rhs) const;
bool operator==(const QuotaInfo& rhs) const;
blink::StorageKey storage_key;
int64_t usage = 0;
};
using QuotaInfoArray = std::list<QuotaInfo>;
using FetchResultCallback = base::OnceCallback<void(const QuotaInfoArray&)>;
static scoped_refptr<BrowsingDataQuotaHelper> Create(
content::StoragePartition* storage_partition);
BrowsingDataQuotaHelper(const BrowsingDataQuotaHelper&) = delete;
BrowsingDataQuotaHelper& operator=(const BrowsingDataQuotaHelper&) = delete;
virtual void StartFetching(FetchResultCallback callback) = 0;
virtual void DeleteStorageKeyData(const blink::StorageKey& storage_key,
base::OnceClosure completed) = 0;
protected:
BrowsingDataQuotaHelper();
virtual ~BrowsingDataQuotaHelper();
private:
friend class base::DeleteHelper<BrowsingDataQuotaHelper>;
friend struct BrowsingDataQuotaHelperDeleter;
};
#endif