Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: headless/lib/headless_content_main_delegate.cc

Issue 2693943004: headless: Add support for minidump generation on Linux (Closed)
Patch Set: Review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/headless_content_main_delegate.h ('k') | headless/lib/headless_crash_reporter_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_content_main_delegate.cc
diff --git a/headless/lib/headless_content_main_delegate.cc b/headless/lib/headless_content_main_delegate.cc
index 608881757e2d2c2e57b9a49758274e17a159eca7..fc8f645164aacac9e20166366681351c0b52b680 100644
--- a/headless/lib/headless_content_main_delegate.cc
+++ b/headless/lib/headless_content_main_delegate.cc
@@ -4,16 +4,21 @@
#include "headless/lib/headless_content_main_delegate.h"
+#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
+#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
+#include "components/crash/content/app/breakpad_linux.h"
#include "content/public/browser/browser_main_runner.h"
#include "content/public/common/content_switches.h"
#include "headless/lib/browser/headless_browser_impl.h"
#include "headless/lib/browser/headless_content_browser_client.h"
+#include "headless/lib/headless_crash_reporter_client.h"
+#include "headless/lib/headless_macros.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/switches.h"
@@ -31,6 +36,9 @@ namespace {
const int kTraceEventBrowserProcessSortIndex = -6;
HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr;
+
+base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client =
+ LAZY_INSTANCE_INITIALIZER;
} // namespace
HeadlessContentMainDelegate::HeadlessContentMainDelegate(
@@ -131,8 +139,31 @@ void HeadlessContentMainDelegate::InitLogging(
DCHECK(success);
}
+void HeadlessContentMainDelegate::InitCrashReporter(
+ const base::CommandLine& command_line) {
+ const std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+ crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer());
+ g_headless_crash_client.Pointer()->set_crash_dumps_dir(
+ browser_->options()->crash_dumps_dir);
+
+ if (!browser_->options()->enable_crash_reporter) {
+ DCHECK(!breakpad::IsCrashReporterEnabled());
+ return;
+ }
+#if defined(HEADLESS_USE_BREAKPAD)
+ if (process_type != switches::kZygoteProcess)
+ breakpad::InitCrashReporter(process_type);
+#endif // defined(HEADLESS_USE_BREAKPAD)
+}
+
void HeadlessContentMainDelegate::PreSandboxStartup() {
- InitLogging(*base::CommandLine::ForCurrentProcess());
+ const base::CommandLine& command_line(
+ *base::CommandLine::ForCurrentProcess());
+ const std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+ InitLogging(command_line);
+ InitCrashReporter(command_line);
InitializeResourceBundle();
}
@@ -163,7 +194,14 @@ int HeadlessContentMainDelegate::RunProcess(
}
void HeadlessContentMainDelegate::ZygoteForked() {
- // TODO(skyostil): Disable the zygote host.
+ const base::CommandLine& command_line(
+ *base::CommandLine::ForCurrentProcess());
+ const std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+ // Unconditionally try to turn on crash reporting since we do not have access
+ // to the latest browser options at this point when testing. Breakpad will
+ // bail out gracefully if the browser process hasn't enabled crash reporting.
+ breakpad::InitCrashReporter(process_type);
}
// static
« no previous file with comments | « headless/lib/headless_content_main_delegate.h ('k') | headless/lib/headless_crash_reporter_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698