0

Reland "Add CrashReporterClient::GetProductInfo(ProductInfo*)"

This is a reland of commit 49d3a5a2bc

This reland fixes the compile errors on casto builds.
See patchset 1..2 for diff.

Original change's description:
> Add CrashReporterClient::GetProductInfo(ProductInfo*)
>
> This method unifies the other two existing GetProductNameAndVersion()
> functions, simplifying the CrashReporterClient interface.
>
> This is a step towards providing an interface for accessing product info
> through crash_export_thunks, which will be used in JS Error reporting on
> Windows.
>
> Bug: 40149439, 374696525
> Low-Coverage-Reason: TESTS_IN_SEPARATE_CL, the new interface will be used in future CLs.
> Change-Id: Ic198b69764721b7d03cf71fb9f79a8392fe3d8d1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6012865
> Reviewed-by: Alexander Timin <altimin@chromium.org>
> Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Reviewed-by: Nate Fischer <ntfschr@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1382090}

Bug: 40149439, 374696525
Change-Id: I4b1ad56c84081736e1df5051706bbd9695727c58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6012631
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: Vigen Issahhanjan <vigeni@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Keren Zhu <kerenzhu@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1383219}
This commit is contained in:
Keren Zhu
2024-11-14 21:05:39 +00:00
committed by Chromium LUCI CQ
parent 9d0b5dfab5
commit 408052b7bf
19 changed files with 129 additions and 165 deletions

@@ -56,12 +56,10 @@ class AwCrashReporterClient : public crash_reporter::CrashReporterClient {
return false; return false;
} }
void GetProductNameAndVersion(std::string* product_name, void GetProductInfo(ProductInfo* product_info) override {
std::string* version, product_info->product_name = "AndroidWebView";
std::string* channel) override { product_info->version = PRODUCT_VERSION;
*product_name = "AndroidWebView"; product_info->channel =
*version = PRODUCT_VERSION;
*channel =
version_info::GetChannelString(version_info::android::GetChannel()); version_info::GetChannelString(version_info::android::GetChannel());
} }

@@ -22,12 +22,12 @@
#include "chrome/common/env_vars.h" #include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/google_update_settings.h"
#include "components/crash/core/common/crash_keys.h" #include "components/crash/core/common/crash_keys.h"
#include "components/version_info/version_info_values.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#include "components/upload_list/crash_upload_list.h" #include "components/upload_list/crash_upload_list.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "components/version_info/version_info_values.h"
#endif #endif
#if BUILDFLAG(IS_POSIX) #if BUILDFLAG(IS_POSIX)
@@ -113,40 +113,6 @@ void ChromeCrashReporterClient::SetCrashReporterClientIdFromGUID(
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
void ChromeCrashReporterClient::GetProductNameAndVersion(
const char** product_name,
const char** version) {
DCHECK(product_name);
DCHECK(version);
#if BUILDFLAG(IS_ANDROID)
*product_name = "Chrome_Android";
#elif BUILDFLAG(IS_CHROMEOS_ASH)
*product_name = "Chrome_ChromeOS";
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
*product_name = "Chrome_Lacros";
#else // BUILDFLAG(IS_ANDROID)
#if !defined(ADDRESS_SANITIZER)
*product_name = "Chrome_Linux";
#else
*product_name = "Chrome_Linux_ASan";
#endif
#endif
*version = PRODUCT_VERSION;
}
void ChromeCrashReporterClient::GetProductNameAndVersion(
std::string* product_name,
std::string* version,
std::string* channel) {
const char* c_product_name;
const char* c_version;
GetProductNameAndVersion(&c_product_name, &c_version);
*product_name = c_product_name;
*version = c_version;
*channel = chrome::GetChannelName(chrome::WithExtendedStable(true));
}
base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() {
return base::FilePath(CrashUploadList::kReporterLogFilename); return base::FilePath(CrashUploadList::kReporterLogFilename);
} }
@@ -161,11 +127,40 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation(
return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); return base::PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir);
} }
void ChromeCrashReporterClient::GetProductInfo(ProductInfo* product_info) {
CHECK(product_info);
#if BUILDFLAG(IS_ANDROID)
product_info->product_name = "Chrome_Android";
#elif BUILDFLAG(IS_CHROMEOS_ASH)
product_info->product_name = "Chrome_ChromeOS";
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
product_info->product_name = "Chrome_Lacros";
#elif BUILDFLAG(IS_LINUX)
#if defined(ADDRESS_SANITIZER)
product_info->product_name = "Chrome_Linux_ASan";
#else
product_info->product_name = "Chrome_Linux";
#endif // defined(ADDRESS_SANITIZER)
#elif BUILDFLAG(IS_MAC)
product_info->product_name = "Chrome_Mac";
#elif BUILDFLAG(IS_WIN)
product_info->product_name = "Chrome";
#else
NOTREACHED();
#endif
product_info->version = PRODUCT_VERSION;
product_info->channel =
chrome::GetChannelName(chrome::WithExtendedStable(true));
}
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
bool ChromeCrashReporterClient::GetCrashMetricsLocation( bool ChromeCrashReporterClient::GetCrashMetricsLocation(
base::FilePath* metrics_dir) { base::FilePath* metrics_dir) {
if (!GetCollectStatsConsent()) if (!GetCollectStatsConsent()) {
return false; return false;
}
return base::PathService::Get(chrome::DIR_CRASH_METRICS, metrics_dir); return base::PathService::Get(chrome::DIR_CRASH_METRICS, metrics_dir);
} }
#endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)

