From 81988d96fe5c162f349494523c8055b9d8760847 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Fri, 19 Apr 2019 22:02:49 +0800 Subject: [PATCH] core/telemetry_session: Only create the backend when we really need it The backend is not used until we decide to submit the testcase/telemetry, and creating it early prevents users from updating the credentials properly while the games are running. --- src/core/telemetry_session.cpp | 20 +++++++++++--------- src/core/telemetry_session.h | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 8f9073dde..3e287f76d 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -92,13 +92,6 @@ bool VerifyLogin(const std::string& username, const std::string& token) { } TelemetrySession::TelemetrySession() { -#ifdef ENABLE_WEB_SERVICE - backend = std::make_unique(Settings::values.web_api_url, - Settings::values.citra_username, - Settings::values.citra_token); -#else - backend = std::make_unique(); -#endif // Log one-time top-level information AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId()); @@ -192,9 +185,15 @@ TelemetrySession::~TelemetrySession() { .count()}; AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time); +#ifdef ENABLE_WEB_SERVICE + auto backend = std::make_unique(Settings::values.web_api_url, + Settings::values.citra_username, + Settings::values.citra_token); +#else + auto backend = std::make_unique(); +#endif + // Complete the session, submitting to web service if necessary - // This is just a placeholder to wrap up the session once the core completes and this is - // destroyed. This will be moved elsewhere once we are actually doing real I/O with the service. field_collection.Accept(*backend); if (Settings::values.enable_telemetry) backend->Complete(); @@ -203,6 +202,9 @@ TelemetrySession::~TelemetrySession() { bool TelemetrySession::SubmitTestcase() { #ifdef ENABLE_WEB_SERVICE + auto backend = std::make_unique(Settings::values.web_api_url, + Settings::values.citra_username, + Settings::values.citra_token); field_collection.Accept(*backend); return backend->SubmitTestcase(); #else diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index 12bb04c43..b3637e723 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h @@ -39,7 +39,6 @@ public: private: Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session - std::unique_ptr backend; ///< Backend interface that logs fields }; /**