mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add breakpad support (issue #1131).
- General usage instructions are available at https://sites.google.com/a/chromium.org/dev/developers/testing/webkit-layout-tests/using-breakpad-with-content-shell. - Mac: Generate "Chromium Embedded Framework.framework" using a new cef_framework target (the libcef target is now only used on Windows and Linux). Rename "Libraries/libcef.dylib" to "Chromium Embedded Framework". Distribute Release and Debug builds of the "Chromium Embedded Framework.framework" folder as part of the binary distribution. - Mac: Fix the Xcode target compiler setting for the binary distribution so that it no longer needs to be set manually. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1524 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
58
libcef/common/breakpad_client.cc
Normal file
58
libcef/common/breakpad_client.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
// 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 "libcef/common/breakpad_client.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "include/cef_version.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
||||
CefBreakpadClient::CefBreakpadClient() {}
|
||||
CefBreakpadClient::~CefBreakpadClient() {}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void CefBreakpadClient::GetProductNameAndVersion(
|
||||
const base::FilePath& exe_path,
|
||||
base::string16* product_name,
|
||||
base::string16* version,
|
||||
base::string16* special_build,
|
||||
base::string16* channel_name) {
|
||||
*product_name = ASCIIToUTF16("cef");
|
||||
*version = UTF8ToUTF16(base::StringPrintf(
|
||||
"%d.%d.%d", CEF_VERSION_MAJOR, CHROME_VERSION_BUILD, CEF_REVISION));
|
||||
*special_build = string16();
|
||||
*channel_name = string16();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
|
||||
void CefBreakpadClient::GetProductNameAndVersion(std::string* product_name,
|
||||
std::string* version) {
|
||||
*product_name = "cef";
|
||||
*version = base::StringPrintf(
|
||||
"%d.%d.%d", CEF_VERSION_MAJOR, CHROME_VERSION_BUILD, CEF_REVISION);
|
||||
}
|
||||
|
||||
base::FilePath CefBreakpadClient::GetReporterLogFilename() {
|
||||
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CefBreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
|
||||
#if !defined(OS_WIN)
|
||||
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir))
|
||||
return false;
|
||||
*crash_dir = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
||||
switches::kCrashDumpsDir);
|
||||
return true;
|
||||
#else
|
||||
NOTREACHED();
|
||||
return false;
|
||||
#endif
|
||||
}
|
43
libcef/common/breakpad_client.h
Normal file
43
libcef/common/breakpad_client.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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 CEF_LIBCEF_COMMON_BREAKPAD_CLIENT_H_
|
||||
#define CEF_LIBCEF_COMMON_BREAKPAD_CLIENT_H_
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "components/breakpad/app/breakpad_client.h"
|
||||
|
||||
class CefBreakpadClient : public breakpad::BreakpadClient {
|
||||
public:
|
||||
CefBreakpadClient();
|
||||
virtual ~CefBreakpadClient();
|
||||
|
||||
#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;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBreakpadClient);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_BREAKPAD_CLIENT_H_
|
@@ -86,4 +86,7 @@ const char kEnableSpeechInput[] = "enable-speech-input";
|
||||
// Enable the speech input profanity filter.
|
||||
const char kEnableProfanityFilter[] = "enable-profanity-filter";
|
||||
|
||||
// The directory breakpad should store minidumps in.
|
||||
const char kCrashDumpsDir[] = "crash-dumps-dir";
|
||||
|
||||
} // namespace switches
|
||||
|
@@ -39,6 +39,7 @@ extern const char kPersistSessionCookies[];
|
||||
extern const char kEnableMediaStream[];
|
||||
extern const char kEnableSpeechInput[];
|
||||
extern const char kEnableProfanityFilter[];
|
||||
extern const char kCrashDumpsDir[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
|
@@ -5,13 +5,16 @@
|
||||
#include "libcef/common/main_delegate.h"
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/common/breakpad_client.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/command_line_impl.h"
|
||||
#include "libcef/renderer/content_renderer_client.h"
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@@ -28,16 +31,26 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <Objbase.h> // NOLINT(build/include_order)
|
||||
#include "components/breakpad/app/breakpad_win.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "base/mac/os_crash_dumps.h"
|
||||
#include "base/mac/bundle_locations.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "components/breakpad/app/breakpad_mac.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
#include "components/breakpad/app/breakpad_linux.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
base::LazyInstance<CefBreakpadClient>::Leaky g_shell_breakpad_client =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
||||
base::FilePath GetFrameworksPath() {
|
||||
@@ -345,6 +358,26 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
void CefMainDelegate::PreSandboxStartup() {
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
|
||||
if (command_line.HasSwitch(switches::kEnableCrashReporter)) {
|
||||
breakpad::SetBreakpadClient(g_shell_breakpad_client.Pointer());
|
||||
#if defined(OS_MACOSX)
|
||||
base::mac::DisableOSCrashDumps();
|
||||
breakpad::InitCrashReporter();
|
||||
breakpad::InitCrashProcessInfo();
|
||||
#elif defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
std::string process_type = command_line.GetSwitchValueASCII(
|
||||
switches::kProcessType);
|
||||
if (process_type != switches::kZygoteProcess)
|
||||
breakpad::InitCrashReporter();
|
||||
#elif defined(OS_WIN)
|
||||
UINT new_flags =
|
||||
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
|
||||
UINT existing_flags = SetErrorMode(new_flags);
|
||||
SetErrorMode(existing_flags | new_flags);
|
||||
breakpad::InitCrashReporter();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
if (!command_line.HasSwitch(switches::kProcessType)) {
|
||||
// Only override the child process path when executing the main process.
|
||||
@@ -396,6 +429,14 @@ void CefMainDelegate::ProcessExiting(const std::string& process_type) {
|
||||
ResourceBundle::CleanupSharedInstance();
|
||||
}
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
|
||||
void CefMainDelegate::ZygoteForked() {
|
||||
if (CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableCrashReporter)) {
|
||||
breakpad::InitCrashReporter();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
content::ContentBrowserClient* CefMainDelegate::CreateContentBrowserClient() {
|
||||
browser_client_.reset(new CefContentBrowserClient);
|
||||
|
@@ -39,6 +39,9 @@ class CefMainDelegate : public content::ContentMainDelegate {
|
||||
const std::string& process_type,
|
||||
const content::MainFunctionParams& main_function_params) OVERRIDE;
|
||||
virtual void ProcessExiting(const std::string& process_type) OVERRIDE;
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
|
||||
virtual void ZygoteForked() OVERRIDE;
|
||||
#endif
|
||||
virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
|
||||
virtual content::ContentRendererClient*
|
||||
CreateContentRendererClient() OVERRIDE;
|
||||
|
Reference in New Issue
Block a user