#include "content/browser/web_package/prefetched_signed_exchange_cache.h"
#include <string_view>
#include <utility>
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/strings/string_util.h"
#include "components/link_header_util/link_header_util.h"
#include "content/browser/loader/cross_origin_read_blocking_checker.h"
#include "content/browser/loader/navigation_loader_interceptor.h"
#include "content/browser/loader/response_head_update_params.h"
#include "content/browser/navigation_subresource_loader_params.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/web_package/signed_exchange_inner_response_url_loader.h"
#include "content/browser/web_package/signed_exchange_reporter.h"
#include "content/browser/web_package/signed_exchange_utils.h"
#include "content/browser/web_package/subresource_signed_exchange_url_loader_factory.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/base/network_anonymization_key.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/http/http_cache.h"
#include "net/http/http_util.h"
#include "net/url_request/redirect_util.h"
#include "services/network/public/cpp/constants.h"
#include "services/network/public/cpp/cors/cors.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/initiator_lock_compatibility.h"
#include "services/network/public/cpp/orb/orb_api.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/single_request_url_loader_factory.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "services/network/public/mojom/restricted_cookie_manager.mojom.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "storage/browser/blob/blob_data_handle.h"
#include "storage/browser/blob/blob_impl.h"
#include "storage/browser/blob/mojo_blob_reader.h"
namespace content {
namespace {
constexpr size_t kMaxEntrySize = …;
class RedirectResponseURLLoader : public network::mojom::URLLoader { … };
class PrefetchedNavigationLoaderInterceptor
: public NavigationLoaderInterceptor { … };
bool CanStoreEntry(const PrefetchedSignedExchangeCacheEntry& entry) { … }
bool CanUseEntry(const PrefetchedSignedExchangeCacheEntry& entry,
const base::Time& verification_time) { … }
bool ExtractSHA256HashValueFromString(const std::string_view value,
net::SHA256HashValue* out) { … }
std::map<GURL, net::SHA256HashValue> GetAllowedAltSXG(
const PrefetchedSignedExchangeCacheEntry& main_exchange) { … }
}
PrefetchedSignedExchangeCache::PrefetchedSignedExchangeCache() = default;
PrefetchedSignedExchangeCache::~PrefetchedSignedExchangeCache() = default;
void PrefetchedSignedExchangeCache::Store(
std::unique_ptr<const PrefetchedSignedExchangeCacheEntry> cached_exchange) { … }
void PrefetchedSignedExchangeCache::Clear() { … }
std::unique_ptr<NavigationLoaderInterceptor>
PrefetchedSignedExchangeCache::MaybeCreateInterceptor(
const GURL& outer_url,
int frame_tree_node_id,
const net::IsolationInfo& isolation_info) { … }
const PrefetchedSignedExchangeCache::EntryMap&
PrefetchedSignedExchangeCache::GetExchanges() { … }
void PrefetchedSignedExchangeCache::RecordHistograms() { … }
std::vector<blink::mojom::PrefetchedSignedExchangeInfoPtr>
PrefetchedSignedExchangeCache::GetInfoListForNavigation(
const PrefetchedSignedExchangeCacheEntry& main_exchange,
const base::Time& verification_time,
int frame_tree_node_id,
const net::NetworkAnonymizationKey& network_anonymization_key) { … }
void PrefetchedSignedExchangeCache::AddObserverForTesting(
TestObserver* observer) { … }
void PrefetchedSignedExchangeCache::RemoveObserverForTesting(
const TestObserver* observer) { … }
}