diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-23 07:04:00 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-23 07:04:00 +0000 |
commit | d6d06a3517f9549488826a9f5faac5cdb678e992 (patch) | |
tree | fed51e6cfe5072b5a7a25622a8ea99d55043770c | |
parent | 6814d22bc067acf0966db195b9244f0ec7eed8fb (diff) | |
download | chromium_src-d6d06a3517f9549488826a9f5faac5cdb678e992.zip chromium_src-d6d06a3517f9549488826a9f5faac5cdb678e992.tar.gz chromium_src-d6d06a3517f9549488826a9f5faac5cdb678e992.tar.bz2 |
Introduce ShellBreakpadClient and install it.
We're not yet initializing breakpad, as this is not yet posible on all
supported platforms.
Also change some defaults of BreakpadClient so I have to override fewer
methods.
BUG=247431
R=rsesek@chromium.org
Review URL: https://codereview.chromium.org/27647002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230358 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | components/breakpad/app/breakpad_client.cc | 6 | ||||
-rw-r--r-- | content/content_shell.gypi | 3 | ||||
-rw-r--r-- | content/shell/DEPS | 2 | ||||
-rw-r--r-- | content/shell/android/shell_descriptors.h | 5 | ||||
-rw-r--r-- | content/shell/app/shell_breakpad_client.cc | 62 | ||||
-rw-r--r-- | content/shell/app/shell_breakpad_client.h | 52 | ||||
-rw-r--r-- | content/shell/app/shell_main_delegate.cc | 10 | ||||
-rw-r--r-- | content/shell/browser/shell_content_browser_client.cc | 7 | ||||
-rw-r--r-- | content/shell/common/shell_switches.cc | 3 | ||||
-rw-r--r-- | content/shell/common/shell_switches.h | 1 |
10 files changed, 147 insertions, 4 deletions
diff --git a/components/breakpad/app/breakpad_client.cc b/components/breakpad/app/breakpad_client.cc index 0c488da..16f7dc7 100644 --- a/components/breakpad/app/breakpad_client.cc +++ b/components/breakpad/app/breakpad_client.cc @@ -50,7 +50,7 @@ bool BreakpadClient::ShouldShowRestartDialog(base::string16* title, } bool BreakpadClient::AboutToRestart() { - return true; + return false; } bool BreakpadClient::GetDeferredUploadsSupported(bool is_per_usr_install) { @@ -58,7 +58,7 @@ bool BreakpadClient::GetDeferredUploadsSupported(bool is_per_usr_install) { } bool BreakpadClient::GetIsPerUserInstall(const base::FilePath& exe_path) { - return false; + return true; } bool BreakpadClient::GetShouldDumpLargerDumps(bool is_per_user_install) { @@ -100,7 +100,7 @@ size_t BreakpadClient::RegisterCrashKeys() { } bool BreakpadClient::IsRunningUnattended() { - return false; + return true; } #if defined(OS_WIN) || defined(OS_MACOSX) diff --git a/content/content_shell.gypi b/content/content_shell.gypi index e6cdd95..6c2188d 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -40,6 +40,7 @@ 'content_resources.gyp:content_resources', '../base/base.gyp:base', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + '../components/components.gyp:breakpad_component', '../ipc/ipc.gyp:ipc', '../media/media.gyp:media', '../net/net.gyp:net', @@ -67,6 +68,8 @@ 'shell/android/shell_manager.h', 'shell/app/paths_mac.h', 'shell/app/paths_mac.mm', + 'shell/app/shell_breakpad_client.cc', + 'shell/app/shell_breakpad_client.h', 'shell/app/shell_main_delegate.cc', 'shell/app/shell_main_delegate.h', 'shell/app/shell_main_delegate_mac.h', diff --git a/content/shell/DEPS b/content/shell/DEPS index 0943fd0..3738104 100644 --- a/content/shell/DEPS +++ b/content/shell/DEPS @@ -22,6 +22,8 @@ include_rules = [ # For WebTestRunner library "+third_party/WebKit/public/testing", + + "+components/breakpad", ] specific_include_rules = { diff --git a/content/shell/android/shell_descriptors.h b/content/shell/android/shell_descriptors.h index 8bcd376..9441813 100644 --- a/content/shell/android/shell_descriptors.h +++ b/content/shell/android/shell_descriptors.h @@ -5,10 +5,13 @@ #ifndef CONTENT_SHELL_ANDROID_SHELL_DESCRIPTORS_H_ #define CONTENT_SHELL_ANDROID_SHELL_DESCRIPTORS_H_ +#include "content/public/common/content_descriptors.h" + // This is a list of global descriptor keys to be used with the // base::GlobalDescriptors object (see base/posix/global_descriptors.h) enum { - kShellPakDescriptor = 1, + kShellPakDescriptor = kContentIPCDescriptorMax + 1, + kAndroidMinidumpDescriptor, }; #endif // CONTENT_SHELL_ANDROID_SHELL_DESCRIPTORS_H_ diff --git a/content/shell/app/shell_breakpad_client.cc b/content/shell/app/shell_breakpad_client.cc new file mode 100644 index 0000000..c4dd86d --- /dev/null +++ b/content/shell/app/shell_breakpad_client.cc @@ -0,0 +1,62 @@ +// Copyright 2013 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 "content/shell/app/shell_breakpad_client.h" + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "content/shell/common/shell_switches.h" + +#if defined(OS_ANDROID) +#include "content/shell/android/shell_descriptors.h" +#endif + +namespace content { + +ShellBreakpadClient::ShellBreakpadClient() {} +ShellBreakpadClient::~ShellBreakpadClient() {} + +#if defined(OS_WIN) +void ShellBreakpadClient::GetProductNameAndVersion( + const base::FilePath& exe_path, + base::string16* product_name, + base::string16* version, + base::string16* special_build, + base::string16* channel_name) { + *product_name = ASCIIToUTF16("content_shell"); + *version = ASCIIToUTF16(CONTENT_SHELL_VERSION); + *special_build = string16(); + *channel_name = string16(); +} +#endif + +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS) +void ShellBreakpadClient::GetProductNameAndVersion(std::string* product_name, + std::string* version) { + *product_name = "content_shell"; + *version = CONTENT_SHELL_VERSION; +} + +base::FilePath ShellBreakpadClient::GetReporterLogFilename() { + return base::FilePath(FILE_PATH_LITERAL("uploads.log")); +} +#endif + +bool ShellBreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) { + if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir)) + return false; + *crash_dir = CommandLine::ForCurrentProcess()->GetSwitchValuePath( + switches::kCrashDumpsDir); + return true; +} + +#if defined(OS_ANDROID) +int ShellBreakpadClient::GetAndroidMinidumpDescriptor() { + return kAndroidMinidumpDescriptor; +} +#endif + +} // namespace content diff --git a/content/shell/app/shell_breakpad_client.h b/content/shell/app/shell_breakpad_client.h new file mode 100644 index 0000000..63d3024 --- /dev/null +++ b/content/shell/app/shell_breakpad_client.h @@ -0,0 +1,52 @@ +// Copyright 2013 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 CONTENT_SHELL_APP_SHELL_BREAKPAD_CLIENT_H_ +#define CONTENT_SHELL_APP_SHELL_BREAKPAD_CLIENT_H_ + +#include "base/compiler_specific.h" +#include "components/breakpad/app/breakpad_client.h" + +namespace content { + +class ShellBreakpadClient : public breakpad::BreakpadClient { + public: + ShellBreakpadClient(); + virtual ~ShellBreakpadClient(); + +#if defined(OS_WIN) + // Returns a textual description of the product type and version to include + // in the crash report. + virtual void GetProductNameAndVersion(const base::FilePath& exe_path, + base::string16* product_name, + base::string16* version, + base::string16* special_build, + base::string16* channel_name) OVERRIDE; +#endif + +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS) + // Returns a textual description of the product type and version to include + // in the crash report. + virtual void GetProductNameAndVersion(std::string* product_name, + std::string* version) OVERRIDE; + + virtual base::FilePath GetReporterLogFilename() OVERRIDE; +#endif + + // The location where minidump files should be written. Returns true if + // |crash_dir| was set. + virtual bool GetCrashDumpLocation(base::FilePath* crash_dir) OVERRIDE; + +#if defined(OS_ANDROID) + // Returns the descriptor key of the android minidump global descriptor. + virtual int GetAndroidMinidumpDescriptor() OVERRIDE; +#endif + +private: + DISALLOW_COPY_AND_ASSIGN(ShellBreakpadClient); +}; + +} // namespace content + +#endif // CONTENT_SHELL_APP_SHELL_BREAKPAD_CLIENT_H_ diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc index f7f6e14..d0db696 100644 --- a/content/shell/app/shell_main_delegate.cc +++ b/content/shell/app/shell_main_delegate.cc @@ -4,8 +4,10 @@ #include "content/shell/app/shell_main_delegate.h" +#include "base/base_switches.h" #include "base/command_line.h" #include "base/files/file_path.h" +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/path_service.h" #include "cc/base/switches.h" @@ -13,6 +15,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/url_constants.h" #include "content/public/test/layouttest_support.h" +#include "content/shell/app/shell_breakpad_client.h" #include "content/shell/app/webkit_test_platform_support.h" #include "content/shell/browser/shell_browser_main.h" #include "content/shell/browser/shell_content_browser_client.h" @@ -53,6 +56,9 @@ namespace { +base::LazyInstance<content::ShellBreakpadClient>::Leaky + g_shell_breakpad_client = LAZY_INSTANCE_INITIALIZER; + #if defined(OS_WIN) // If "Content Shell" doesn't show up in your list of trace providers in // Sawbuck, add these registry entries to your machine (NOTE the optional @@ -174,6 +180,10 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { } void ShellMainDelegate::PreSandboxStartup() { + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableCrashReporter)) { + breakpad::SetBreakpadClient(g_shell_breakpad_client.Pointer()); + } InitializeResourceBundle(); } diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc index 0facfaec..e482176 100644 --- a/content/shell/browser/shell_content_browser_client.cc +++ b/content/shell/browser/shell_content_browser_client.cc @@ -4,6 +4,7 @@ #include "content/shell/browser/shell_content_browser_client.h" +#include "base/base_switches.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/path_service.h" @@ -146,6 +147,12 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches( command_line->AppendSwitch(switches::kExposeInternalsForTesting); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStableReleaseMode)) command_line->AppendSwitch(switches::kStableReleaseMode); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableCrashReporter)) { + command_line->AppendSwitch(switches::kEnableCrashReporter); + } + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir)) + command_line->AppendSwitch(switches::kCrashDumpsDir); } void ShellContentBrowserClient::OverrideWebkitPrefs( diff --git a/content/shell/common/shell_switches.cc b/content/shell/common/shell_switches.cc index a00af456..6c16104 100644 --- a/content/shell/common/shell_switches.cc +++ b/content/shell/common/shell_switches.cc @@ -18,6 +18,9 @@ const char kContentBrowserTest[] = "browser-test"; // Makes Content Shell use the given path for its data directory. const char kContentShellDataPath[] = "data-path"; +// The directory breakpad should store minidumps in. +const char kCrashDumpsDir[] = "crash-dumps-dir"; + // Request pages to be dumped as text once they finished loading. const char kDumpRenderTree[] = "dump-render-tree"; diff --git a/content/shell/common/shell_switches.h b/content/shell/common/shell_switches.h index d6b936a..7883548 100644 --- a/content/shell/common/shell_switches.h +++ b/content/shell/common/shell_switches.h @@ -13,6 +13,7 @@ extern const char kAllowExternalPages[]; extern const char kCheckLayoutTestSysDeps[]; extern const char kContentBrowserTest[]; extern const char kContentShellDataPath[]; +extern const char kCrashDumpsDir[]; extern const char kDumpRenderTree[]; extern const char kEnableAccelerated2DCanvas[]; extern const char kEncodeBinary[]; |