#ifndef ASH_SYSTEM_DIAGNOSTICS_ROUTINE_LOG_H_
#define ASH_SYSTEM_DIAGNOSTICS_ROUTINE_LOG_H_
#include <memory>
#include <string>
#include "ash/ash_export.h"
#include "ash/system/diagnostics/async_log.h"
#include "ash/webui/diagnostics_ui/mojom/system_routine_controller.mojom.h"
#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
namespace ash {
namespace diagnostics {
class ASH_EXPORT RoutineLog {
public:
enum class RoutineCategory {
kNetwork = 0,
kSystem = 1,
};
explicit RoutineLog(const base::FilePath& log_base_path);
~RoutineLog();
RoutineLog(const RoutineLog&) = delete;
RoutineLog& operator=(const RoutineLog&) = delete;
void LogRoutineStarted(mojom::RoutineType type);
void LogRoutineCompleted(mojom::RoutineType type,
mojom::StandardRoutineResult result);
void LogRoutineCancelled(mojom::RoutineType type);
std::string GetContentsForCategory(const RoutineCategory category) const;
private:
void Append(mojom::RoutineType type, const std::string& text);
base::FilePath GetCategoryLogFilePath(const RoutineCategory category);
const base::FilePath log_base_path_;
base::flat_map<RoutineCategory, std::unique_ptr<AsyncLog>> logs_;
};
}
}
#endif