diff --git a/Common/Net/HTTPRequest.cpp b/Common/Net/HTTPRequest.cpp index d606a6c946..28fa7332f7 100644 --- a/Common/Net/HTTPRequest.cpp +++ b/Common/Net/HTTPRequest.cpp @@ -9,7 +9,8 @@ namespace http { -Request::Request(RequestMethod method, const std::string &url, std::string_view name, bool *cancelled, ProgressBarMode mode) : method_(method), url_(url), name_(name), progress_(cancelled), progressBarMode_(mode) { +Request::Request(RequestMethod method, const std::string &url, std::string_view name, bool *cancelled, ProgressBarMode mode) + : method_(method), url_(url), name_(name), progress_(cancelled), progressBarMode_(mode) { INFO_LOG(Log::HTTP, "HTTP %s request: %s (%.*s)", RequestMethodToString(method), url.c_str(), (int)name.size(), name.data()); progress_.callback = [=](int64_t bytes, int64_t contentLength, bool done) { diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 5e01300afa..75a4770475 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -308,30 +308,14 @@ namespace Reporting bool SendReportRequest(const char *uri, const std::string &data, const std::string &mimeType, Buffer *output = NULL) { - http::Client http; - net::RequestProgress progress(&pendingMessagesDone); - Buffer theVoid = Buffer::Void(); - - http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION)); - - if (output == nullptr) - output = &theVoid; - - const char *serverHost = ServerHostname(); - if (!serverHost) - return false; - - if (http.Resolve(serverHost, ServerPort())) { - int result = -1; - if (http.Connect()) { - result = http.POST(http::RequestParams(uri), data, mimeType, output, &progress); - http.Disconnect(); - } - - return result >= 200 && result < 300; - } else { - return false; - } + char url[1024]; + const char *hostname = ServerHostname(); + int port = ServerPort(); + snprintf(url, sizeof(url), "http://%s:%d%s", hostname, port, uri); + g_DownloadManager.AsyncPostWithCallback(url, data, mimeType, http::ProgressBarMode::NONE, [=](http::Request &req) { + serverWorking = !req.Failed(); + }); + return true; } std::string StripTrailingNull(const std::string &str) @@ -514,12 +498,8 @@ namespace Reporting } } - int Process(int pos) - { - SetCurrentThreadName("Report"); - - AndroidJNIThreadContext jniContext; // destructor detaches - + // Not the thread func, but called from it. + int Process(int pos) { Payload &payload = payloadBuffer[pos]; Buffer output; @@ -671,7 +651,7 @@ namespace Reporting return -1; } - int ProcessPending() { + int SendPendingReportsThread() { SetCurrentThreadName("Report"); std::unique_lock guard(pendingMessageLock); @@ -714,7 +694,7 @@ namespace Reporting pendingMessageCond.notify_one(); if (!messageThread.joinable()) { - messageThread = std::thread(ProcessPending); + messageThread = std::thread(SendPendingReportsThread); } }