@@ -44,17 +44,13 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
base::FilePath GetReporterLogFilename() override; base::FilePath GetReporterLogFilename() override;
bool GetShouldDumpLargerDumps() override; bool GetShouldDumpLargerDumps() override;
#endif #endif
bool GetCrashDumpLocation(base::FilePath* crash_dir) override; bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
void GetProductInfo(ProductInfo* product_info) override;
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
bool GetCrashMetricsLocation(base::FilePath* metrics_dir) override; bool GetCrashMetricsLocation(base::FilePath* metrics_dir) override;

@@ -38,8 +38,9 @@ ChromeCrashReporterClient::~ChromeCrashReporterClient() {}
// static // static
void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { void ChromeCrashReporterClient::InitializeCrashReportingForProcess() {
static ChromeCrashReporterClient* instance = nullptr; static ChromeCrashReporterClient* instance = nullptr;
if (instance) if (instance) {
return; return;
}
instance = new ChromeCrashReporterClient(); instance = new ChromeCrashReporterClient();
ANNOTATE_LEAKING_OBJECT_PTR(instance); ANNOTATE_LEAKING_OBJECT_PTR(instance);
@@ -54,8 +55,9 @@ void ChromeCrashReporterClient::InitializeCrashReportingForProcess() {
crash_reporter::SetCrashReporterClient(instance); crash_reporter::SetCrashReporterClient(instance);
std::wstring user_data_dir; std::wstring user_data_dir;
if (process_type.empty()) if (process_type.empty()) {
install_static::GetUserDataDirectory(&user_data_dir, nullptr); install_static::GetUserDataDirectory(&user_data_dir, nullptr);
}
// TODO(wfh): Add a DCHECK for success. See https://crbug.com/1329269. // TODO(wfh): Add a DCHECK for success. See https://crbug.com/1329269.
std::ignore = crash_reporter::InitializeCrashpadWithEmbeddedHandler( std::ignore = crash_reporter::InitializeCrashpadWithEmbeddedHandler(
@@ -88,6 +90,17 @@ void ChromeCrashReporterClient::GetProductNameAndVersion(
special_build, channel_name); special_build, channel_name);
} }
void ChromeCrashReporterClient::GetProductInfo(ProductInfo* product_info) {
std::wstring product_name, version, special_build, channel_name;
wchar_t exe_file[MAX_PATH] = {};
CHECK(::GetModuleFileName(nullptr, exe_file, std::size(exe_file)));
GetProductNameAndVersion(exe_file, &product_name, &version, &special_build,
&channel_name);
product_info->product_name = base::WideToUTF8(product_name);
product_info->version = base::WideToUTF8(version);
product_info->channel = base::WideToUTF8(channel_name);
}
bool ChromeCrashReporterClient::GetShouldDumpLargerDumps() { bool ChromeCrashReporterClient::GetShouldDumpLargerDumps() {
// Capture larger dumps for Google Chrome beta, dev, and canary channels, and // Capture larger dumps for Google Chrome beta, dev, and canary channels, and
// Chromium builds. The Google Chrome stable channel uses smaller dumps. // Chromium builds. The Google Chrome stable channel uses smaller dumps.
@@ -112,8 +125,9 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation(std::wstring* crash_dir) {
// short-circuit how it's handled on Windows. Honoring this // short-circuit how it's handled on Windows. Honoring this
// variable is required in order to symbolize stack traces in // variable is required in order to symbolize stack traces in
// Telemetry based tests: http://crbug.com/561763. // Telemetry based tests: http://crbug.com/561763.
if (GetAlternativeCrashDumpLocation(crash_dir)) if (GetAlternativeCrashDumpLocation(crash_dir)) {
return true; return true;
}
*crash_dir = install_static::GetCrashDumpLocation(); *crash_dir = install_static::GetCrashDumpLocation();
return !crash_dir->empty(); return !crash_dir->empty();
@@ -121,8 +135,9 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation(std::wstring* crash_dir) {
bool ChromeCrashReporterClient::GetCrashMetricsLocation( bool ChromeCrashReporterClient::GetCrashMetricsLocation(
std::wstring* metrics_dir) { std::wstring* metrics_dir) {
if (!GetCollectStatsConsent()) if (!GetCollectStatsConsent()) {
return false; return false;
}
install_static::GetUserDataDirectory(metrics_dir, nullptr); install_static::GetUserDataDirectory(metrics_dir, nullptr);
return !metrics_dir->empty(); return !metrics_dir->empty();
} }
@@ -184,14 +199,16 @@ std::wstring ChromeCrashReporterClient::GetWerRuntimeExceptionModule() {
DWORD len = GetModuleFileName(CURRENT_MODULE(), elf_file, MAX_PATH); DWORD len = GetModuleFileName(CURRENT_MODULE(), elf_file, MAX_PATH);
// On error return an empty path to indicate than a module is not to be // On error return an empty path to indicate than a module is not to be
// registered. This is harmless. // registered. This is harmless.
if (len == 0 || len == MAX_PATH) if (len == 0 || len == MAX_PATH) {
return std::wstring(); return std::wstring();
}
wchar_t elf_dir[MAX_PATH]; wchar_t elf_dir[MAX_PATH];
wchar_t* file_start = nullptr; wchar_t* file_start = nullptr;
DWORD dir_len = GetFullPathName(elf_file, MAX_PATH, elf_dir, &file_start); DWORD dir_len = GetFullPathName(elf_file, MAX_PATH, elf_dir, &file_start);
if (dir_len == 0 || dir_len > len || !file_start) if (dir_len == 0 || dir_len > len || !file_start) {
return std::wstring(); return std::wstring();
}
// file_start points to the start of the filename in the elf_dir buffer. // file_start points to the start of the filename in the elf_dir buffer.
return std::wstring(elf_dir, file_start).append(kWerDll); return std::wstring(elf_dir, file_start).append(kWerDll);

@@ -29,6 +29,7 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
std::wstring* version, std::wstring* version,
std::wstring* special_build, std::wstring* special_build,
std::wstring* channel_name) override; std::wstring* channel_name) override;
void GetProductInfo(ProductInfo* product_info) override;
bool GetShouldDumpLargerDumps() override; bool GetShouldDumpLargerDumps() override;
bool GetCrashDumpLocation(std::wstring* crash_dir) override; bool GetCrashDumpLocation(std::wstring* crash_dir) override;

@@ -164,7 +164,7 @@ TEST_F(ChromeJsErrorReportProcessorTest, Basic) {
// This is from MockChromeJsErrorReportProcessor::GetOsVersion() // This is from MockChromeJsErrorReportProcessor::GetOsVersion()
EXPECT_THAT(actual_report->query, HasSubstr("os_version=7.20.1")); EXPECT_THAT(actual_report->query, HasSubstr("os_version=7.20.1"));
#endif #endif
// These are from MockCrashEndpoint::Client::GetProductNameAndVersion, which // These are from MockCrashEndpoint::Client::GetProductInfo, which
// is only defined for non-MAC POSIX systems. TODO(crbug.com/40146362): // is only defined for non-MAC POSIX systems. TODO(crbug.com/40146362):
// Get this info for non-POSIX platforms. // Get this info for non-POSIX platforms.
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
@@ -232,7 +232,7 @@ void ChromeJsErrorReportProcessorTest::TestAllFields() {
// This is from MockChromeJsErrorReportProcessor::GetOsVersion() // This is from MockChromeJsErrorReportProcessor::GetOsVersion()
EXPECT_THAT(actual_report->query, HasSubstr("os_version=7.20.1")); EXPECT_THAT(actual_report->query, HasSubstr("os_version=7.20.1"));
#endif #endif
// These are from MockCrashEndpoint::Client::GetProductNameAndVersion, which // These are from MockCrashEndpoint::Client::GetProductInfo, which
// is only defined for non-MAC POSIX systems. TODO(crbug.com/40146362): // is only defined for non-MAC POSIX systems. TODO(crbug.com/40146362):
// Get this info for non-POSIX platforms. // Get this info for non-POSIX platforms.
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)

@@ -18,24 +18,20 @@ namespace chromecast {
CastCrashReporterClientAndroid::CastCrashReporterClientAndroid( CastCrashReporterClientAndroid::CastCrashReporterClientAndroid(
const std::string& process_type) const std::string& process_type)
: process_type_(process_type) { : process_type_(process_type) {}
}
CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() { CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() {}
}
void CastCrashReporterClientAndroid::GetProductNameAndVersion( void CastCrashReporterClientAndroid::GetProductInfo(ProductInfo* product_info) {
std::string* product_name, product_info->product_name = "media_shell";
std::string* version, product_info->version = CAST_BUILD_RELEASE ".";
std::string* channel) { product_info->version +=
*product_name = "media_shell"; base::android::BuildInfo::GetInstance()->package_version_code();
*version = CAST_BUILD_RELEASE ".";
*version += base::android::BuildInfo::GetInstance()->package_version_code();
#if CAST_IS_DEBUG_BUILD() #if CAST_IS_DEBUG_BUILD()
*version += ".debug"; product_info->version += ".debug";
#endif #endif
CastSysInfoAndroid sys_info; CastSysInfoAndroid sys_info;
*channel = sys_info.GetSystemReleaseChannel(); product_info->channel = sys_info.GetSystemReleaseChannel();
} }
base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() { base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() {

@@ -29,9 +29,7 @@ class CastCrashReporterClientAndroid
base::FilePath* crash_dir); base::FilePath* crash_dir);
// crash_reporter::CrashReporterClient implementation: // crash_reporter::CrashReporterClient implementation:
void GetProductNameAndVersion(std::string* product_name, void GetProductInfo(ProductInfo* product_info) override;
std::string* version,
std::string* channel) override;
base::FilePath GetReporterLogFilename() override; base::FilePath GetReporterLogFilename() override;
bool GetCrashDumpLocation(base::FilePath* crash_dir) override; bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
bool EnableBreakpadForProcess(const std::string& process_type) override; bool EnableBreakpadForProcess(const std::string& process_type) override;

@@ -31,15 +31,11 @@ class MockCrashEndpoint::Client : public crash_reporter::CrashReporterClient {
FROM_HERE, base::BlockingType::MAY_BLOCK); FROM_HERE, base::BlockingType::MAY_BLOCK);
return owner_->consented_; return owner_->consented_;
} }
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) void GetProductInfo(ProductInfo* product_info) override {
void GetProductNameAndVersion(std::string* product_name, product_info->product_name = "Chrome_ChromeOS";
std::string* version, product_info->version = "1.2.3.4";
std::string* channel) override { product_info->channel = "Stable";
*product_name = "Chrome_ChromeOS";
*version = "1.2.3.4";
*channel = "Stable";
} }
#endif
private: private:
raw_ptr<MockCrashEndpoint> owner_; raw_ptr<MockCrashEndpoint> owner_;
}; };

@@ -1066,15 +1066,13 @@ void HandleCrashDump(const BreakpadInfo& info) {
MimeWriter writer(temp_file_fd, mime_boundary); MimeWriter writer(temp_file_fd, mime_boundary);
{ {
const char* product_name = ""; crash_reporter::CrashReporterClient::ProductInfo product_info;
const char* version = ""; GetCrashReporterClient()->GetProductInfo(&product_info);
GetCrashReporterClient()->GetProductNameAndVersion(&product_name, &version);
writer.AddBoundary(); writer.AddBoundary();
writer.AddPairString("prod", product_name); writer.AddPairString("prod", product_info.product_name.c_str());
writer.AddBoundary(); writer.AddBoundary();
writer.AddPairString("ver", version); writer.AddPairString("ver", product_info.version.c_str());
writer.AddBoundary(); writer.AddBoundary();
if (info.pid > 0) { if (info.pid > 0) {
char pid_value_buf[kUint64StringSize]; char pid_value_buf[kUint64StringSize];

@@ -17,7 +17,11 @@ bool GetClientCollectStatsConsent() {
void GetClientProductNameAndVersion(std::string* product, void GetClientProductNameAndVersion(std::string* product,
std::string* version, std::string* version,
std::string* channel) { std::string* channel) {
GetCrashReporterClient()->GetProductNameAndVersion(product, version, channel); CrashReporterClient::ProductInfo product_info;
GetCrashReporterClient()->GetProductInfo(&product_info);
*product = product_info.product_name;
*version = product_info.version;
*channel = product_info.channel;
} }
#endif #endif

@@ -41,6 +41,9 @@ CrashReporterClient* GetCrashReporterClient() {
CrashReporterClient::CrashReporterClient() = default; CrashReporterClient::CrashReporterClient() = default;
CrashReporterClient::~CrashReporterClient() = default; CrashReporterClient::~CrashReporterClient() = default;
CrashReporterClient::ProductInfo::ProductInfo() = default;
CrashReporterClient::ProductInfo::~ProductInfo() = default;
#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_ANDROID) #if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_ANDROID)
void CrashReporterClient::SetCrashReporterClientIdFromGUID( void CrashReporterClient::SetCrashReporterClientIdFromGUID(
const std::string& client_guid) {} const std::string& client_guid) {}
@@ -71,14 +74,6 @@ bool CrashReporterClient::GetShouldDumpLargerDumps() {
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
void CrashReporterClient::GetProductNameAndVersion(const char** product_name,
const char** version) {
}
void CrashReporterClient::GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) {}
base::FilePath CrashReporterClient::GetReporterLogFilename() { base::FilePath CrashReporterClient::GetReporterLogFilename() {
return base::FilePath(); return base::FilePath();
} }
@@ -105,6 +100,8 @@ bool CrashReporterClient::GetCrashMetricsLocation(base::FilePath* crash_dir) {
return false; return false;
} }
void CrashReporterClient::GetProductInfo(ProductInfo* product_info) {}
bool CrashReporterClient::IsRunningUnattended() { bool CrashReporterClient::IsRunningUnattended() {
return true; return true;
} }

@@ -34,6 +34,15 @@ CrashReporterClient* GetCrashReporterClient();
// Interface that the embedder implements. // Interface that the embedder implements.
class CrashReporterClient { class CrashReporterClient {
public: public:
struct ProductInfo {
ProductInfo();
~ProductInfo();
std::string product_name;
std::string version;
std::string channel;
};
CrashReporterClient(); CrashReporterClient();
virtual ~CrashReporterClient(); virtual ~CrashReporterClient();
@@ -73,16 +82,6 @@ class CrashReporterClient {
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// Returns a textual description of the product type and version to include
// in the crash report. Neither out parameter should be set to NULL.
// TODO(jperaza): Remove the 2-parameter overload of this method once all
// Linux-ish breakpad clients have transitioned to crashpad.
virtual void GetProductNameAndVersion(const char** product_name,
const char** version);
virtual void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel);
virtual base::FilePath GetReporterLogFilename(); virtual base::FilePath GetReporterLogFilename();
// Custom crash minidump handler after the minidump is generated. // Custom crash minidump handler after the minidump is generated.
@@ -114,6 +113,10 @@ class CrashReporterClient {
virtual bool GetCrashMetricsLocation(base::FilePath* metrics_dir); virtual bool GetCrashMetricsLocation(base::FilePath* metrics_dir);
#endif #endif
// Returns a textual description of the product info (product name, version,
// etc.) to include in the crash report.
virtual void GetProductInfo(ProductInfo* product_info);
// Returns true if running in unattended mode (for automated testing). // Returns true if running in unattended mode (for automated testing).
virtual bool IsRunningUnattended(); virtual bool IsRunningUnattended();

@@ -435,13 +435,10 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client,
// TODO(jperaza): Set URL for Android when Crashpad takes over report upload. // TODO(jperaza): Set URL for Android when Crashpad takes over report upload.
*url = std::string(); *url = std::string();
std::string product_name; CrashReporterClient::ProductInfo product_info;
std::string product_version; crash_reporter_client->GetProductInfo(&product_info);
std::string channel; (*process_annotations)["prod"] = product_info.product_name;
crash_reporter_client->GetProductNameAndVersion(&product_name, (*process_annotations)["ver"] = product_info.version;
&product_version, &channel);
(*process_annotations)["prod"] = product_name;
(*process_annotations)["ver"] = product_version;
SetBuildInfoAnnotations(process_annotations); SetBuildInfoAnnotations(process_annotations);
@@ -451,8 +448,8 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client,
#else #else
const bool allow_empty_channel = false; const bool allow_empty_channel = false;
#endif #endif
if (allow_empty_channel || !channel.empty()) { if (allow_empty_channel || !product_info.channel.empty()) {
(*process_annotations)["channel"] = channel; (*process_annotations)["channel"] = product_info.channel;
} }
(*process_annotations)["plat"] = std::string("Android"); (*process_annotations)["plat"] = std::string("Android");

@@ -184,27 +184,26 @@ bool PlatformCrashpadInitialization(
url = std::string(); url = std::string();
#endif #endif
std::string product_name, product_version, channel; CrashReporterClient::ProductInfo product_info;
crash_reporter_client->GetProductNameAndVersion(&product_name, crash_reporter_client->GetProductInfo(&product_info);
&product_version, &channel);
std::map<std::string, std::string> annotations; std::map<std::string, std::string> annotations;
annotations["prod"] = product_name; annotations["prod"] = product_info.product_name;
annotations["ver"] = product_version; annotations["ver"] = product_info.version;
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Empty means stable. // Empty means stable.
const bool allow_empty_channel = true; const bool allow_empty_channel = true;
if (channel == "extended") { if (product_info.channel == "extended") {
// Extended stable reports as stable (empty string) with an extra bool. // Extended stable reports as stable (empty string) with an extra bool.
channel.clear(); product_info.channel.clear();
annotations["extended_stable_channel"] = "true"; annotations["extended_stable_channel"] = "true";
} }
#else #else
const bool allow_empty_channel = false; const bool allow_empty_channel = false;
#endif #endif
if (allow_empty_channel || !channel.empty()) { if (allow_empty_channel || !product_info.channel.empty()) {
annotations["channel"] = channel; annotations["channel"] = product_info.channel;
} }
annotations["plat"] = std::string("Linux"); annotations["plat"] = std::string("Linux");

@@ -38,22 +38,6 @@ void ShellCrashReporterClient::GetProductNameAndVersion(
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
void ShellCrashReporterClient::GetProductNameAndVersion(
const char** product_name,
const char** version) {
*product_name = "content_shell";
*version = CONTENT_SHELL_VERSION;
}
void ShellCrashReporterClient::GetProductNameAndVersion(
std::string* product_name,
std::string* version,
std::string* channel) {
*product_name = "content_shell";
*version = CONTENT_SHELL_VERSION;
*channel = "";
}
base::FilePath ShellCrashReporterClient::GetReporterLogFilename() { base::FilePath ShellCrashReporterClient::GetReporterLogFilename() {
return base::FilePath(FILE_PATH_LITERAL("uploads.log")); return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
} }
@@ -78,6 +62,11 @@ bool ShellCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
return true; return true;
} }
void ShellCrashReporterClient::GetProductInfo(ProductInfo* product_info) {
product_info->product_name = "content_shell";
product_info->version = CONTENT_SHELL_VERSION;
}
bool ShellCrashReporterClient::EnableBreakpadForProcess( bool ShellCrashReporterClient::EnableBreakpadForProcess(
const std::string& process_type) { const std::string& process_type) {
return process_type == switches::kRendererProcess || return process_type == switches::kRendererProcess ||

@@ -30,13 +30,6 @@ class ShellCrashReporterClient : public crash_reporter::CrashReporterClient {
#endif #endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// Returns a textual description of the product type and version to include
// in the crash report.
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
base::FilePath GetReporterLogFilename() override; base::FilePath GetReporterLogFilename() override;
#endif #endif
@@ -48,6 +41,7 @@ class ShellCrashReporterClient : public crash_reporter::CrashReporterClient {
bool GetCrashDumpLocation(base::FilePath* crash_dir) override; bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
#endif #endif
void GetProductInfo(ProductInfo* product_info) override;
bool EnableBreakpadForProcess(const std::string& process_type) override; bool EnableBreakpadForProcess(const std::string& process_type) override;
}; };

@@ -18,28 +18,18 @@
namespace headless { namespace headless {
namespace { namespace {
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
constexpr char kChromeHeadlessProductName[] = "Chrome_Headless"; constexpr char kChromeHeadlessProductName[] = "Chrome_Headless";
#endif
} // namespace } // namespace
HeadlessCrashReporterClient::HeadlessCrashReporterClient() = default; HeadlessCrashReporterClient::HeadlessCrashReporterClient() = default;
HeadlessCrashReporterClient::~HeadlessCrashReporterClient() = default; HeadlessCrashReporterClient::~HeadlessCrashReporterClient() = default;
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) void HeadlessCrashReporterClient::GetProductInfo(
void HeadlessCrashReporterClient::GetProductNameAndVersion( ProductInfo* product_info) {
std::string* product_name, product_info->product_name = kChromeHeadlessProductName;
std::string* version, product_info->version = PRODUCT_VERSION;
std::string* channel) { product_info->channel = "";
*product_name = kChromeHeadlessProductName;
*version = PRODUCT_VERSION;
*channel = "";
} }
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
bool HeadlessCrashReporterClient::GetCrashDumpLocation( bool HeadlessCrashReporterClient::GetCrashDumpLocation(
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)

@@ -28,11 +28,7 @@ class HeadlessCrashReporterClient : public crash_reporter::CrashReporterClient {
} }
const base::FilePath& crash_dumps_dir() const { return crash_dumps_dir_; } const base::FilePath& crash_dumps_dir() const { return crash_dumps_dir_; }
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) void GetProductInfo(ProductInfo* product_info) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
bool GetCrashDumpLocation(std::wstring* crash_dir) override; bool GetCrashDumpLocation(std::wstring* crash_dir) override;