Skip to content

Commit

Permalink
Move Linux/Android breakpad implementation to breakpad component
Browse files Browse the repository at this point in the history
Also split up breakpad component in more subdirectories and tighten up DEPS
rules

BUG=247431
[email protected]
[email protected]

Review URL: https://codereview.chromium.org/31243002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229964 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
[email protected] committed Oct 22, 2013
1 parent 774a58c commit 0b818f7
Show file tree
Hide file tree
Showing 37 changed files with 231 additions and 158 deletions.
2 changes: 1 addition & 1 deletion PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
),
True,
(
r"^components[\\\/]breakpad[\\\/]breakpad_mac\.mm$",
r"^components[\\\/]breakpad[\\\/]app[\\\/]breakpad_mac\.mm$",
r"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$",
r"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$",
r"^net[\\\/]disk_cache[\\\/]cache_util\.cc$",
Expand Down
1 change: 0 additions & 1 deletion chrome/app/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ include_rules = [
"+policy", # For generated headers and source
"+sandbox",
"+tools/memory_watcher",
"+third_party/lss/linux_syscall_support.h",
]
2 changes: 1 addition & 1 deletion chrome/app/chrome_breakpad_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "components/breakpad/breakpad_client.h"
#include "components/breakpad/app/breakpad_client.h"

namespace chrome {

Expand Down
4 changes: 2 additions & 2 deletions chrome/app/chrome_exe_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "chrome/browser/policy/policy_path_parser.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "components/breakpad/breakpad_client.h"
#include "components/breakpad/breakpad_win.h"
#include "components/breakpad/app/breakpad_client.h"
#include "components/breakpad/app/breakpad_win.h"
#include "content/public/app/startup_helper_win.h"
#include "content/public/common/result_codes.h"
#include "sandbox/win/src/sandbox_factory.h"
Expand Down
12 changes: 6 additions & 6 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/mac/cfbundle_blocker.h"
#include "chrome/common/mac/objc_zombie.h"
#include "components/breakpad/breakpad_mac.h"
#include "components/breakpad/app/breakpad_mac.h"
#include "grit/chromium_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
#endif
Expand All @@ -68,7 +68,7 @@
#include <locale.h>
#include <signal.h>
#include "chrome/app/chrome_breakpad_client.h"
#include "components/breakpad/breakpad_client.h"
#include "components/breakpad/app/breakpad_client.h"
#endif

#if !defined(DISABLE_NACL) && defined(OS_LINUX)
Expand Down Expand Up @@ -98,7 +98,7 @@
#endif

#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "chrome/app/breakpad_linux.h"
#include "components/breakpad/app/breakpad_linux.h"
#endif

#if !defined(CHROME_MULTIPLE_DLL_CHILD)
Expand Down Expand Up @@ -739,9 +739,9 @@ void ChromeMainDelegate::PreSandboxStartup() {
// need to call InitCrashReporter() in RunZygote().
if (!process_type.empty() && process_type != switches::kZygoteProcess) {
#if defined(OS_ANDROID)
InitNonBrowserCrashReporterForAndroid();
breakpad::InitNonBrowserCrashReporterForAndroid();
#else
InitCrashReporter();
breakpad::InitCrashReporter();
#endif
}
#endif
Expand Down Expand Up @@ -845,7 +845,7 @@ void ChromeMainDelegate::ZygoteForked() {
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets
// this up for the browser process in a different manner.
InitCrashReporter();
breakpad::InitCrashReporter();

// Reset the command line for the newly spawned process.
crash_keys::SetSwitchesFromCommandLine(CommandLine::ForCurrentProcess());
Expand Down
2 changes: 1 addition & 1 deletion chrome/app/client_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/util_constants.h"
#include "components/breakpad/breakpad_win.h"
#include "components/breakpad/app/breakpad_win.h"

namespace {
// The entry point signature of chrome.dll.
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/chrome_browser_main_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include "base/debug/trace_event.h"
#include "base/path_service.h"
#include "cc/base/switches.h"
#include "chrome/app/breakpad_linux.h"
#include "chrome/browser/android/crash_dump_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/breakpad/app/breakpad_linux.h"
#include "components/breakpad/browser/crash_dump_manager_android.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/common/main_function_params.h"
#include "net/android/network_change_notifier_factory_android.h"
Expand Down Expand Up @@ -44,10 +44,10 @@ void ChromeBrowserMainPartsAndroid::PreProfileInit() {
switches::kEnableCrashReporterForTesting);

if (breakpad_enabled) {
InitCrashReporter();
breakpad::InitCrashReporter();
base::FilePath crash_dump_dir;
PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir);
crash_dump_manager_.reset(new CrashDumpManager(crash_dump_dir));
crash_dump_manager_.reset(new breakpad::CrashDumpManager(crash_dump_dir));
}

ChromeBrowserMainParts::PreProfileInit();
Expand Down
4 changes: 3 additions & 1 deletion chrome/browser/chrome_browser_main_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include "chrome/browser/chrome_browser_main.h"

namespace breakpad {
class CrashDumpManager;
}

class ChromeBrowserMainPartsAndroid : public ChromeBrowserMainParts {
public:
Expand All @@ -24,7 +26,7 @@ class ChromeBrowserMainPartsAndroid : public ChromeBrowserMainParts {

private:
scoped_ptr<base::MessageLoop> main_message_loop_;
scoped_ptr<CrashDumpManager> crash_dump_manager_;
scoped_ptr<breakpad::CrashDumpManager> crash_dump_manager_;

DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainPartsAndroid);
};
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chrome_browser_main_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "base/command_line.h"
#include "base/linux_util.h"
#include "base/prefs/pref_service.h"
#include "chrome/app/breakpad_linux.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/pref_names.h"
#include "components/breakpad/app/breakpad_linux.h"

#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/settings/cros_settings.h"
Expand Down Expand Up @@ -122,7 +122,7 @@ void ChromeBrowserMainPartsLinux::PreProfileInit() {
#endif

if (IsCrashReportingEnabled(local_state()))
InitCrashReporter();
breakpad::InitCrashReporter();

ChromeBrowserMainPartsPosix::PreProfileInit();
}
Expand All @@ -131,5 +131,5 @@ void ChromeBrowserMainPartsLinux::PostProfileInit() {
ChromeBrowserMainPartsPosix::PostProfileInit();

g_browser_process->metrics_service()->RecordBreakpadRegistration(
IsCrashReporterEnabled());
breakpad::IsCrashReporterEnabled());
}
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/breakpad/breakpad_mac.h"
#include "components/breakpad/app/breakpad_mac.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/result_codes.h"
#include "ui/base/l10n/l10n_util_mac.h"
Expand Down
37 changes: 18 additions & 19 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
#elif defined(OS_MACOSX)
#include "chrome/browser/chrome_browser_main_mac.h"
#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
#include "components/breakpad/breakpad_mac.h"
#include "components/breakpad/app/breakpad_mac.h"
#elif defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
#include "chrome/browser/chromeos/drive/file_system_backend_delegate.h"
Expand All @@ -164,20 +164,20 @@
#elif defined(OS_LINUX)
#include "chrome/browser/chrome_browser_main_linux.h"
#elif defined(OS_ANDROID)
#include "chrome/browser/android/crash_dump_manager.h"
#include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
#include "chrome/browser/chrome_browser_main_android.h"
#include "chrome/browser/media/encrypted_media_message_filter_android.h"
#include "chrome/common/descriptors_android.h"
#include "components/breakpad/browser/crash_dump_manager_android.h"
#elif defined(OS_POSIX)
#include "chrome/browser/chrome_browser_main_posix.h"
#endif

#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "base/debug/leak_annotations.h"
#include "base/linux_util.h"
#include "chrome/app/breakpad_linux.h"
#include "chrome/browser/crash_handler_host_linux.h"
#include "components/breakpad/app/breakpad_linux.h"
#include "components/breakpad/browser/crash_handler_host_linux.h"
#endif

#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
Expand Down Expand Up @@ -254,10 +254,6 @@ using extensions::Extension;
using extensions::Manifest;
using message_center::NotifierId;

#if defined(OS_MACOSX)
using breakpad::IsCrashReporterEnabled;
#endif

namespace {

// Cached version of the locale so we can return the locale on the I/O
Expand Down Expand Up @@ -495,21 +491,23 @@ void FillFontFamilyMap(const PrefService* prefs,
}

#if defined(OS_POSIX) && !defined(OS_MACOSX)
CrashHandlerHostLinux* CreateCrashHandlerHost(const std::string& process_type) {
breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
const std::string& process_type) {
base::FilePath dumps_path;
PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path);
{
ANNOTATE_SCOPED_MEMORY_LEAK;
CrashHandlerHostLinux* crash_handler = new CrashHandlerHostLinux(
process_type, dumps_path, getenv(env_vars::kHeadless) == NULL);
breakpad::CrashHandlerHostLinux* crash_handler =
new breakpad::CrashHandlerHostLinux(
process_type, dumps_path, getenv(env_vars::kHeadless) == NULL);
crash_handler->StartUploaderThread();
return crash_handler;
}
}

int GetCrashSignalFD(const CommandLine& command_line) {
if (command_line.HasSwitch(switches::kExtensionProcess)) {
static CrashHandlerHostLinux* crash_handler = NULL;
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler)
crash_handler = CreateCrashHandlerHost("extension");
return crash_handler->GetDeathSignalSocket();
Expand All @@ -519,28 +517,28 @@ int GetCrashSignalFD(const CommandLine& command_line) {
command_line.GetSwitchValueASCII(switches::kProcessType);

if (process_type == switches::kRendererProcess) {
static CrashHandlerHostLinux* crash_handler = NULL;
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket();
}

if (process_type == switches::kPluginProcess) {
static CrashHandlerHostLinux* crash_handler = NULL;
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket();
}

if (process_type == switches::kPpapiPluginProcess) {
static CrashHandlerHostLinux* crash_handler = NULL;
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket();
}

if (process_type == switches::kGpuProcess) {
static CrashHandlerHostLinux* crash_handler = NULL;
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
if (!crash_handler)
crash_handler = CreateCrashHandlerHost(process_type);
return crash_handler->GetDeathSignalSocket();
Expand Down Expand Up @@ -1366,7 +1364,7 @@ std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
CommandLine* command_line, int child_process_id) {
#if defined(OS_POSIX)
if (IsCrashReporterEnabled()) {
if (breakpad::IsCrashReporterEnabled()) {
std::string enable_crash_reporter;
GoogleUpdateSettings::GetMetricsId(&enable_crash_reporter);
#if !defined(OS_MACOSX)
Expand Down Expand Up @@ -2530,8 +2528,9 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor,
FileDescriptor(f, true)));

if (IsCrashReporterEnabled()) {
f = CrashDumpManager::GetInstance()->CreateMinidumpFile(child_process_id);
if (breakpad::IsCrashReporterEnabled()) {
f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
child_process_id);
if (f == base::kInvalidPlatformFileValue) {
LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
"be disabled for this process.";
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/login/wizard_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "base/prefs/pref_service.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "chrome/app/breakpad_linux.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
Expand Down Expand Up @@ -58,6 +57,7 @@
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/settings/cros_settings_names.h"
#include "components/breakpad/app/breakpad_linux.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -482,7 +482,7 @@ void WizardController::OnEulaAccepted() {
#if defined(GOOGLE_CHROME_BUILD)
// The crash reporter initialization needs IO to complete.
base::ThreadRestrictions::ScopedAllowIO allow_io;
InitCrashReporter();
breakpad::InitCrashReporter();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/cocoa/first_run_dialog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/google_update_settings.h"
#import "components/breakpad/breakpad_mac.h"
#import "components/breakpad/app/breakpad_mac.h"
#endif

@interface FirstRunDialogController (PrivateMethods)
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/gtk/first_run_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "base/i18n/rtl.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/breakpad_linux.h"
#include "chrome/browser/first_run/first_run_dialog.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/process_singleton.h"
Expand All @@ -20,6 +19,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "components/breakpad/app/breakpad_linux.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
Expand Down Expand Up @@ -164,7 +164,7 @@ void FirstRunDialog::OnResponseDialog(GtkWidget* widget, int response) {
if (report_crashes_ &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(report_crashes_))) {
if (GoogleUpdateSettings::SetCollectStatsConsent(true))
InitCrashReporter();
breakpad::InitCrashReporter();
} else {
GoogleUpdateSettings::SetCollectStatsConsent(false);
}
Expand Down
Loading

0 comments on commit 0b818f7

Please sign in to comment.