#ifndef REMOTING_BASE_CRASH_BREAKPAD_UTILS_H_
#define REMOTING_BASE_CRASH_BREAKPAD_UTILS_H_
#include <atomic>
#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/process/process_handle.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/values.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_handle.h"
#endif
namespace remoting {
extern const char kBreakpadProductVersionKey[];
extern const char kBreakpadProcessStartTimeKey[];
extern const char kBreakpadProcessIdKey[];
extern const char kBreakpadProcessNameKey[];
extern const char kBreakpadProcessUptimeKey[];
extern base::FilePath GetMinidumpDirectoryPath();
extern bool CreateMinidumpDirectoryIfNeeded(
const base::FilePath& minidump_directory);
extern bool WriteMetadataForMinidump(const base::FilePath& minidump_file_path,
base::Value::Dict custom_client_info);
#if BUILDFLAG(IS_WIN)
extern const wchar_t kCrashServerPipeName[];
base::win::ScopedHandle GetClientHandleForCrashServerPipe();
#endif
class BreakpadHelper {
public:
BreakpadHelper();
BreakpadHelper(const BreakpadHelper&) = delete;
BreakpadHelper& operator=(const BreakpadHelper&) = delete;
~BreakpadHelper();
bool Initialize(const base::FilePath& minidump_directory);
void OnException();
bool OnMinidumpGenerated(const base::FilePath& minidump_file_path);
private:
std::atomic<bool> handling_exception_{false};
bool initialized_ = false;
base::ProcessId process_id_ = base::GetCurrentProcId();
base::FilePath process_name_;
base::Time process_start_time_ = base::Time::NowFromSystemTime();
};
}
#endif