Merge pull request #4793 from FearlessTobi/port-2526
Port yuzu-emu/yuzu#2526: "core/telemetry_session: Remove usages of the global system accessor"
This commit is contained in:
commit
e26d9f5ef1
@ -94,7 +94,6 @@ System::ResultStatus System::SingleStep() {
|
|||||||
|
|
||||||
System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) {
|
System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) {
|
||||||
app_loader = Loader::GetLoader(filepath);
|
app_loader = Loader::GetLoader(filepath);
|
||||||
|
|
||||||
if (!app_loader) {
|
if (!app_loader) {
|
||||||
LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);
|
LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);
|
||||||
return ResultStatus::ErrorGetLoader;
|
return ResultStatus::ErrorGetLoader;
|
||||||
@ -125,6 +124,7 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
|
|||||||
return init_result;
|
return init_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
telemetry_session->AddInitialInfo(*app_loader);
|
||||||
std::shared_ptr<Kernel::Process> process;
|
std::shared_ptr<Kernel::Process> process;
|
||||||
const Loader::ResultStatus load_result{app_loader->Load(process)};
|
const Loader::ResultStatus load_result{app_loader->Load(process)};
|
||||||
kernel->SetCurrentProcess(process);
|
kernel->SetCurrentProcess(process);
|
||||||
|
@ -91,7 +91,31 @@ bool VerifyLogin(const std::string& username, const std::string& token) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TelemetrySession::TelemetrySession() {
|
TelemetrySession::TelemetrySession() = default;
|
||||||
|
|
||||||
|
TelemetrySession::~TelemetrySession() {
|
||||||
|
// Log one-time session end information
|
||||||
|
const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
std::chrono::system_clock::now().time_since_epoch())
|
||||||
|
.count()};
|
||||||
|
AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time);
|
||||||
|
|
||||||
|
#ifdef ENABLE_WEB_SERVICE
|
||||||
|
auto backend = std::make_unique<WebService::TelemetryJson>(Settings::values.web_api_url,
|
||||||
|
Settings::values.citra_username,
|
||||||
|
Settings::values.citra_token);
|
||||||
|
#else
|
||||||
|
auto backend = std::make_unique<Telemetry::NullVisitor>();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Complete the session, submitting to the web service backend if necessary
|
||||||
|
field_collection.Accept(*backend);
|
||||||
|
if (Settings::values.enable_telemetry) {
|
||||||
|
backend->Complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) {
|
||||||
// Log one-time top-level information
|
// Log one-time top-level information
|
||||||
AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId());
|
AddField(Telemetry::FieldType::None, "TelemetryId", GetTelemetryId());
|
||||||
|
|
||||||
@ -101,7 +125,7 @@ TelemetrySession::TelemetrySession() {
|
|||||||
.count()};
|
.count()};
|
||||||
AddField(Telemetry::FieldType::Session, "Init_Time", init_time);
|
AddField(Telemetry::FieldType::Session, "Init_Time", init_time);
|
||||||
std::string program_name;
|
std::string program_name;
|
||||||
const Loader::ResultStatus res{System::GetInstance().GetAppLoader().ReadTitle(program_name)};
|
const Loader::ResultStatus res{app_loader.ReadTitle(program_name)};
|
||||||
if (res == Loader::ResultStatus::Success) {
|
if (res == Loader::ResultStatus::Success) {
|
||||||
AddField(Telemetry::FieldType::Session, "ProgramName", program_name);
|
AddField(Telemetry::FieldType::Session, "ProgramName", program_name);
|
||||||
}
|
}
|
||||||
@ -178,28 +202,6 @@ TelemetrySession::TelemetrySession() {
|
|||||||
AddField(Telemetry::FieldType::UserConfig, "System_RegionValue", Settings::values.region_value);
|
AddField(Telemetry::FieldType::UserConfig, "System_RegionValue", Settings::values.region_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
TelemetrySession::~TelemetrySession() {
|
|
||||||
// Log one-time session end information
|
|
||||||
const s64 shutdown_time{std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
||||||
std::chrono::system_clock::now().time_since_epoch())
|
|
||||||
.count()};
|
|
||||||
AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time);
|
|
||||||
|
|
||||||
#ifdef ENABLE_WEB_SERVICE
|
|
||||||
auto backend = std::make_unique<WebService::TelemetryJson>(Settings::values.web_api_url,
|
|
||||||
Settings::values.citra_username,
|
|
||||||
Settings::values.citra_token);
|
|
||||||
#else
|
|
||||||
auto backend = std::make_unique<Telemetry::NullVisitor>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Complete the session, submitting to web service if necessary
|
|
||||||
field_collection.Accept(*backend);
|
|
||||||
if (Settings::values.enable_telemetry)
|
|
||||||
backend->Complete();
|
|
||||||
backend = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TelemetrySession::SubmitTestcase() {
|
bool TelemetrySession::SubmitTestcase() {
|
||||||
#ifdef ENABLE_WEB_SERVICE
|
#ifdef ENABLE_WEB_SERVICE
|
||||||
auto backend = std::make_unique<WebService::TelemetryJson>(Settings::values.web_api_url,
|
auto backend = std::make_unique<WebService::TelemetryJson>(Settings::values.web_api_url,
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "common/telemetry.h"
|
#include "common/telemetry.h"
|
||||||
|
|
||||||
|
namespace Loader {
|
||||||
|
class AppLoader;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,11 +19,33 @@ namespace Core {
|
|||||||
* session, logging any one-time fields. Interfaces with the telemetry backend used for submitting
|
* session, logging any one-time fields. Interfaces with the telemetry backend used for submitting
|
||||||
* data to the web service. Submits session data on close.
|
* data to the web service. Submits session data on close.
|
||||||
*/
|
*/
|
||||||
class TelemetrySession : NonCopyable {
|
class TelemetrySession {
|
||||||
public:
|
public:
|
||||||
TelemetrySession();
|
explicit TelemetrySession();
|
||||||
~TelemetrySession();
|
~TelemetrySession();
|
||||||
|
|
||||||
|
TelemetrySession(const TelemetrySession&) = delete;
|
||||||
|
TelemetrySession& operator=(const TelemetrySession&) = delete;
|
||||||
|
|
||||||
|
TelemetrySession(TelemetrySession&&) = delete;
|
||||||
|
TelemetrySession& operator=(TelemetrySession&&) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the initial telemetry info necessary when starting up a title.
|
||||||
|
*
|
||||||
|
* This includes information such as:
|
||||||
|
* - Telemetry ID
|
||||||
|
* - Initialization time
|
||||||
|
* - Title ID
|
||||||
|
* - Title name
|
||||||
|
* - Title file format
|
||||||
|
* - Miscellaneous settings values.
|
||||||
|
*
|
||||||
|
* @param app_loader The application loader to use to retrieve
|
||||||
|
* title-specific information.
|
||||||
|
*/
|
||||||
|
void AddInitialInfo(Loader::AppLoader& app_loader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around the Telemetry::FieldCollection::AddField method.
|
* Wrapper around the Telemetry::FieldCollection::AddField method.
|
||||||
* @param type Type of the field to add.
|
* @param type Type of the field to add.
|
||||||
|
Loading…
Reference in New Issue
Block a user