#ifndef COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_UTILS_H_
#define COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_UTILS_H_
#include <stddef.h>
#include <memory>
#include <optional>
#include "components/download/database/download_db_entry.h"
#include "components/download/database/in_progress/download_entry.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_interrupt_reasons.h"
#include "components/download/public/common/download_item.h"
#include "components/download/public/common/download_item_impl.h"
#include "components/download/public/common/download_source.h"
#include "components/download/public/common/resume_mode.h"
#include "net/base/net_errors.h"
#include "net/cert/cert_status_flags.h"
#include "net/http/http_response_headers.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
namespace net {
class HttpRequestHeaders;
}
namespace network {
struct ResourceRequest;
}
namespace download {
struct DownloadCreateInfo;
struct DownloadSaveInfo;
class DownloadUrlParameters;
URLSecurityPolicy;
COMPONENTS_DOWNLOAD_EXPORT DownloadInterruptReason
HandleRequestCompletionStatus(net::Error error_code,
bool has_strong_validators,
net::CertStatus cert_status,
bool is_partial_request,
DownloadInterruptReason abort_reason);
COMPONENTS_DOWNLOAD_EXPORT DownloadInterruptReason
HandleSuccessfulServerResponse(const net::HttpResponseHeaders& http_headers,
DownloadSaveInfo* save_info,
bool fetch_error_body);
COMPONENTS_DOWNLOAD_EXPORT void HandleResponseHeaders(
const net::HttpResponseHeaders* headers,
DownloadCreateInfo* create_info);
COMPONENTS_DOWNLOAD_EXPORT std::unique_ptr<network::ResourceRequest>
CreateResourceRequest(DownloadUrlParameters* params);
COMPONENTS_DOWNLOAD_EXPORT int GetLoadFlags(DownloadUrlParameters* params,
bool has_upload_data);
COMPONENTS_DOWNLOAD_EXPORT std::unique_ptr<net::HttpRequestHeaders>
GetAdditionalRequestHeaders(DownloadUrlParameters* params);
COMPONENTS_DOWNLOAD_EXPORT DownloadDBEntry
CreateDownloadDBEntryFromItem(const DownloadItemImpl& item);
COMPONENTS_DOWNLOAD_EXPORT std::unique_ptr<DownloadEntry>
CreateDownloadEntryFromDownloadDBEntry(std::optional<DownloadDBEntry> entry);
COMPONENTS_DOWNLOAD_EXPORT uint64_t GetUniqueDownloadId();
COMPONENTS_DOWNLOAD_EXPORT ResumeMode
GetDownloadResumeMode(const GURL& url,
DownloadInterruptReason reason,
bool restart_required,
bool user_action_required);
COMPONENTS_DOWNLOAD_EXPORT bool IsDownloadDone(
const GURL& url,
DownloadItem::DownloadState state,
DownloadInterruptReason reason);
COMPONENTS_DOWNLOAD_EXPORT bool DeleteDownloadedFile(
const base::FilePath& path);
COMPONENTS_DOWNLOAD_EXPORT DownloadItem::DownloadRenameResult
RenameDownloadedFile(const base::FilePath& from_path,
const base::FilePath& display_name);
LocalPathCallback;
COMPONENTS_DOWNLOAD_EXPORT
void DetermineLocalPath(DownloadItem* download,
const base::FilePath& virtual_path,
LocalPathCallback callback);
constexpr char kDownloadContentValidationLengthFinchKey[] = …;
int64_t GetDownloadValidationLengthConfig();
constexpr char kExpiredDownloadDeleteTimeFinchKey[] = …;
constexpr char kOverwrittenDownloadDeleteTimeFinchKey[] = …;
constexpr char kDownloadFileBufferSizeFinchKey[] = …;
COMPONENTS_DOWNLOAD_EXPORT base::TimeDelta GetExpiredDownloadDeleteTime();
COMPONENTS_DOWNLOAD_EXPORT base::TimeDelta GetOverwrittenDownloadDeleteTime();
COMPONENTS_DOWNLOAD_EXPORT size_t GetDownloadFileBufferSize();
COMPONENTS_DOWNLOAD_EXPORT
bool IsInterruptedDownloadAutoResumable(download::DownloadItem* download_item,
int auto_resumption_size_limit);
COMPONENTS_DOWNLOAD_EXPORT
bool IsContentDispositionAttachmentInHead(
const network::mojom::URLResponseHead& response_head);
}
#endif