#include "storage/browser/quota/usage_tracker.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "components/services/storage/public/cpp/buckets/constants.h"
#include "storage/browser/quota/client_usage_tracker.h"
#include "storage/browser/quota/quota_client_type.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
namespace storage {
struct UsageTracker::AccumulateInfo { … };
UsageTracker::UsageTracker(
QuotaManagerImpl* quota_manager_impl,
const base::flat_map<mojom::QuotaClient*, QuotaClientType>& client_types,
blink::mojom::StorageType type,
scoped_refptr<SpecialStoragePolicy> special_storage_policy)
: … { … }
UsageTracker::~UsageTracker() { … }
void UsageTracker::GetGlobalUsage(UsageCallback callback) { … }
void UsageTracker::GetStorageKeyUsageWithBreakdown(
const blink::StorageKey& storage_key,
UsageWithBreakdownCallback callback) { … }
void UsageTracker::GetBucketUsageWithBreakdown(
const BucketLocator& bucket,
UsageWithBreakdownCallback callback) { … }
void UsageTracker::UpdateBucketUsageCache(QuotaClientType client_type,
const BucketLocator& bucket,
std::optional<int64_t> delta) { … }
void UsageTracker::DeleteBucketCache(QuotaClientType client_type,
const BucketLocator& bucket) { … }
int64_t UsageTracker::GetCachedUsage() const { … }
std::map<std::string, int64_t> UsageTracker::GetCachedHostsUsage() const { … }
std::map<blink::StorageKey, int64_t> UsageTracker::GetCachedStorageKeysUsage()
const { … }
std::map<BucketLocator, int64_t> UsageTracker::GetCachedBucketsUsage() const { … }
void UsageTracker::SetUsageCacheEnabled(QuotaClientType client_type,
const blink::StorageKey& storage_key,
bool enabled) { … }
void UsageTracker::DidGetBucketsForType(
QuotaErrorOr<std::set<BucketInfo>> result) { … }
void UsageTracker::DidGetBucketsForStorageKey(
const blink::StorageKey& storage_key,
QuotaErrorOr<std::set<BucketInfo>> result) { … }
void UsageTracker::AccumulateClientGlobalUsage(
base::OnceClosure barrier_callback,
AccumulateInfo* info,
int64_t total_usage,
int64_t unlimited_usage) { … }
void UsageTracker::AccumulateClientUsageWithBreakdown(
base::OnceClosure barrier_callback,
AccumulateInfo* info,
QuotaClientType client,
int64_t total_usage,
int64_t unlimited_usage) { … }
void UsageTracker::FinallySendGlobalUsage(
std::unique_ptr<AccumulateInfo> info) { … }
void UsageTracker::FinallySendStorageKeyUsageWithBreakdown(
std::unique_ptr<AccumulateInfo> info,
const blink::StorageKey& storage_key) { … }
void UsageTracker::FinallySendBucketUsageWithBreakdown(
std::unique_ptr<AccumulateInfo> info,
const BucketLocator& bucket) { … }
ClientUsageTracker& UsageTracker::GetClient(QuotaClientType type) { … }
}