#include "components/download/public/common/download_response_handler.h"
#include <memory>
#include "base/metrics/histogram_functions.h"
#include "components/download/public/common/download_stats.h"
#include "components/download/public/common/download_url_parameters.h"
#include "components/download/public/common/download_utils.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/record_ontransfersizeupdate_utils.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/early_hints.mojom.h"
namespace download {
namespace {
mojom::NetworkRequestStatus ConvertInterruptReasonToMojoNetworkRequestStatus(
DownloadInterruptReason reason) { … }
}
DownloadResponseHandler::DownloadResponseHandler(
network::ResourceRequest* resource_request,
Delegate* delegate,
std::unique_ptr<DownloadSaveInfo> save_info,
bool is_parallel_request,
bool is_transient,
bool fetch_error_body,
network::mojom::RedirectMode cross_origin_redirects,
const DownloadUrlParameters::RequestHeadersType& request_headers,
const std::string& request_origin,
DownloadSource download_source,
bool require_safety_checks,
std::vector<GURL> url_chain,
bool is_background_mode)
: … { … }
DownloadResponseHandler::~DownloadResponseHandler() = default;
void DownloadResponseHandler::OnReceiveEarlyHints(
network::mojom::EarlyHintsPtr early_hints) { … }
void DownloadResponseHandler::OnReceiveResponse(
network::mojom::URLResponseHeadPtr head,
mojo::ScopedDataPipeConsumerHandle body,
std::optional<mojo_base::BigBuffer> cached_metadata) { … }
std::unique_ptr<DownloadCreateInfo>
DownloadResponseHandler::CreateDownloadCreateInfo(
const network::mojom::URLResponseHead& head) { … }
void DownloadResponseHandler::OnReceiveRedirect(
const net::RedirectInfo& redirect_info,
network::mojom::URLResponseHeadPtr head) { … }
void DownloadResponseHandler::OnUploadProgress(
int64_t current_position,
int64_t total_size,
OnUploadProgressCallback callback) { … }
void DownloadResponseHandler::OnTransferSizeUpdated(
int32_t transfer_size_diff) { … }
void DownloadResponseHandler::OnComplete(
const network::URLLoaderCompletionStatus& status) { … }
void DownloadResponseHandler::OnResponseStarted(
mojom::DownloadStreamHandlePtr stream_handle) { … }
}