#include "client/crash_report_database.h"
#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mutex>
#include <tuple>
#include <utility>
#include "base/check_op.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "client/settings.h"
#include "util/file/directory_reader.h"
#include "util/file/filesystem.h"
#include "util/misc/initialization_state_dcheck.h"
#include "util/misc/memory_sanitizer.h"
namespace crashpad {
namespace {
base::FilePath ReplaceFinalExtension(
const base::FilePath& path,
const base::FilePath::StringType extension) { … }
UUID UUIDFromReportPath(const base::FilePath& path) { … }
OperationStatus;
constexpr base::FilePath::CharType kSettings[] = …);
constexpr base::FilePath::CharType kCrashReportExtension[] = …);
constexpr base::FilePath::CharType kMetadataExtension[] = …);
constexpr base::FilePath::CharType kLockExtension[] = …);
constexpr base::FilePath::CharType kNewDirectory[] = …);
constexpr base::FilePath::CharType kPendingDirectory[] = …);
constexpr base::FilePath::CharType kCompletedDirectory[] = …);
constexpr const base::FilePath::CharType* kReportDirectories[] = …;
enum { … };
struct ReportMetadata { … };
class ScopedLockFile { … };
}
class CrashReportDatabaseGeneric : public CrashReportDatabase { … };
CrashReportDatabaseGeneric::CrashReportDatabaseGeneric() = default;
CrashReportDatabaseGeneric::~CrashReportDatabaseGeneric() = default;
bool CrashReportDatabaseGeneric::Initialize(const base::FilePath& path,
bool may_create) { … }
std::unique_ptr<CrashReportDatabase> CrashReportDatabase::Initialize(
const base::FilePath& path) { … }
std::unique_ptr<CrashReportDatabase>
CrashReportDatabase::InitializeWithoutCreating(const base::FilePath& path) { … }
base::FilePath CrashReportDatabaseGeneric::DatabasePath() { … }
Settings* CrashReportDatabaseGeneric::GetSettings() { … }
OperationStatus CrashReportDatabaseGeneric::PrepareNewCrashReport(
std::unique_ptr<NewReport>* report) { … }
OperationStatus CrashReportDatabaseGeneric::FinishedWritingCrashReport(
std::unique_ptr<NewReport> report,
UUID* uuid) { … }
OperationStatus CrashReportDatabaseGeneric::LookUpCrashReport(const UUID& uuid,
Report* report) { … }
OperationStatus CrashReportDatabaseGeneric::GetPendingReports(
std::vector<Report>* reports) { … }
OperationStatus CrashReportDatabaseGeneric::GetCompletedReports(
std::vector<Report>* reports) { … }
OperationStatus CrashReportDatabaseGeneric::GetReportForUploading(
const UUID& uuid,
std::unique_ptr<const UploadReport>* report,
bool report_metrics) { … }
OperationStatus CrashReportDatabaseGeneric::SkipReportUpload(
const UUID& uuid,
Metrics::CrashSkippedReason reason) { … }
OperationStatus CrashReportDatabaseGeneric::DeleteReport(const UUID& uuid) { … }
OperationStatus CrashReportDatabaseGeneric::RequestUpload(const UUID& uuid) { … }
int CrashReportDatabaseGeneric::CleanDatabase(time_t lockfile_ttl) { … }
OperationStatus CrashReportDatabaseGeneric::RecordUploadAttempt(
UploadReport* report,
bool successful,
const std::string& id) { … }
base::FilePath CrashReportDatabaseGeneric::ReportPath(const UUID& uuid,
ReportState state) { … }
OperationStatus CrashReportDatabaseGeneric::LocateAndLockReport(
const UUID& uuid,
ReportState desired_state,
base::FilePath* path,
ScopedLockFile* lock_file) { … }
OperationStatus CrashReportDatabaseGeneric::CheckoutReport(
const UUID& uuid,
ReportState state,
base::FilePath* path,
ScopedLockFile* lock_file,
Report* report) { … }
OperationStatus CrashReportDatabaseGeneric::ReportsInState(
ReportState state,
std::vector<Report>* reports) { … }
int CrashReportDatabaseGeneric::CleanReportsInState(ReportState state,
time_t lockfile_ttl) { … }
void CrashReportDatabaseGeneric::CleanOrphanedAttachments() { … }
bool CrashReportDatabaseGeneric::ReadMetadata(const base::FilePath& path,
Report* report) { … }
bool CrashReportDatabaseGeneric::CleaningReadMetadata(
const base::FilePath& path,
Report* report) { … }
bool CrashReportDatabaseGeneric::WriteNewMetadata(const base::FilePath& path) { … }
bool CrashReportDatabaseGeneric::WriteMetadata(const base::FilePath& path,
const Report& report) { … }
}