blob: b5ca8e1dd52d7d5ff0bc3659831e3bb898f70976 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <string>
#include "base/sequence_checker.h"
namespace base {
template <typename T>
class NoDestructor;
} // namespace base
namespace crashpad {
class CrashReportDatabase;
} // namespace crashpad
namespace updater {
// This class manages interaction with the crash reporter.
class CrashClient {
CrashClient(const CrashClient&) = delete;
CrashClient& operator=(const CrashClient&) = delete;
static CrashClient* GetInstance();
// Retrieves the current guid associated with crashes. The value may be empty
// if no guid is associated.
static std::string GetClientId();
// Returns true if the upload of crashes is enabled.
static bool IsUploadEnabled();
// Initializes collection and upload of crash reports.
bool InitializeCrashReporting();
// Initializes the crash database only. Used in the crash reporter, which
// cannot connect to itself to upload its own crashes.
bool InitializeDatabaseOnly();
crashpad::CrashReportDatabase* database() { return database_.get(); }
friend class base::NoDestructor<CrashClient>;
std::unique_ptr<crashpad::CrashReportDatabase> database_;
} // namespace updater