mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-27 08:05:41 +00:00
40 lines
922 B
C++
40 lines
922 B
C++
#pragma once
|
|
#include "http_downloader.h"
|
|
#include "common/thirdparty/thread_pool.h"
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <curl/curl.h>
|
|
|
|
namespace FrontendCommon {
|
|
|
|
class HTTPDownloaderCurl final : public HTTPDownloader
|
|
{
|
|
public:
|
|
HTTPDownloaderCurl();
|
|
~HTTPDownloaderCurl() override;
|
|
|
|
bool Initialize();
|
|
|
|
protected:
|
|
Request* InternalCreateRequest() override;
|
|
void InternalPollRequests() override;
|
|
bool StartRequest(HTTPDownloader::Request* request) override;
|
|
void CloseRequest(HTTPDownloader::Request* request) override;
|
|
|
|
private:
|
|
struct Request : HTTPDownloader::Request
|
|
{
|
|
CURL* handle = nullptr;
|
|
std::atomic_bool closed{false};
|
|
};
|
|
|
|
static size_t WriteCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
|
|
void ProcessRequest(Request* req);
|
|
|
|
std::unique_ptr<cb::ThreadPool> m_thread_pool;
|
|
std::mutex m_cancel_mutex;
|
|
};
|
|
|
|
} // namespace FrontendCommon
|