2016-12-12 11:05:29 +01:00
|
|
|
// Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
|
|
|
|
// 2016 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.
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
#ifndef CEF_LIBCEF_COMMON_CRASH_REPORTER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_CRASH_REPORTER_CLIENT_H_
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
#include <string>
|
2024-04-23 22:06:00 +02:00
|
|
|
#include <string_view>
|
2017-05-17 11:29:28 +02:00
|
|
|
#include <vector>
|
2016-12-12 11:05:29 +01:00
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
#include "base/synchronization/lock.h"
|
2016-01-06 20:20:54 +01:00
|
|
|
#include "build/build_config.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_version.h"
|
2020-04-14 21:31:00 +02:00
|
|
|
#include "components/crash/core/app/crash_reporter_client.h"
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
// Global object that is instantiated in each process and configures crash
|
|
|
|
// reporting. On Windows this is created by the
|
|
|
|
// InitializeCrashReportingForProcess() method called from chrome_elf. On
|
|
|
|
// Linux and macOS this is created by crash_reporting::BasicStartupComplete().
|
2014-09-27 01:48:19 +02:00
|
|
|
class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
|
2013-11-21 23:43:36 +01:00
|
|
|
public:
|
2014-09-27 01:48:19 +02:00
|
|
|
CefCrashReporterClient();
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
CefCrashReporterClient(const CefCrashReporterClient&) = delete;
|
|
|
|
CefCrashReporterClient& operator=(const CefCrashReporterClient&) = delete;
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefCrashReporterClient() override;
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
// Reads the crash config file and returns true on success. Failure to read
|
|
|
|
// the crash config file will disable crash reporting. This method should be
|
|
|
|
// called immediately after the CefCrashReporterClient instance is created.
|
|
|
|
bool ReadCrashConfigFile();
|
|
|
|
bool HasCrashConfigFile() const;
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2016-12-12 11:05:29 +01:00
|
|
|
// Called from chrome_elf (chrome_elf/crash/crash_helper.cc) to instantiate
|
|
|
|
// a process wide instance of CefCrashReporterClient and initialize crash
|
|
|
|
// reporting for the process. The instance is leaked.
|
|
|
|
// crash_reporting_win::InitializeCrashReportingForModule() will be called
|
|
|
|
// later from crash_reporting::PreSandboxStartup() to read global state into
|
|
|
|
// the module address space.
|
|
|
|
static void InitializeCrashReportingForProcess();
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
bool GetAlternativeCrashDumpLocation(std::wstring* crash_dir) override;
|
|
|
|
void GetProductNameAndVersion(const std::wstring& exe_path,
|
|
|
|
std::wstring* product_name,
|
|
|
|
std::wstring* version,
|
|
|
|
std::wstring* special_build,
|
|
|
|
std::wstring* channel_name) override;
|
|
|
|
bool GetCrashDumpLocation(std::wstring* crash_dir) override;
|
|
|
|
bool GetCrashMetricsLocation(std::wstring* metrics_dir) override;
|
2022-01-24 18:58:02 +01:00
|
|
|
#elif BUILDFLAG(IS_POSIX)
|
2014-11-12 20:25:15 +01:00
|
|
|
void GetProductNameAndVersion(const char** product_name,
|
|
|
|
const char** version) override;
|
2018-05-21 14:54:08 +02:00
|
|
|
void GetProductNameAndVersion(std::string* product_name,
|
|
|
|
std::string* version,
|
|
|
|
std::string* channel) override;
|
2016-12-12 11:05:29 +01:00
|
|
|
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
|
2022-01-24 18:58:02 +01:00
|
|
|
#endif // BUILDFLAG(IS_POSIX)
|
2016-12-12 11:05:29 +01:00
|
|
|
|
|
|
|
// All of these methods must return true to enable crash report upload.
|
|
|
|
bool GetCollectStatsConsent() override;
|
|
|
|
bool GetCollectStatsInSample() override;
|
|
|
|
bool ReportingIsEnforcedByPolicy(bool* crashpad_enabled) override;
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2020-06-09 19:48:00 +02:00
|
|
|
std::string GetUploadUrl() override;
|
2016-12-12 11:05:29 +01:00
|
|
|
void GetCrashOptionalArguments(std::vector<std::string>* arguments) override;
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2021-03-04 23:36:57 +01:00
|
|
|
std::wstring GetCrashExternalHandler(const std::wstring& exe_dir) override;
|
2016-12-12 11:05:29 +01:00
|
|
|
bool HasCrashExternalHandler() const;
|
|
|
|
#endif
|
2016-04-27 22:38:52 +02:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2017-02-06 20:23:59 +01:00
|
|
|
bool EnableBrowserCrashForwarding() override;
|
2018-02-15 01:12:09 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Set or clear a crash key value.
|
2024-04-23 22:06:00 +02:00
|
|
|
bool SetCrashKeyValue(const std::string_view& key,
|
|
|
|
const std::string_view& value);
|
2018-02-15 01:12:09 +01:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
private:
|
2016-12-12 11:05:29 +01:00
|
|
|
bool has_crash_config_file_ = false;
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
enum KeySize { SMALL_SIZE, MEDIUM_SIZE, LARGE_SIZE };
|
|
|
|
|
|
|
|
// Map of crash key name to (KeySize, index).
|
|
|
|
// Const access to |crash_keys_| is thread-safe after initialization.
|
|
|
|
using KeyMap = std::map<std::string, std::pair<KeySize, size_t>>;
|
|
|
|
KeyMap crash_keys_;
|
|
|
|
|
|
|
|
// Modification of CrashKeyString values must be synchronized.
|
|
|
|
base::Lock crash_key_lock_;
|
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
std::string server_url_;
|
|
|
|
bool rate_limit_ = true;
|
|
|
|
int max_uploads_ = 5;
|
|
|
|
int max_db_size_ = 20;
|
|
|
|
int max_db_age_ = 5;
|
|
|
|
|
2017-01-12 17:44:35 +01:00
|
|
|
std::string product_name_ = "cef";
|
|
|
|
std::string product_version_ = CEF_VERSION;
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2016-12-12 11:05:29 +01:00
|
|
|
std::string app_name_ = "CEF";
|
|
|
|
std::string external_handler_;
|
|
|
|
#endif
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2017-02-06 20:23:59 +01:00
|
|
|
bool enable_browser_crash_forwarding_ = false;
|
|
|
|
#endif
|
2013-11-21 23:43:36 +01:00
|
|
|
};
|
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
#endif // CEF_LIBCEF_COMMON_CRASH_REPORTER_CLIENT_H_
|