FrontendCommon: Add HTTPDownloaderUWP

This commit is contained in:
Connor McLaughlin
2021-07-04 19:14:41 +10:00
parent 99018b51b4
commit b0adcb5ea6
4 changed files with 212 additions and 1 deletions

View File

@ -0,0 +1,37 @@
#pragma once
#include "http_downloader.h"
#include "common/windows_headers.h"
#include <winrt/windows.Web.Http.h>
namespace FrontendCommon {
class HTTPDownloaderUWP final : public HTTPDownloader
{
public:
HTTPDownloaderUWP(std::string user_agent);
~HTTPDownloaderUWP() override;
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;
winrt::Windows::Web::Http::HttpClient client;
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Windows::Web::Http::HttpResponseMessage,
winrt::Windows::Web::Http::HttpProgress>
request_async{nullptr};
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Windows::Storage::Streams::IBuffer, uint64_t>
receive_async{};
};
std::string m_user_agent;
};
} // namespace FrontendCommon