diff options
| author | 2019-06-05 15:57:48 -0400 | |
|---|---|---|
| committer | 2019-06-05 15:57:48 -0400 | |
| commit | 799302bc9d6edade951cf7746314d96d440c823c (patch) | |
| tree | 0fd074d6ab32ef2b2590bdd0c21302784976d653 /src/core/telemetry_session.cpp | |
| parent | Merge pull request #2545 from lioncash/timing (diff) | |
| parent | core/core: Remove unnecessary includes (diff) | |
| download | yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.gz yuzu-799302bc9d6edade951cf7746314d96d440c823c.tar.xz yuzu-799302bc9d6edade951cf7746314d96d440c823c.zip | |
Merge pull request #2526 from lioncash/global
core/telemetry_session: Remove usages of the global system accessor
Diffstat (limited to 'src/core/telemetry_session.cpp')
| -rw-r--r-- | src/core/telemetry_session.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 4b17bada5..90d06830f 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "common/file_util.h" | 12 | #include "common/file_util.h" |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | 14 | ||
| 15 | #include "core/core.h" | ||
| 16 | #include "core/file_sys/control_metadata.h" | 15 | #include "core/file_sys/control_metadata.h" |
| 17 | #include "core/file_sys/patch_manager.h" | 16 | #include "core/file_sys/patch_manager.h" |
| 18 | #include "core/loader/loader.h" | 17 | #include "core/loader/loader.h" |
| @@ -101,7 +100,30 @@ bool VerifyLogin(const std::string& username, const std::string& token) { | |||
| 101 | #endif | 100 | #endif |
| 102 | } | 101 | } |
| 103 | 102 | ||
| 104 | TelemetrySession::TelemetrySession() { | 103 | TelemetrySession::TelemetrySession() = default; |
| 104 | |||
| 105 | TelemetrySession::~TelemetrySession() { | ||
| 106 | // Log one-time session end information | ||
| 107 | const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| 108 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 109 | .count()}; | ||
| 110 | AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time); | ||
| 111 | |||
| 112 | #ifdef ENABLE_WEB_SERVICE | ||
| 113 | auto backend = std::make_unique<WebService::TelemetryJson>( | ||
| 114 | Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token); | ||
| 115 | #else | ||
| 116 | auto backend = std::make_unique<Telemetry::NullVisitor>(); | ||
| 117 | #endif | ||
| 118 | |||
| 119 | // Complete the session, submitting to the web service backend if necessary | ||
| 120 | field_collection.Accept(*backend); | ||
| 121 | if (Settings::values.enable_telemetry) { | ||
| 122 | backend->Complete(); | ||
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 | void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) { | ||
| 105 | // Log one-time top-level information | 127 | // Log one-time top-level information |
| 106 | AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId()); | 128 | AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId()); |
| 107 | 129 | ||
| @@ -112,26 +134,28 @@ TelemetrySession::TelemetrySession() { | |||
| 112 | AddField(Telemetry::FieldType::Session, "Init_Time", init_time); | 134 | AddField(Telemetry::FieldType::Session, "Init_Time", init_time); |
| 113 | 135 | ||
| 114 | u64 program_id{}; | 136 | u64 program_id{}; |
| 115 | const Loader::ResultStatus res{System::GetInstance().GetAppLoader().ReadProgramId(program_id)}; | 137 | const Loader::ResultStatus res{app_loader.ReadProgramId(program_id)}; |
| 116 | if (res == Loader::ResultStatus::Success) { | 138 | if (res == Loader::ResultStatus::Success) { |
| 117 | const std::string formatted_program_id{fmt::format("{:016X}", program_id)}; | 139 | const std::string formatted_program_id{fmt::format("{:016X}", program_id)}; |
| 118 | AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id); | 140 | AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id); |
| 119 | 141 | ||
| 120 | std::string name; | 142 | std::string name; |
| 121 | System::GetInstance().GetAppLoader().ReadTitle(name); | 143 | app_loader.ReadTitle(name); |
| 122 | 144 | ||
| 123 | if (name.empty()) { | 145 | if (name.empty()) { |
| 124 | auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata(); | 146 | auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata(); |
| 125 | if (nacp != nullptr) | 147 | if (nacp != nullptr) { |
| 126 | name = nacp->GetApplicationName(); | 148 | name = nacp->GetApplicationName(); |
| 149 | } | ||
| 127 | } | 150 | } |
| 128 | 151 | ||
| 129 | if (!name.empty()) | 152 | if (!name.empty()) { |
| 130 | AddField(Telemetry::FieldType::Session, "ProgramName", name); | 153 | AddField(Telemetry::FieldType::Session, "ProgramName", name); |
| 154 | } | ||
| 131 | } | 155 | } |
| 132 | 156 | ||
| 133 | AddField(Telemetry::FieldType::Session, "ProgramFormat", | 157 | AddField(Telemetry::FieldType::Session, "ProgramFormat", |
| 134 | static_cast<u8>(System::GetInstance().GetAppLoader().GetFileType())); | 158 | static_cast<u8>(app_loader.GetFileType())); |
| 135 | 159 | ||
| 136 | // Log application information | 160 | // Log application information |
| 137 | Telemetry::AppendBuildInfo(field_collection); | 161 | Telemetry::AppendBuildInfo(field_collection); |
| @@ -162,27 +186,6 @@ TelemetrySession::TelemetrySession() { | |||
| 162 | Settings::values.use_docked_mode); | 186 | Settings::values.use_docked_mode); |
| 163 | } | 187 | } |
| 164 | 188 | ||
| 165 | TelemetrySession::~TelemetrySession() { | ||
| 166 | // Log one-time session end information | ||
| 167 | const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| 168 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 169 | .count()}; | ||
| 170 | AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time); | ||
| 171 | |||
| 172 | #ifdef ENABLE_WEB_SERVICE | ||
| 173 | auto backend = std::make_unique<WebService::TelemetryJson>( | ||
| 174 | Settings::values.web_api_url, Settings::values.yuzu_username, Settings::values.yuzu_token); | ||
| 175 | #else | ||
| 176 | auto backend = std::make_unique<Telemetry::NullVisitor>(); | ||
| 177 | #endif | ||
| 178 | |||
| 179 | // Complete the session, submitting to web service if necessary | ||
| 180 | field_collection.Accept(*backend); | ||
| 181 | if (Settings::values.enable_telemetry) | ||
| 182 | backend->Complete(); | ||
| 183 | backend = nullptr; | ||
| 184 | } | ||
| 185 | |||
| 186 | bool TelemetrySession::SubmitTestcase() { | 189 | bool TelemetrySession::SubmitTestcase() { |
| 187 | #ifdef ENABLE_WEB_SERVICE | 190 | #ifdef ENABLE_WEB_SERVICE |
| 188 | auto backend = std::make_unique<WebService::TelemetryJson>( | 191 | auto backend = std::make_unique<WebService::TelemetryJson>( |