2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2022-04-18 10:07:08 +00:00
|
|
|
|
|
|
|
#pragma once
|
2023-11-06 13:27:14 +00:00
|
|
|
|
2022-04-18 10:07:08 +00:00
|
|
|
#include "common/HTTPDownloader.h"
|
2023-11-06 13:27:14 +00:00
|
|
|
|
2022-04-18 10:07:08 +00:00
|
|
|
#include <atomic>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
2023-11-06 13:23:44 +00:00
|
|
|
class HTTPDownloaderCurl final : public HTTPDownloader
|
2022-04-18 10:07:08 +00:00
|
|
|
{
|
2023-11-06 13:23:44 +00:00
|
|
|
public:
|
|
|
|
HTTPDownloaderCurl();
|
|
|
|
~HTTPDownloaderCurl() override;
|
2022-04-18 10:07:08 +00:00
|
|
|
|
2023-11-21 06:12:58 +00:00
|
|
|
bool Initialize(std::string user_agent);
|
2022-04-18 10:07:08 +00:00
|
|
|
|
2023-11-06 13:23:44 +00:00
|
|
|
protected:
|
|
|
|
Request* InternalCreateRequest() override;
|
|
|
|
void InternalPollRequests() override;
|
|
|
|
bool StartRequest(HTTPDownloader::Request* request) override;
|
|
|
|
void CloseRequest(HTTPDownloader::Request* request) override;
|
2022-04-18 10:07:08 +00:00
|
|
|
|
2023-11-06 13:23:44 +00:00
|
|
|
private:
|
|
|
|
struct Request : HTTPDownloader::Request
|
|
|
|
{
|
|
|
|
CURL* handle = nullptr;
|
|
|
|
};
|
2022-04-18 10:07:08 +00:00
|
|
|
|
2023-11-06 13:23:44 +00:00
|
|
|
static size_t WriteCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
|
2022-04-18 10:07:08 +00:00
|
|
|
|
2023-11-06 13:27:14 +00:00
|
|
|
CURLM* m_multi_handle = nullptr;
|
2023-11-06 13:23:44 +00:00
|
|
|
std::string m_user_agent;
|
|
|
|
};
|