Commit 1c9f89a0 authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Initialize Crashpad to catch app shim crashes.

Bug: 893821
Change-Id: Ic2ff92577d35250fbe773ff6b80918da33d57155
Reviewed-on: https://chromium-review.googlesource.com/c/1365955Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615629}
parent fcbb3aa5
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#endif #endif
void ChromeCrashReporterClient::Create() {
static base::NoDestructor<ChromeCrashReporterClient> crash_client;
crash_reporter::SetCrashReporterClient(crash_client.get());
}
ChromeCrashReporterClient::ChromeCrashReporterClient() {} ChromeCrashReporterClient::ChromeCrashReporterClient() {}
ChromeCrashReporterClient::~ChromeCrashReporterClient() {} ChromeCrashReporterClient::~ChromeCrashReporterClient() {}
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/no_destructor.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/crash/content/app/crash_reporter_client.h" #include "components/crash/content/app/crash_reporter_client.h"
class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient { class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
public: public:
ChromeCrashReporterClient(); static void Create();
~ChromeCrashReporterClient() override;
// crash_reporter::CrashReporterClient implementation. // crash_reporter::CrashReporterClient implementation.
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
...@@ -59,6 +59,11 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient { ...@@ -59,6 +59,11 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
bool EnableBreakpadForProcess(const std::string& process_type) override; bool EnableBreakpadForProcess(const std::string& process_type) override;
private: private:
friend class base::NoDestructor<ChromeCrashReporterClient>;
ChromeCrashReporterClient();
~ChromeCrashReporterClient() override;
DISALLOW_COPY_AND_ASSIGN(ChromeCrashReporterClient); DISALLOW_COPY_AND_ASSIGN(ChromeCrashReporterClient);
}; };
......
...@@ -169,11 +169,6 @@ base::LazyInstance<ChromeContentUtilityClient>::DestructorAtExit ...@@ -169,11 +169,6 @@ base::LazyInstance<ChromeContentUtilityClient>::DestructorAtExit
g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER;
#endif #endif
#if defined(OS_POSIX)
base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client =
LAZY_INSTANCE_INITIALIZER;
#endif
extern int NaClMain(const content::MainFunctionParams&); extern int NaClMain(const content::MainFunctionParams&);
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
...@@ -790,7 +785,7 @@ void ChromeMainDelegate::PreSandboxStartup() { ...@@ -790,7 +785,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
crash_reporter::InitializeCrashKeys(); crash_reporter::InitializeCrashKeys();
#if defined(OS_POSIX) #if defined(OS_POSIX)
crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); ChromeCrashReporterClient::Create();
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
...@@ -11,6 +11,7 @@ import("//build/util/branding.gni") ...@@ -11,6 +11,7 @@ import("//build/util/branding.gni")
# Framework bundle. # Framework bundle.
source_set("app_shim") { source_set("app_shim") {
sources = [ sources = [
"../app/chrome_crash_reporter_client.h",
"app_shim_controller.h", "app_shim_controller.h",
"app_shim_controller.mm", "app_shim_controller.mm",
"app_shim_delegate.h", "app_shim_delegate.h",
...@@ -23,6 +24,7 @@ source_set("app_shim") { ...@@ -23,6 +24,7 @@ source_set("app_shim") {
"//chrome/browser/ui:ui", "//chrome/browser/ui:ui",
"//chrome/common", "//chrome/common",
"//chrome/common:mojo_bindings", "//chrome/common:mojo_bindings",
"//components/crash/content/app",
"//content/public/browser", "//content/public/browser",
"//ipc", "//ipc",
"//mojo/core/embedder", "//mojo/core/embedder",
......
include_rules = [ include_rules = [
"+chrome/app/chrome_crash_reporter_client.h",
"+chrome/browser/ui/cocoa", "+chrome/browser/ui/cocoa",
"+chrome/installer/launcher_support", "+chrome/installer/launcher_support",
"+components/crash/content/app",
"+content/public/browser", "+content/public/browser",
"+mojo/core/embedder", "+mojo/core/embedder",
] ]
...@@ -27,10 +27,12 @@ ...@@ -27,10 +27,12 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "chrome/app/chrome_crash_reporter_client.h"
#include "chrome/app_shim/app_shim_controller.h" #include "chrome/app_shim/app_shim_controller.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "components/crash/content/app/crashpad.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#include "mojo/core/embedder/scoped_ipc_support.h" #include "mojo/core/embedder/scoped_ipc_support.h"
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h" #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
...@@ -183,6 +185,9 @@ int ChromeAppModeStart_v4(const app_mode::ChromeAppModeInfo* info) { ...@@ -183,6 +185,9 @@ int ChromeAppModeStart_v4(const app_mode::ChromeAppModeInfo* info) {
base::mac::SetOverrideFrameworkBundlePath( base::mac::SetOverrideFrameworkBundlePath(
info->chrome_versioned_path.Append(chrome::kFrameworkName)); info->chrome_versioned_path.Append(chrome::kFrameworkName));
ChromeCrashReporterClient::Create();
crash_reporter::InitializeCrashpad(true, "app_shim");
// Calculate the preferred locale used by Chrome. // Calculate the preferred locale used by Chrome.
// We can't use l10n_util::OverrideLocaleWithCocoaLocale() because it calls // We can't use l10n_util::OverrideLocaleWithCocoaLocale() because it calls
// [base::mac::OuterBundle() preferredLocalizations] which gets localizations // [base::mac::OuterBundle() preferredLocalizations] which gets localizations
......
...@@ -147,7 +147,9 @@ int LaunchChromeTests(size_t parallel_jobs, ...@@ -147,7 +147,9 @@ int LaunchChromeTests(size_t parallel_jobs,
install_static::ScopedInstallDetails install_details; install_static::ScopedInstallDetails install_details;
#endif #endif
#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN) #if defined(OS_LINUX) || defined(OS_ANDROID)
ChromeCrashReporterClient::Create();
#elif defined(OS_WIN)
// We leak this pointer intentionally. The crash client needs to outlive // We leak this pointer intentionally. The crash client needs to outlive
// all other code. // all other code.
ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient(); ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient();
......
...@@ -114,7 +114,8 @@ void InitializeCrashpadImpl(bool initial_client, ...@@ -114,7 +114,8 @@ void InitializeCrashpadImpl(bool initial_client,
// "relauncher" is hard-coded because it's a Chrome --type, but this // "relauncher" is hard-coded because it's a Chrome --type, but this
// component can't see Chrome's switches. This is only used for argument // component can't see Chrome's switches. This is only used for argument
// sanitization. // sanitization.
DCHECK(browser_process || process_type == "relauncher"); DCHECK(browser_process || process_type == "relauncher" ||
process_type == "app_shim");
#elif defined(OS_WIN) #elif defined(OS_WIN)
// "Chrome Installer" is the name historically used for installer binaries // "Chrome Installer" is the name historically used for installer binaries
// as processed by the backend. // as processed by the backend.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment