diff options
author | Kristian Monsen <kristianm@google.com> | 2011-06-09 11:47:42 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-29 14:33:03 +0100 |
commit | dc0f95d653279beabeb9817299e2902918ba123e (patch) | |
tree | 32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/common/logging_chrome.cc | |
parent | ba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff) | |
download | external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2 |
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/common/logging_chrome.cc')
-rw-r--r-- | chrome/common/logging_chrome.cc | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index e0f92d9..b17458f 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -43,32 +43,36 @@ #include "base/threading/thread_restrictions.h" #include "base/time.h" #include "base/utf_string_conversions.h" +#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" #include "ipc/ipc_logging.h" + #if defined(OS_WIN) #include "base/logging_win.h" #include <initguid.h> #endif +namespace { + // When true, this means that error dialogs should not be shown. -static bool dialogs_are_suppressed_ = false; +bool dialogs_are_suppressed_ = false; // This should be true for exactly the period between the end of // InitChromeLogging() and the beginning of CleanupChromeLogging(). -static bool chrome_logging_initialized_ = false; +bool chrome_logging_initialized_ = false; // Set if we caled InitChromeLogging() but failed to initialize. -static bool chrome_logging_failed_ = false; +bool chrome_logging_failed_ = false; // This should be true for exactly the period between the end of // InitChromeLogging() and the beginning of CleanupChromeLogging(). -static bool chrome_logging_redirected_ = false; +bool chrome_logging_redirected_ = false; #if defined(OS_WIN) // {7FE69228-633E-4f06-80C1-527FEA23E3A7} -static const GUID kChromeTraceProviderName = { +const GUID kChromeTraceProviderName = { 0x7fe69228, 0x633e, 0x4f06, { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } }; #endif @@ -77,16 +81,29 @@ static const GUID kChromeTraceProviderName = { // silenced. To record a new error, pass the log string associated // with that error in the str parameter. MSVC_DISABLE_OPTIMIZE(); -static void SilentRuntimeAssertHandler(const std::string& str) { +void SilentRuntimeAssertHandler(const std::string& str) { base::debug::BreakDebugger(); } -static void SilentRuntimeReportHandler(const std::string& str) { +void SilentRuntimeReportHandler(const std::string& str) { } +#if defined(OS_WIN) +// Handler to silently dump the current process when there is an assert in +// chrome. +void DumpProcessAssertHandler(const std::string& str) { + // Get the breakpad pointer from chrome.exe + typedef void (__cdecl *DumpProcessFunction)(); + DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( + ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), + "DumpProcess")); + if (DumpProcess) + DumpProcess(); +} +#endif // OS_WIN MSVC_ENABLE_OPTIMIZE(); // Suppresses error/assertion dialogs and enables the logging of // those errors into silenced_errors_. -static void SuppressDialogs() { +void SuppressDialogs() { if (dialogs_are_suppressed_) return; @@ -106,6 +123,8 @@ static void SuppressDialogs() { dialogs_are_suppressed_ = true; } +} // anonymous namespace + namespace logging { LoggingDestination DetermineLogMode(const CommandLine& command_line) { @@ -341,6 +360,15 @@ void InitChromeLogging(const CommandLine& command_line, logging::LogEventProvider::Initialize(kChromeTraceProviderName); #endif +#ifdef NDEBUG + if (command_line.HasSwitch(switches::kSilentDumpOnDCHECK) && + command_line.HasSwitch(switches::kEnableDCHECK)) { +#if defined(OS_WIN) + logging::SetLogReportHandler(DumpProcessAssertHandler); +#endif + } +#endif // NDEBUG + chrome_logging_initialized_ = true; } |