#include "services/network/prefetch_url_loader_client.h"
#include <functional>
#include <optional>
#include "base/check.h"
#include "mojo/public/cpp/base/big_buffer.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "services/network/prefetch_cache.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/early_hints.mojom.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
namespace network {
namespace {
bool IsNiceResponseCode(int response_code) { … }
bool ShouldAbandonPrefetch(const mojom::URLResponseHead& head) { … }
}
PrefetchURLLoaderClient::PrefetchURLLoaderClient(
base::PassKey<PrefetchCache>,
const net::NetworkIsolationKey& nik,
const ResourceRequest& request,
base::TimeTicks expiry_time,
PrefetchCache* prefetch_cache)
: … { … }
PrefetchURLLoaderClient::~PrefetchURLLoaderClient() = default;
mojo::PendingReceiver<mojom::URLLoader>
PrefetchURLLoaderClient::GetURLLoaderPendingReceiver() { … }
mojo::PendingRemote<mojom::URLLoaderClient>
PrefetchURLLoaderClient::BindNewPipeAndPassRemote() { … }
void PrefetchURLLoaderClient::SetClient(
mojo::PendingRemote<mojom::URLLoaderClient> client) { … }
void PrefetchURLLoaderClient::OnReceiveEarlyHints(
mojom::EarlyHintsPtr early_hints) { … }
void PrefetchURLLoaderClient::OnReceiveResponse(
mojom::URLResponseHeadPtr head,
mojo::ScopedDataPipeConsumerHandle body,
std::optional<mojo_base::BigBuffer> cached_metadata) { … }
void PrefetchURLLoaderClient::OnReceiveRedirect(
const net::RedirectInfo& redirect_info,
mojom::URLResponseHeadPtr head) { … }
void PrefetchURLLoaderClient::OnUploadProgress(
int64_t current_position,
int64_t total_size,
OnUploadProgressCallback callback) { … }
void PrefetchURLLoaderClient::OnTransferSizeUpdated(
int32_t transfer_size_diff) { … }
void PrefetchURLLoaderClient::OnComplete(
const URLLoaderCompletionStatus& status) { … }
void PrefetchURLLoaderClient::OnDisconnect() { … }
template <typename Method, typename... Args>
void PrefetchURLLoaderClient::ForwardOrRecord(Method method, Args... args) { … }
template <typename Method, typename... Args>
void PrefetchURLLoaderClient::ForwardToRealClient(Method method, Args... args) { … }
}