OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 // Need to include this before most other files because it defines | 7 // Need to include this before most other files because it defines |
8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the | 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the |
10 // ViewMsgLog et al. functions. | 10 // ViewMsgLog et al. functions. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } }; | 83 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } }; |
84 #endif | 84 #endif |
85 | 85 |
86 // Assertion handler for logging errors that occur when dialogs are | 86 // Assertion handler for logging errors that occur when dialogs are |
87 // silenced. To record a new error, pass the log string associated | 87 // silenced. To record a new error, pass the log string associated |
88 // with that error in the str parameter. | 88 // with that error in the str parameter. |
89 MSVC_DISABLE_OPTIMIZE(); | 89 MSVC_DISABLE_OPTIMIZE(); |
90 void SilentRuntimeAssertHandler(const std::string& str) { | 90 void SilentRuntimeAssertHandler(const std::string& str) { |
91 base::debug::BreakDebugger(); | 91 base::debug::BreakDebugger(); |
92 } | 92 } |
93 void SilentRuntimeReportHandler(const std::string& str) { | |
94 } | |
95 #if defined(OS_WIN) | |
96 // Handler to silently dump the current process when there is an assert in | |
97 // chrome. | |
98 void DumpProcessAssertHandler(const std::string& str) { | |
99 base::debug::DumpWithoutCrashing(); | |
100 } | |
101 #endif // OS_WIN | |
102 MSVC_ENABLE_OPTIMIZE(); | 93 MSVC_ENABLE_OPTIMIZE(); |
103 | 94 |
104 // Suppresses error/assertion dialogs and enables the logging of | 95 // Suppresses error/assertion dialogs and enables the logging of |
105 // those errors into silenced_errors_. | 96 // those errors into silenced_errors_. |
106 void SuppressDialogs() { | 97 void SuppressDialogs() { |
107 if (dialogs_are_suppressed_) | 98 if (dialogs_are_suppressed_) |
108 return; | 99 return; |
109 | 100 |
110 logging::SetLogAssertHandler(SilentRuntimeAssertHandler); | 101 logging::SetLogAssertHandler(SilentRuntimeAssertHandler); |
111 logging::SetLogReportHandler(SilentRuntimeReportHandler); | |
112 | 102 |
113 #if defined(OS_WIN) | 103 #if defined(OS_WIN) |
114 UINT new_flags = SEM_FAILCRITICALERRORS | | 104 UINT new_flags = SEM_FAILCRITICALERRORS | |
115 SEM_NOGPFAULTERRORBOX | | 105 SEM_NOGPFAULTERRORBOX | |
116 SEM_NOOPENFILEERRORBOX; | 106 SEM_NOOPENFILEERRORBOX; |
117 | 107 |
118 // Preserve existing error mode, as discussed at http://t/dmea | 108 // Preserve existing error mode, as discussed at http://t/dmea |
119 UINT existing_flags = SetErrorMode(new_flags); | 109 UINT existing_flags = SetErrorMode(new_flags); |
120 SetErrorMode(existing_flags | new_flags); | 110 SetErrorMode(existing_flags | new_flags); |
121 #endif | 111 #endif |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } else { | 341 } else { |
352 DLOG(WARNING) << "Bad log level: " << log_level; | 342 DLOG(WARNING) << "Bad log level: " << log_level; |
353 } | 343 } |
354 } | 344 } |
355 | 345 |
356 #if defined(OS_WIN) | 346 #if defined(OS_WIN) |
357 // Enable trace control and transport through event tracing for Windows. | 347 // Enable trace control and transport through event tracing for Windows. |
358 logging::LogEventProvider::Initialize(kChromeTraceProviderName); | 348 logging::LogEventProvider::Initialize(kChromeTraceProviderName); |
359 #endif | 349 #endif |
360 | 350 |
361 #if DCHECK_IS_ON && defined(NDEBUG) && defined(OS_WIN) | |
362 if (command_line.HasSwitch(switches::kSilentDumpOnDCHECK)) | |
363 logging::SetLogReportHandler(DumpProcessAssertHandler); | |
364 #endif | |
365 | |
366 chrome_logging_initialized_ = true; | 351 chrome_logging_initialized_ = true; |
367 } | 352 } |
368 | 353 |
369 // This is a no-op, but we'll keep it around in case | 354 // This is a no-op, but we'll keep it around in case |
370 // we need to do more cleanup in the future. | 355 // we need to do more cleanup in the future. |
371 void CleanupChromeLogging() { | 356 void CleanupChromeLogging() { |
372 if (chrome_logging_failed_) | 357 if (chrome_logging_failed_) |
373 return; // We failed to initiailize logging, no cleanup. | 358 return; // We failed to initiailize logging, no cleanup. |
374 | 359 |
375 DCHECK(chrome_logging_initialized_) << | 360 DCHECK(chrome_logging_initialized_) << |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 time_deets.year, | 424 time_deets.year, |
440 time_deets.month, | 425 time_deets.month, |
441 time_deets.day_of_month, | 426 time_deets.day_of_month, |
442 time_deets.hour, | 427 time_deets.hour, |
443 time_deets.minute, | 428 time_deets.minute, |
444 time_deets.second); | 429 time_deets.second); |
445 return base_path.InsertBeforeExtensionASCII(suffix); | 430 return base_path.InsertBeforeExtensionASCII(suffix); |
446 } | 431 } |
447 | 432 |
448 } // namespace logging | 433 } // namespace logging |
OLD | NEW |