From 3347919fb2242eebcd32c8cf6358807d15e63b39 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 11 Apr 2025 21:19:42 +0100 Subject: [PATCH] Codechange: Remove empty destructor and use member init for ClientNetworkContentSocketHandler. --- src/network/network_content.cpp | 19 ------------------- src/network/network_content.h | 19 ++++++++----------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index d93fc012e7..362fedfd62 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -707,25 +707,6 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr da #undef check_and_terminate } -/** - * Create a socket handler to handle the connection. - */ -ClientNetworkContentSocketHandler::ClientNetworkContentSocketHandler() : - NetworkContentSocketHandler(), - http_response_index(-2), - cur_file(std::nullopt), - cur_info(nullptr), - is_connecting(false), - is_cancelled(false) -{ - this->last_activity = std::chrono::steady_clock::now(); -} - -/** Clear up the mess ;) */ -ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler() -{ -} - /** Connect to the content server. */ class NetworkContentConnecter : public TCPConnecter { public: diff --git a/src/network/network_content.h b/src/network/network_content.h index e905b21b97..b00047abdd 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -63,18 +63,18 @@ struct ContentCallback { class ClientNetworkContentSocketHandler : public NetworkContentSocketHandler, ContentCallback, HTTPCallback { protected: using ContentIDList = std::vector; ///< List of content IDs to (possibly) select. - std::vector callbacks; ///< Callbacks to notify "the world" - ContentIDList requested; ///< ContentIDs we already requested (so we don't do it again) - ContentVector infos; ///< All content info we received + std::vector callbacks; ///< Callbacks to notify "the world" + ContentIDList requested; ///< ContentIDs we already requested (so we don't do it again) + ContentVector infos; ///< All content info we received std::unordered_multimap reverse_dependency_map; ///< Content reverse dependency map - std::vector http_response; ///< The HTTP response to the requests we've been doing - int http_response_index; ///< Where we are, in the response, with handling it + std::vector http_response; ///< The HTTP response to the requests we've been doing + int http_response_index = -2; ///< Where we are, in the response, with handling it std::optional cur_file; ///< Currently downloaded file std::unique_ptr cur_info; ///< Information about the currently downloaded file - bool is_connecting; ///< Whether we're connecting - bool is_cancelled; ///< Whether the download has been cancelled - std::chrono::steady_clock::time_point last_activity; ///< The last time there was network activity + bool is_connecting = false; ///< Whether we're connecting + bool is_cancelled = false; ///< Whether the download has been cancelled + std::chrono::steady_clock::time_point last_activity = std::chrono::steady_clock::now(); ///< The last time there was network activity friend class NetworkContentConnecter; @@ -103,9 +103,6 @@ public: /** The idle timeout; when to close the connection because it's idle. */ static constexpr std::chrono::seconds IDLE_TIMEOUT = std::chrono::seconds(60); - ClientNetworkContentSocketHandler(); - ~ClientNetworkContentSocketHandler(); - void Connect(); void SendReceive(); NetworkRecvStatus CloseConnection(bool error = true) override;