#include "third_party/blink/renderer/modules/cache_storage/inspector_cache_storage_agent.h"
#include <sys/types.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/memory/scoped_refptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "services/network/public/mojom/fetch_api.mojom-blink.h"
#include "third_party/blink/public/common/cache_storage/cache_storage_utils.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/cache_storage/cache_storage.mojom-blink.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fileapi/file_reader_client.h"
#include "third_party/blink/renderer/core/fileapi/file_reader_loader.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/core/inspector/inspected_frames.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/modules/buckets/storage_bucket.h"
#include "third_party/blink/renderer/modules/buckets/storage_bucket_manager.h"
#include "third_party/blink/renderer/modules/cache_storage/cache_storage.h"
#include "third_party/blink/renderer/platform/blob/blob_data.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
#include "third_party/blink/renderer/platform/network/http_header_map.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
Array;
ProtocolCache;
Cache;
CachedResponse;
CachedResponseType;
DataEntry;
Header;
ProtocolResponse;
DeleteCacheCallback;
DeleteEntryCallback;
RequestCacheNamesCallback;
RequestEntriesCallback;
RequestCachedResponseCallback;
namespace blink {
namespace {
String BuildCacheId(const String& storage_key,
const std::optional<String>& storage_bucket_name,
const String& cache_name) { … }
ProtocolResponse ParseCacheId(const String& id,
String* storage_key,
std::optional<String>* storage_bucket_name,
String* cache_name) { … }
const char* CacheStorageErrorString(mojom::blink::CacheStorageError error) { … }
CachedResponseType ResponseTypeToString(
network::mojom::FetchResponseType type) { … }
struct DataRequestParams { … };
struct RequestResponse { … };
template <typename RequestCallback>
class RequestCallbackWrapper
: public RefCounted<RequestCallbackWrapper<RequestCallback>> { … };
class ResponsesAccumulator : public RefCounted<ResponsesAccumulator> { … };
class GetCacheKeysForRequestData { … };
class CachedResponseFileReaderLoaderClient final
: public GarbageCollected<CachedResponseFileReaderLoaderClient>,
public FileReaderClient { … };
}
InspectorCacheStorageAgent::InspectorCacheStorageAgent(InspectedFrames* frames)
: … { … }
InspectorCacheStorageAgent::~InspectorCacheStorageAgent() = default;
void InspectorCacheStorageAgent::Trace(Visitor* visitor) const { … }
base::expected<mojom::blink::CacheStorage*, protocol::Response>
InspectorCacheStorageAgent::GetCacheStorageRemote(
const String& storage_key,
const std::optional<String>& storage_bucket_name,
base::OnceCallback<void(ProtocolResponse)> on_failure_callback) { … }
base::expected<mojom::blink::CacheStorage*, protocol::Response>
InspectorCacheStorageAgent::GetCacheStorageRemoteForId(
const String& cache_id,
String& cache_name,
base::OnceCallback<void(ProtocolResponse)> on_failure_callback) { … }
void InspectorCacheStorageAgent::requestCacheNames(
protocol::Maybe<String> maybe_security_origin,
protocol::Maybe<String> maybe_storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> maybe_storage_bucket,
std::unique_ptr<RequestCacheNamesCallback> callback) { … }
void InspectorCacheStorageAgent::requestEntries(
const String& cache_id,
protocol::Maybe<int> skip_count,
protocol::Maybe<int> page_size,
protocol::Maybe<String> path_filter,
std::unique_ptr<RequestEntriesCallback> callback) { … }
void InspectorCacheStorageAgent::deleteCache(
const String& cache_id,
std::unique_ptr<DeleteCacheCallback> callback) { … }
void InspectorCacheStorageAgent::deleteEntry(
const String& cache_id,
const String& request,
std::unique_ptr<DeleteEntryCallback> callback) { … }
void InspectorCacheStorageAgent::requestCachedResponse(
const String& cache_id,
const String& request_url,
const std::unique_ptr<protocol::Array<protocol::CacheStorage::Header>>
request_headers,
std::unique_ptr<RequestCachedResponseCallback> callback) { … }
}