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 @@
#include "components/version_info/version_info.h"
#endif
void ChromeCrashReporterClient::Create() {
static base::NoDestructor<ChromeCrashReporterClient> crash_client;
crash_reporter::SetCrashReporterClient(crash_client.get());
}
ChromeCrashReporterClient::ChromeCrashReporterClient() {}
ChromeCrashReporterClient::~ChromeCrashReporterClient() {}
......
......@@ -11,13 +11,13 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "components/crash/content/app/crash_reporter_client.h"
class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
public:
ChromeCrashReporterClient();
~ChromeCrashReporterClient() override;
static void Create();
// crash_reporter::CrashReporterClient implementation.
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
......@@ -59,6 +59,11 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
bool EnableBreakpadForProcess(const std::string& process_type) override;
private:
friend class base::NoDestructor<ChromeCrashReporterClient>;
ChromeCrashReporterClient();
~ChromeCrashReporterClient() override;
DISALLOW_COPY_AND_ASSIGN(ChromeCrashReporterClient);
};
......
......@@ -169,11 +169,6 @@ base::LazyInstance<ChromeContentUtilityClient>::DestructorAtExit
g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER;
#endif
#if defined(OS_POSIX)
base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client =
LAZY_INSTANCE_INITIALIZER;
#endif
extern int NaClMain(const content::MainFunctionParams&);
#if !defined(OS_CHROMEOS)
......@@ -790,7 +785,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
crash_reporter::InitializeCrashKeys();
#if defined(OS_POSIX)
crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer());
ChromeCrashReporterClient::Create();
#endif
#if defined(OS_MACOSX)
......
......@@ -11,6 +11,7 @@ import("//build/util/branding.gni")
# Framework bundle.
source_set("app_shim") {
sources = [
"../app/chrome_crash_reporter_client.h",
"app_shim_controller.h",
"app_shim_controller.mm",
"app_shim_delegate.h",
......@@ -23,6 +24,7 @@ source_set("app_shim") {
"//chrome/browser/ui:ui",
"//chrome/common",
"//chrome/common:mojo_bindings",
"//components/crash/content/app",
"//content/public/browser",
"//ipc",
"//mojo/core/embedder",
......
include_rules = [
"+chrome/app/chrome_crash_reporter_client.h",
"+chrome/browser/ui/cocoa",
"+chrome/installer/launcher_support",
"+components/crash/content/app",
"+content/public/browser",
"+mojo/core/embedder",
]
......@@ -27,10 +27,12 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
#include "base/threading/thread.h"
#include "chrome/app/chrome_crash_reporter_client.h"
#include "chrome/app_shim/app_shim_controller.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/crash/content/app/crashpad.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/embedder/scoped_ipc_support.h"
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
......@@ -183,6 +185,9 @@ int ChromeAppModeStart_v4(const app_mode::ChromeAppModeInfo* info) {
base::mac::SetOverrideFrameworkBundlePath(
info->chrome_versioned_path.Append(chrome::kFrameworkName));
ChromeCrashReporterClient::Create();
crash_reporter::InitializeCrashpad(true, "app_shim");
// Calculate the preferred locale used by Chrome.
// We can't use l10n_util::OverrideLocaleWithCocoaLocale() because it calls
// [base::mac::OuterBundle() preferredLocalizations] which gets localizations
......
......@@ -147,7 +147,9 @@ int LaunchChromeTests(size_t parallel_jobs,
install_static::ScopedInstallDetails install_details;
#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
// all other code.
ChromeCrashReporterClient* crash_client = new ChromeCrashReporterClient();
......
......@@ -114,7 +114,8 @@ void InitializeCrashpadImpl(bool initial_client,
// "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
// sanitization.
DCHECK(browser_process || process_type == "relauncher");
DCHECK(browser_process || process_type == "relauncher" ||
process_type == "app_shim");
#elif defined(OS_WIN)
// "Chrome Installer" is the name historically used for installer binaries
// 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