#include "storage/browser/test/mock_quota_manager.h"
#include <limits>
#include <memory>
#include <tuple>
#include <utility>
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/test_waitable_event.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
#include "storage/browser/quota/quota_client_type.h"
StorageKey;
StorageType;
namespace storage {
MockQuotaManager::BucketData::BucketData(const BucketInfo& bucket,
QuotaClientTypes quota_client_types,
base::Time modified)
: … { … }
MockQuotaManager::BucketData::~BucketData() = default;
MockQuotaManager::BucketData::BucketData(MockQuotaManager::BucketData&&) =
default;
MockQuotaManager::BucketData& MockQuotaManager::BucketData::operator=(
MockQuotaManager::BucketData&&) = default;
MockQuotaManager::MockQuotaManager(
bool is_incognito,
const base::FilePath& profile_path,
scoped_refptr<base::SingleThreadTaskRunner> io_thread,
scoped_refptr<SpecialStoragePolicy> special_storage_policy)
: … { … }
void MockQuotaManager::UpdateOrCreateBucket(
const BucketInitParams& params,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
QuotaErrorOr<BucketInfo> MockQuotaManager::GetOrCreateBucketSync(
const BucketInitParams& params) { … }
void MockQuotaManager::CreateBucketForTesting(
const blink::StorageKey& storage_key,
const std::string& bucket_name,
blink::mojom::StorageType storage_type,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void MockQuotaManager::GetOrCreateBucketDeprecated(
const BucketInitParams& params,
blink::mojom::StorageType type,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void MockQuotaManager::GetBucketById(
const BucketId& bucket_id,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void MockQuotaManager::GetBucketByNameUnsafe(
const blink::StorageKey& storage_key,
const std::string& bucket_name,
blink::mojom::StorageType type,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void MockQuotaManager::GetBucketsForStorageKey(
const blink::StorageKey& storage_key,
blink::mojom::StorageType type,
base::OnceCallback<void(QuotaErrorOr<std::set<BucketInfo>>)> callback,
bool delete_expired) { … }
void MockQuotaManager::GetUsageAndQuota(const StorageKey& storage_key,
StorageType type,
UsageAndQuotaCallback callback) { … }
int64_t MockQuotaManager::GetQuotaForStorageKey(
const blink::StorageKey& storage_key,
blink::mojom::StorageType type,
const QuotaSettings& settings) const { … }
void MockQuotaManager::SetQuota(const StorageKey& storage_key,
StorageType type,
int64_t quota) { … }
bool MockQuotaManager::AddBucket(const BucketInfo& bucket,
QuotaClientTypes quota_client_types,
base::Time modified) { … }
BucketInfo MockQuotaManager::CreateBucket(const BucketInitParams& params,
StorageType type) { … }
bool MockQuotaManager::BucketHasData(const BucketInfo& bucket,
QuotaClientType quota_client) const { … }
int MockQuotaManager::BucketDataCount(QuotaClientType quota_client) { … }
void MockQuotaManager::GetBucketsModifiedBetween(StorageType type,
base::Time begin,
base::Time end,
GetBucketsCallback callback) { … }
void MockQuotaManager::DeleteBucketData(const BucketLocator& bucket,
QuotaClientTypes quota_client_types,
StatusCallback callback) { … }
void MockQuotaManager::FindAndDeleteBucketData(const StorageKey& storage_key,
const std::string& bucket_name,
StatusCallback callback) { … }
void MockQuotaManager::UpdateBucketPersistence(
BucketId bucket,
bool persistent,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void MockQuotaManager::OnClientWriteFailed(const StorageKey& storage_key) { … }
MockQuotaManager::~MockQuotaManager() = default;
QuotaErrorOr<BucketInfo> MockQuotaManager::FindBucketById(
const BucketId& bucket_id) { … }
QuotaErrorOr<BucketInfo> MockQuotaManager::FindBucket(
const blink::StorageKey& storage_key,
const std::string& bucket_name,
blink::mojom::StorageType type) { … }
QuotaErrorOr<BucketInfo> MockQuotaManager::FindBucket(
const BucketLocator& locator) { … }
QuotaErrorOr<BucketInfo> MockQuotaManager::FindAndUpdateBucket(
const BucketInitParams& params,
blink::mojom::StorageType type) { … }
void MockQuotaManager::UpdateUsage(const BucketLocator& bucket,
std::optional<int64_t> delta) { … }
void MockQuotaManager::DidGetBucket(
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback,
QuotaErrorOr<BucketInfo> result) { … }
void MockQuotaManager::DidGetModifiedInTimeRange(
GetBucketsCallback callback,
std::unique_ptr<std::set<BucketLocator>> buckets) { … }
void MockQuotaManager::DidDeleteBucketData(
StatusCallback callback,
blink::mojom::QuotaStatusCode status) { … }
}