#include "storage/browser/quota/quota_manager_proxy.h"
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/time/time.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
#include "components/services/storage/public/cpp/constants.h"
#include "components/services/storage/public/mojom/quota_client.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "storage/browser/quota/quota_client_type.h"
#include "storage/browser/quota/quota_manager_impl.h"
#include "storage/browser/quota/quota_override_handle.h"
#include "storage/browser/quota/storage_directory_util.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
StorageKey;
namespace storage {
class ScopedWaitableEvent { … };
QuotaManagerProxy::QuotaManagerProxy(
QuotaManagerImpl* quota_manager_impl,
scoped_refptr<base::SequencedTaskRunner> quota_manager_impl_task_runner,
const base::FilePath& profile_path)
: … { … }
base::FilePath QuotaManagerProxy::GetBucketPath(const BucketLocator& bucket) { … }
base::FilePath QuotaManagerProxy::GetClientBucketPath(
const BucketLocator& bucket,
QuotaClientType client_type) { … }
void QuotaManagerProxy::RegisterClient(
mojo::PendingRemote<mojom::QuotaClient> client,
QuotaClientType client_type,
const std::vector<blink::mojom::StorageType>& storage_types) { … }
void QuotaManagerProxy::BindInternalsHandler(
mojo::PendingReceiver<mojom::QuotaInternalsHandler> receiver) { … }
void QuotaManagerProxy::UpdateOrCreateBucket(
const BucketInitParams& bucket_params,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
QuotaErrorOr<BucketInfo> QuotaManagerProxy::GetOrCreateBucketSync(
const BucketInitParams& params) { … }
void QuotaManagerProxy::GetOrCreateBucketDeprecated(
const BucketInitParams& params,
blink::mojom::StorageType storage_type,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void QuotaManagerProxy::CreateBucketForTesting(
const StorageKey& storage_key,
const std::string& bucket_name,
blink::mojom::StorageType storage_type,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void QuotaManagerProxy::GetBucketByNameUnsafe(
const StorageKey& storage_key,
const std::string& bucket_name,
blink::mojom::StorageType type,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void QuotaManagerProxy::GetBucketsForStorageKey(
const blink::StorageKey& storage_key,
blink::mojom::StorageType type,
bool delete_expired,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<std::set<BucketInfo>>)> callback) { … }
void QuotaManagerProxy::GetBucketById(
const BucketId& bucket_id,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void QuotaManagerProxy::DeleteBucket(
const StorageKey& storage_key,
const std::string& bucket_name,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(blink::mojom::QuotaStatusCode)> callback) { … }
void QuotaManagerProxy::UpdateBucketExpiration(
BucketId bucket,
const base::Time& expiration,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void QuotaManagerProxy::UpdateBucketPersistence(
BucketId bucket,
bool persistent,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<BucketInfo>)> callback) { … }
void QuotaManagerProxy::NotifyBucketAccessed(const BucketLocator& bucket,
base::Time access_time) { … }
void QuotaManagerProxy::NotifyBucketModified(
QuotaClientType client_id,
const BucketLocator& bucket,
std::optional<int64_t> delta,
base::Time modification_time,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceClosure callback) { … }
void QuotaManagerProxy::OnClientWriteFailed(const StorageKey& storage_key) { … }
void QuotaManagerProxy::SetUsageCacheEnabled(QuotaClientType client_id,
const StorageKey& storage_key,
blink::mojom::StorageType type,
bool enabled) { … }
void QuotaManagerProxy::GetUsageAndQuota(
const StorageKey& storage_key,
blink::mojom::StorageType type,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
UsageAndQuotaCallback callback) { … }
void QuotaManagerProxy::GetBucketUsageAndQuota(
BucketId bucket,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
UsageAndQuotaCallback callback) { … }
void QuotaManagerProxy::GetBucketSpaceRemaining(
const BucketLocator& bucket,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(QuotaErrorOr<int64_t>)> callback) { … }
void QuotaManagerProxy::IsStorageUnlimited(
const StorageKey& storage_key,
blink::mojom::StorageType type,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(bool)> callback) { … }
void QuotaManagerProxy::GetStorageKeyUsageWithBreakdown(
const blink::StorageKey& storage_key,
blink::mojom::StorageType type,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
UsageWithBreakdownCallback callback) { … }
std::unique_ptr<QuotaOverrideHandle>
QuotaManagerProxy::GetQuotaOverrideHandle() { … }
void QuotaManagerProxy::OverrideQuotaForStorageKey(
int handle_id,
const StorageKey& storage_key,
std::optional<int64_t> quota_size,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceClosure callback) { … }
void QuotaManagerProxy::WithdrawOverridesForHandle(int handle_id) { … }
void QuotaManagerProxy::GetOverrideHandleId(
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
base::OnceCallback<void(int)> callback) { … }
QuotaManagerProxy::~QuotaManagerProxy() = default;
void QuotaManagerProxy::InvalidateQuotaManagerImpl(
base::PassKey<QuotaManagerImpl>) { … }
void QuotaManagerProxy::AddObserver(
mojo::PendingRemote<storage::mojom::QuotaManagerObserver> observer) { … }
}