#include "content/browser/loader/prefetch_url_loader.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "content/browser/web_package/prefetched_signed_exchange_cache.h"
#include "content/browser/web_package/prefetched_signed_exchange_cache_adapter.h"
#include "content/browser/web_package/signed_exchange_prefetch_handler.h"
#include "content/browser/web_package/signed_exchange_utils.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/frame_accept_header.h"
#include "content/public/common/content_features.h"
#include "net/base/load_flags.h"
#include "net/base/network_anonymization_key.h"
#include "net/http/http_request_headers.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/record_ontransfersizeupdate_utils.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/early_hints.mojom.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "third_party/blink/public/common/features.h"
namespace content {
namespace {
constexpr char kSignedExchangeEnabledAcceptHeaderForCrossOriginPrefetch[] = …;
}
PrefetchURLLoader::PrefetchURLLoader(
int32_t request_id,
uint32_t options,
int frame_tree_node_id,
const network::ResourceRequest& resource_request,
const net::NetworkAnonymizationKey& network_anonymization_key,
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
scoped_refptr<network::SharedURLLoaderFactory> network_loader_factory,
URLLoaderThrottlesGetter url_loader_throttles_getter,
BrowserContext* browser_context,
scoped_refptr<PrefetchedSignedExchangeCache>
prefetched_signed_exchange_cache,
const std::string& accept_langs,
RecursivePrefetchTokenGenerator recursive_prefetch_token_generator)
: … { … }
PrefetchURLLoader::~PrefetchURLLoader() = default;
void PrefetchURLLoader::FollowRedirect(
const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers,
const net::HttpRequestHeaders& modified_cors_exempt_headers,
const std::optional<GURL>& new_url) { … }
void PrefetchURLLoader::SetPriority(net::RequestPriority priority,
int intra_priority_value) { … }
void PrefetchURLLoader::PauseReadingBodyFromNet() { … }
void PrefetchURLLoader::ResumeReadingBodyFromNet() { … }
void PrefetchURLLoader::OnReceiveEarlyHints(
network::mojom::EarlyHintsPtr early_hints) { … }
void PrefetchURLLoader::OnReceiveResponse(
network::mojom::URLResponseHeadPtr response,
mojo::ScopedDataPipeConsumerHandle body,
std::optional<mojo_base::BigBuffer> cached_metadata) { … }
void PrefetchURLLoader::OnReceiveRedirect(
const net::RedirectInfo& redirect_info,
network::mojom::URLResponseHeadPtr head) { … }
void PrefetchURLLoader::OnUploadProgress(int64_t current_position,
int64_t total_size,
base::OnceCallback<void()> callback) { … }
void PrefetchURLLoader::OnTransferSizeUpdated(int32_t transfer_size_diff) { … }
void PrefetchURLLoader::OnComplete(
const network::URLLoaderCompletionStatus& status) { … }
bool PrefetchURLLoader::SendEmptyBody() { … }
void PrefetchURLLoader::SendOnComplete(
const network::URLLoaderCompletionStatus& completion_status) { … }
void PrefetchURLLoader::OnNetworkConnectionError() { … }
}