Skip to content

Commit

Permalink
Reland Enable crashpad for Mac.
Browse files Browse the repository at this point in the history
-- Add :mac_helpers dependendency to headless_lib

Original reason for revert: Reason for revert:
mac_chromium10.10_rel_ng buildbot failing in browsertests
https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.mac%2FMac10.10_Tests%2F16541%2F%2B%2Frecipes%2Fsteps%2Fheadless_browsertests_on_Mac-10.10%2F0%2Flogs%2FCrashReporterTest.GenerateMinidump%2F0

This follows the same logic as using breakpad in linux with flags --enable_crash-reporter and --crash-dumps-dir folders.

For headless_shell target, we need to include the Helper crashpad_handler in the build. For --headless, this is already available in the framework bundle.

BUG=687407

Review-Url: https://codereview.chromium.org/2816593006
Cr-Commit-Position: refs/heads/master@{#464289}
Committed: https://chromium.googlesource.com/chromium/src/+/ecb2ad24952b077e71e56ba9d3edfc83c522f32a

patch from issue 2816593006 at patchset 60001 (http://crrev.com/2816593006#ps60001)

Review-Url: https://codereview.chromium.org/2820453003
Cr-Commit-Position: refs/heads/master@{#465869}
  • Loading branch information
dvallet authored and Commit bot committed Apr 20, 2017
1 parent 3d95cd9 commit df51c3e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
20 changes: 19 additions & 1 deletion headless/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ static_library("headless_lib") {
"//url",
]

if (!is_mac) {
if (is_mac) {
deps += [ ":mac_helpers" ]
} else {
deps += [ "//ui/aura" ]
}

Expand Down Expand Up @@ -432,6 +434,22 @@ repack("headless_browser_tests_pak") {
]
}

if (is_mac) {
copy("mac_helpers") {
sources = [
"$root_out_dir/crashpad_handler",
]

deps = [
"//third_party/crashpad/crashpad/handler:crashpad_handler",
]

outputs = [
"$root_out_dir/Helpers/{{source_file_part}}",
]
}
}

test("headless_browsertests") {
sources = [
"lib/embedder_mojo_browsertest.cc",
Expand Down
11 changes: 8 additions & 3 deletions headless/lib/headless_browser_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,13 @@ class CrashReporterTest : public HeadlessBrowserTest,
base::FilePath crash_dumps_dir_;
};

// TODO(skyostil): Minidump generation currently is only supported on Linux.
#if defined(HEADLESS_USE_BREAKPAD)
// TODO(skyostil): Minidump generation currently is only supported on Linux and
// Mac.
#if defined(HEADLESS_USE_BREAKPAD) || defined(OS_MACOSX)
#define MAYBE_GenerateMinidump GenerateMinidump
#else
#define MAYBE_GenerateMinidump DISABLED_GenerateMinidump
#endif // defined(HEADLESS_USE_BREAKPAD)
#endif // defined(HEADLESS_USE_BREAKPAD) || defined(OS_MACOSX)
IN_PROC_BROWSER_TEST_F(CrashReporterTest, MAYBE_GenerateMinidump) {
// Navigates a tab to chrome://crash and checks that a minidump is generated.
// Note that we only test renderer crashes here -- browser crashes need to be
Expand All @@ -744,6 +745,10 @@ IN_PROC_BROWSER_TEST_F(CrashReporterTest, MAYBE_GenerateMinidump) {

// Check that one minidump got created.
{
#if defined(OS_MACOSX)
// Mac outputs dumps in the 'completed' directory.
crash_dumps_dir_ = crash_dumps_dir_.Append("completed");
#endif
base::ThreadRestrictions::SetIOAllowed(true);
base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false,
base::FileEnumerator::FILES);
Expand Down
15 changes: 9 additions & 6 deletions headless/lib/headless_content_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include "headless/embedded_resource_pak.h"
#endif

#if defined(OS_MACOSX)
#include "components/crash/content/app/crashpad.h"
#endif

namespace headless {
namespace {
// Keep in sync with content/common/content_constants_internal.h.
Expand Down Expand Up @@ -159,16 +163,17 @@ void HeadlessContentMainDelegate::InitCrashReporter(
g_headless_crash_client.Pointer()->set_crash_dumps_dir(
browser_->options()->crash_dumps_dir);

#if !defined(OS_MACOSX)
#if defined(HEADLESS_USE_BREAKPAD)
if (!browser_->options()->enable_crash_reporter) {
DCHECK(!breakpad::IsCrashReporterEnabled());
return;
}
#if defined(HEADLESS_USE_BREAKPAD)
if (process_type != switches::kZygoteProcess)
breakpad::InitCrashReporter(process_type);
#elif defined(OS_MACOSX)
const bool browser_process = process_type.empty();
crash_reporter::InitializeCrashpad(browser_process, process_type);
#endif // defined(HEADLESS_USE_BREAKPAD)
#endif // !defined(OS_MACOSX)
}

void HeadlessContentMainDelegate::PreSandboxStartup() {
Expand All @@ -181,10 +186,8 @@ void HeadlessContentMainDelegate::PreSandboxStartup() {
#else
if (command_line.HasSwitch(switches::kEnableLogging))
InitLogging(command_line);
#endif
#if !defined(OS_MACOSX)
#endif // defined(OS_WIN)
InitCrashReporter(command_line);
#endif
InitializeResourceBundle();
}

Expand Down

0 comments on commit df51c3e

Please sign in to comment.