#include "content/browser/cache_storage/cache_storage_dispatcher_host.h"
#include <optional>
#include <string>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "cache_storage_histogram_utils.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
#include "content/browser/cache_storage/cache_storage.h"
#include "content/browser/cache_storage/cache_storage_cache.h"
#include "content/browser/cache_storage/cache_storage_context_impl.h"
#include "content/browser/cache_storage/cache_storage_histogram_utils.h"
#include "content/browser/cache_storage/cache_storage_manager.h"
#include "content/browser/cache_storage/cache_storage_trace_utils.h"
#include "content/common/background_fetch/background_fetch_types.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "net/http/http_response_headers.h"
#include "services/network/public/cpp/cross_origin_embedder_policy.h"
#include "services/network/public/cpp/cross_origin_resource_policy.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "services/network/public/mojom/cross_origin_embedder_policy.mojom.h"
#include "third_party/blink/public/common/blob/blob_utils.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
CacheStorageError;
CacheStorageVerboseError;
CrossOriginEmbedderPolicy;
CrossOriginResourcePolicy;
DocumentIsolationPolicy;
FetchResponseType;
RequestMode;
bool OriginCanAccessCacheStorage(const url::Origin& origin) { … }
bool ValidBatchOperations(
const std::vector<blink::mojom::BatchOperationPtr>& batch_operations) { … }
blink::mojom::MatchResultPtr EagerlyReadResponseBody(
blink::mojom::FetchAPIResponsePtr response) { … }
bool ResponseBlockedByCrossOriginResourcePolicy(
const blink::mojom::FetchAPIResponse* response,
const url::Origin& document_origin,
const CrossOriginEmbedderPolicy& document_coep,
const mojo::Remote<network::mojom::CrossOriginEmbedderPolicyReporter>&
coep_reporter,
const DocumentIsolationPolicy& document_dip) { … }
}
class CacheStorageDispatcherHost::CacheImpl
: public blink::mojom::CacheStorageCache { … };
class CacheStorageDispatcherHost::CacheStorageImpl final
: public blink::mojom::CacheStorage { … };
CacheStorageDispatcherHost::CacheStorageDispatcherHost(
CacheStorageContextImpl* context,
scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy)
: … { … }
CacheStorageDispatcherHost::~CacheStorageDispatcherHost() { … }
void CacheStorageDispatcherHost::AddReceiver(
const CrossOriginEmbedderPolicy& cross_origin_embedder_policy,
mojo::PendingRemote<network::mojom::CrossOriginEmbedderPolicyReporter>
coep_reporter,
const DocumentIsolationPolicy& document_isolation_policy,
const blink::StorageKey& storage_key,
const std::optional<storage::BucketLocator>& bucket,
storage::mojom::CacheStorageOwner owner,
mojo::PendingReceiver<blink::mojom::CacheStorage> receiver) { … }
void CacheStorageDispatcherHost::AddCacheReceiver(
std::unique_ptr<CacheImpl> cache_impl,
mojo::PendingAssociatedReceiver<blink::mojom::CacheStorageCache> receiver) { … }
CacheStorageHandle CacheStorageDispatcherHost::OpenCacheStorage(
const storage::BucketLocator& bucket_locator,
storage::mojom::CacheStorageOwner owner) { … }
void CacheStorageDispatcherHost::UpdateOrCreateDefaultBucket(
const blink::StorageKey& storage_key,
base::OnceCallback<void(storage::QuotaErrorOr<storage::BucketInfo>)>
callback) { … }
bool CacheStorageDispatcherHost::WasNotifiedOfBucketDataDeletion(
const storage::BucketLocator& bucket_locator) { … }
void CacheStorageDispatcherHost::NotifyBucketDataDeleted(
const storage::BucketLocator& bucket_locator) { … }
}