Commit 4285087f authored by Joshua LeVasseur's avatar Joshua LeVasseur Committed by Commit Bot

External Mojo: initialize the crash handler.

Bug: b/136266872
Test: Terminate an IoT process with SIGABRT and confirm that it deposits
      a minidump.

Change-Id: I8c6ff5d48e2473d921f4ef9c7576309055e89dea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1682527Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Commit-Queue: Joshua LeVasseur <jlevasseur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675832}
parent b6670212
...@@ -21,12 +21,16 @@ source_set("external_service") { ...@@ -21,12 +21,16 @@ source_set("external_service") {
source_set("process_setup") { source_set("process_setup") {
sources = [ sources = [
"crash_reporter_client.cc",
"crash_reporter_client.h",
"process_setup.cc", "process_setup.cc",
"process_setup.h", "process_setup.h",
] ]
deps = [ deps = [
"//base", "//base",
"//base:base_static", "//base:base_static",
"//chromecast/crash",
"//components/crash/content/app",
] ]
} }
......
include_rules = [ include_rules = [
"+chromecast/crash",
"+components/crash/content/app",
"+mojo/core/embedder", "+mojo/core/embedder",
] ]
// Copyright 2019 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.
#include "chromecast/external_mojo/external_service_support/crash_reporter_client.h"
#include "base/no_destructor.h"
#include "base/time/time.h"
#include "chromecast/crash/linux/crash_util.h"
#include "components/crash/content/app/breakpad_linux.h"
namespace chromecast {
namespace external_service_support {
namespace {
CrashReporterClient* GetCrashReporterClient() {
static base::NoDestructor<CrashReporterClient> crash_reporter_client;
return crash_reporter_client.get();
}
} // namespace
// static
void CrashReporterClient::InitCrashReporter() {
crash_reporter::SetCrashReporterClient(GetCrashReporterClient());
breakpad::InitCrashReporter(/*process_type=*/"");
}
CrashReporterClient::CrashReporterClient()
: start_time_ms_(
(base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds()) {}
CrashReporterClient::~CrashReporterClient() = default;
bool CrashReporterClient::EnableBreakpadForProcess(
const std::string& process_type) {
return true;
}
bool CrashReporterClient::HandleCrashDump(const char* crashdump_filename,
uint64_t crash_pid) {
chromecast::CrashUtil::RequestUploadCrashDump(crashdump_filename, crash_pid,
start_time_ms_);
// Always return true to indicate that this crash dump has been processed,
// so that it won't fallback to Chrome's default uploader.
return true;
}
bool CrashReporterClient::GetCollectStatsConsent() {
// Returning true allows writing the crash dump to disk, but not to
// upload. The uploader will check whether the device has opted in to crash
// uploading. It would be more optimal to avoid writing the crash dump if the
// device is opted out, but the complexity of checking that flag would
// increase the probability of a crash within the crash handler.
return true;
}
} // namespace external_service_support
} // namespace chromecast
// Copyright 2019 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.
#ifndef CHROMECAST_EXTERNAL_MOJO_EXTERNAL_SERVICE_SUPPORT_CRASH_REPORTER_CLIENT_H_
#define CHROMECAST_EXTERNAL_MOJO_EXTERNAL_SERVICE_SUPPORT_CRASH_REPORTER_CLIENT_H_
#include <cstdint>
#include <string>
#include "base/macros.h"
#include "components/crash/content/app/crash_reporter_client.h"
namespace chromecast {
namespace external_service_support {
class CrashReporterClient : public crash_reporter::CrashReporterClient {
public:
CrashReporterClient();
~CrashReporterClient() override;
static void InitCrashReporter();
// crash_reporter::CrashReporterClient implementation:
bool EnableBreakpadForProcess(const std::string& process_type) override;
bool HandleCrashDump(const char* crashdump_filename,
uint64_t crash_pid) override;
bool GetCollectStatsConsent() override;
private:
const uint64_t start_time_ms_;
DISALLOW_COPY_AND_ASSIGN(CrashReporterClient);
};
} // namespace external_service_support
} // namespace chromecast
#endif // CHROMECAST_EXTERNAL_MOJO_EXTERNAL_SERVICE_SUPPORT_CRASH_REPORTER_CLIENT_H_
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
#include "base/logging.h" #include "base/logging.h"
#include "build/build_config.h" #include "build/build_config.h"
#if !defined(OS_ANDROID)
#include "chromecast/external_mojo/external_service_support/crash_reporter_client.h"
#endif
namespace chromecast { namespace chromecast {
namespace external_service_support { namespace external_service_support {
...@@ -36,6 +40,10 @@ void CommonProcessInitialization(int argc, char** argv) { ...@@ -36,6 +40,10 @@ void CommonProcessInitialization(int argc, char** argv) {
command_line->GetSwitchValueASCII(switches::kEnableFeatures), command_line->GetSwitchValueASCII(switches::kEnableFeatures),
command_line->GetSwitchValueASCII(switches::kDisableFeatures)); command_line->GetSwitchValueASCII(switches::kDisableFeatures));
#if !defined(OS_ANDROID)
CrashReporterClient::InitCrashReporter();
#endif
CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN));
} }
......
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