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 <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2017-01-12 17:44:35 +01:00
|
|
|
#include "include/cef_version.h"
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include "base/macros.h"
|
|
|
|
#include "build/build_config.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/crash/content/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();
|
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;
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_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();
|
|
|
|
|
|
|
|
bool GetAlternativeCrashDumpLocation(base::string16* crash_dir) override;
|
2016-06-21 00:59:23 +02:00
|
|
|
void GetProductNameAndVersion(const base::string16& exe_path,
|
2014-11-12 20:25:15 +01:00
|
|
|
base::string16* product_name,
|
|
|
|
base::string16* version,
|
|
|
|
base::string16* special_build,
|
|
|
|
base::string16* channel_name) override;
|
2016-12-12 11:05:29 +01:00
|
|
|
bool GetCrashDumpLocation(base::string16* crash_dir) override;
|
|
|
|
bool GetCrashMetricsLocation(base::string16* metrics_dir) override;
|
|
|
|
#elif defined(OS_POSIX)
|
2014-11-12 20:25:15 +01:00
|
|
|
void GetProductNameAndVersion(const char** product_name,
|
|
|
|
const char** version) override;
|
2017-01-12 17:44:35 +01:00
|
|
|
#if !defined(OS_MACOSX)
|
2014-11-12 20:25:15 +01:00
|
|
|
base::FilePath GetReporterLogFilename() override;
|
2016-12-12 11:05:29 +01:00
|
|
|
bool EnableBreakpadForProcess(const std::string& process_type) override;
|
|
|
|
#endif
|
|
|
|
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
|
|
|
|
#endif // defined(OS_POSIX)
|
|
|
|
|
|
|
|
// All of these methods must return true to enable crash report upload.
|
|
|
|
bool GetCollectStatsConsent() override;
|
|
|
|
bool GetCollectStatsInSample() override;
|
|
|
|
#if defined(OS_WIN) || defined(OS_MACOSX)
|
|
|
|
bool ReportingIsEnforcedByPolicy(bool* crashpad_enabled) override;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
size_t RegisterCrashKeys() override;
|
|
|
|
|
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
bool IsRunningUnattended() override;
|
2013-11-21 23:43:36 +01:00
|
|
|
#endif
|
|
|
|
|
2016-06-21 00:59:23 +02:00
|
|
|
#if defined(OS_WIN)
|
2016-12-12 11:05:29 +01:00
|
|
|
size_t GetCrashKeyCount() const;
|
|
|
|
bool GetCrashKey(size_t index,
|
|
|
|
const char** key_name,
|
|
|
|
size_t* max_length) const;
|
2016-06-21 00:59:23 +02:00
|
|
|
#endif
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
std::string GetCrashServerURL() override;
|
|
|
|
void GetCrashOptionalArguments(std::vector<std::string>* arguments) override;
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
base::string16 GetCrashExternalHandler(
|
|
|
|
const base::string16& exe_dir) override;
|
|
|
|
bool HasCrashExternalHandler() const;
|
|
|
|
#endif
|
2016-04-27 22:38:52 +02:00
|
|
|
|
2017-02-06 20:23:59 +01:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
bool EnableBrowserCrashForwarding() override;
|
|
|
|
#endif
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
private:
|
2016-12-12 11:05:29 +01:00
|
|
|
bool has_crash_config_file_ = false;
|
|
|
|
|
|
|
|
// Values that will persist until the end of the program.
|
|
|
|
// Matches the members of base::debug::CrashKey.
|
|
|
|
struct StoredCrashKey {
|
|
|
|
std::string key_name_;
|
|
|
|
size_t max_length_;
|
|
|
|
};
|
|
|
|
std::vector<StoredCrashKey> crash_keys_;
|
|
|
|
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;
|
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
std::string app_name_ = "CEF";
|
|
|
|
std::string external_handler_;
|
|
|
|
#endif
|
|
|
|
|
2017-02-06 20:23:59 +01:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
bool enable_browser_crash_forwarding_ = false;
|
|
|
|
#endif
|
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefCrashReporterClient);
|
2013-11-21 23:43:36 +01:00
|
|
|
};
|
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
#endif // CEF_LIBCEF_COMMON_CRASH_REPORTER_CLIENT_H_
|