#ifndef ASH_SYSTEM_DIAGNOSTICS_DIAGNOSTICS_LOG_CONTROLLER_H_
#define ASH_SYSTEM_DIAGNOSTICS_DIAGNOSTICS_LOG_CONTROLLER_H_
#include <memory>
#include <string>
#include "ash/ash_export.h"
#include "ash/login_status.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/system/diagnostics/diagnostics_browser_delegate.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
namespace ash {
namespace diagnostics {
class KeyboardInputLog;
class NetworkingLog;
class RoutineLog;
class TelemetryLog;
class ASH_EXPORT DiagnosticsLogController : SessionObserver {
public:
DiagnosticsLogController();
DiagnosticsLogController(const DiagnosticsLogController&) = delete;
DiagnosticsLogController& operator=(const DiagnosticsLogController&) = delete;
~DiagnosticsLogController() override;
static DiagnosticsLogController* Get();
static bool IsInitialized();
static void Initialize(std::unique_ptr<DiagnosticsBrowserDelegate> delegate);
std::string GenerateSessionStringOnBlockingPool() const;
bool GenerateSessionLogOnBlockingPool(const base::FilePath& save_file_path);
void ResetAndInitializeLogWriters();
void OnLoginStatusChanged(LoginStatus login_status) override;
KeyboardInputLog& GetKeyboardInputLog();
NetworkingLog& GetNetworkingLog();
RoutineLog& GetRoutineLog();
TelemetryLog& GetTelemetryLog();
void SetKeyboardInputLogForTesting(
std::unique_ptr<KeyboardInputLog> keyboard_input_log);
void SetNetworkingLogForTesting(std::unique_ptr<NetworkingLog> network_log);
void SetRoutineLogForTesting(std::unique_ptr<RoutineLog> routine_log);
void SetTelemetryLogForTesting(std::unique_ptr<TelemetryLog> telemetry_log);
private:
friend class DiagnosticsLogControllerTest;
void ResetLogBasePath();
void RemoveDirectory(const base::FilePath& path);
LoginStatus previous_status_;
std::unique_ptr<DiagnosticsBrowserDelegate> delegate_;
base::FilePath log_base_path_;
std::unique_ptr<KeyboardInputLog> keyboard_input_log_;
std::unique_ptr<NetworkingLog> networking_log_;
std::unique_ptr<RoutineLog> routine_log_;
std::unique_ptr<TelemetryLog> telemetry_log_;
SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<DiagnosticsLogController> weak_ptr_factory_{this};
};
}
}
#endif