summaryrefslogtreecommitdiffstats
path: root/chrome/common/logging_chrome.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 22:24:14 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 22:24:14 +0000
commitab7ee5b9ea55005503231ebfa6cf0b834eeb359e (patch)
tree3d3ef6ea9fd71c13daa8fbfd4f828988d8c262e6 /chrome/common/logging_chrome.cc
parent336091a66a00ef384627a540501af965e42c6aeb (diff)
downloadchromium_src-ab7ee5b9ea55005503231ebfa6cf0b834eeb359e.zip
chromium_src-ab7ee5b9ea55005503231ebfa6cf0b834eeb359e.tar.gz
chromium_src-ab7ee5b9ea55005503231ebfa6cf0b834eeb359e.tar.bz2
startup: move a bit of logging initialization into InitChromeLogging
Previously we called InitChromeLogging() and then did a bit more logging setup just afterwards. This change moves the follow-up setup into InitChromeLogging as well. While I'm at it, I renamed the dumping function to something more descriptive and used an anonymous namespace rather than "static"s. Review URL: http://codereview.chromium.org/6596077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/logging_chrome.cc')
-rw-r--r--chrome/common/logging_chrome.cc44
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;
}