2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2021-02-21 08:30:58 +00:00
|
|
|
#pragma once
|
|
|
|
#include "http_downloader.h"
|
|
|
|
|
|
|
|
#include "common/windows_headers.h"
|
|
|
|
|
|
|
|
#include <winhttp.h>
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
namespace Common {
|
2021-02-21 08:30:58 +00:00
|
|
|
|
|
|
|
class HTTPDownloaderWinHttp final : public HTTPDownloader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HTTPDownloaderWinHttp();
|
|
|
|
~HTTPDownloaderWinHttp() override;
|
|
|
|
|
2021-04-04 02:55:03 +00:00
|
|
|
bool Initialize(const char* user_agent);
|
2021-02-21 08:30:58 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Request* InternalCreateRequest() override;
|
|
|
|
void InternalPollRequests() override;
|
|
|
|
bool StartRequest(HTTPDownloader::Request* request) override;
|
|
|
|
void CloseRequest(HTTPDownloader::Request* request) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Request : HTTPDownloader::Request
|
|
|
|
{
|
|
|
|
std::wstring object_name;
|
|
|
|
HINTERNET hConnection = NULL;
|
|
|
|
HINTERNET hRequest = NULL;
|
|
|
|
u32 io_position = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void CALLBACK HTTPStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus,
|
|
|
|
LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
|
|
|
|
|
|
|
|
HINTERNET m_hSession = NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace FrontendCommon
|