Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: chrome/common/logging_chrome.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Add test for assert handlers nesting. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include <initguid.h> 62 #include <initguid.h>
63 #include "base/logging_win.h" 63 #include "base/logging_win.h"
64 #include "base/syslog_logging.h" 64 #include "base/syslog_logging.h"
65 #include "chrome/install_static/install_details.h" 65 #include "chrome/install_static/install_details.h"
66 #endif 66 #endif
67 67
68 namespace { 68 namespace {
69 69
70 // When true, this means that error dialogs should not be shown. 70 // When true, this means that error dialogs should not be shown.
71 bool dialogs_are_suppressed_ = false; 71 bool dialogs_are_suppressed_ = false;
72 logging::ScopedLogAssertHandler* assert_handler_ = nullptr;
72 73
73 // This should be true for exactly the period between the end of 74 // This should be true for exactly the period between the end of
74 // InitChromeLogging() and the beginning of CleanupChromeLogging(). 75 // InitChromeLogging() and the beginning of CleanupChromeLogging().
75 bool chrome_logging_initialized_ = false; 76 bool chrome_logging_initialized_ = false;
76 77
77 // Set if we called InitChromeLogging() but failed to initialize. 78 // Set if we called InitChromeLogging() but failed to initialize.
78 bool chrome_logging_failed_ = false; 79 bool chrome_logging_failed_ = false;
79 80
80 // This should be true for exactly the period between the end of 81 // This should be true for exactly the period between the end of
81 // InitChromeLogging() and the beginning of CleanupChromeLogging(). 82 // InitChromeLogging() and the beginning of CleanupChromeLogging().
82 bool chrome_logging_redirected_ = false; 83 bool chrome_logging_redirected_ = false;
83 84
84 #if defined(OS_WIN) 85 #if defined(OS_WIN)
85 // {7FE69228-633E-4f06-80C1-527FEA23E3A7} 86 // {7FE69228-633E-4f06-80C1-527FEA23E3A7}
86 const GUID kChromeTraceProviderName = { 87 const GUID kChromeTraceProviderName = {
87 0x7fe69228, 0x633e, 0x4f06, 88 0x7fe69228, 0x633e, 0x4f06,
88 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } }; 89 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } };
89 #endif 90 #endif
90 91
91 // Assertion handler for logging errors that occur when dialogs are 92 // Assertion handler for logging errors that occur when dialogs are
92 // silenced. To record a new error, pass the log string associated 93 // silenced. To record a new error, pass the log string associated
93 // with that error in the str parameter. 94 // with that error in the str parameter.
94 MSVC_DISABLE_OPTIMIZE(); 95 MSVC_DISABLE_OPTIMIZE();
95 void SilentRuntimeAssertHandler(const std::string& str) { 96 void SilentRuntimeAssertHandler(const char* file,
97 int line,
98 const base::StringPiece message,
99 const base::StringPiece stack_trace) {
96 base::debug::BreakDebugger(); 100 base::debug::BreakDebugger();
97 } 101 }
98 MSVC_ENABLE_OPTIMIZE(); 102 MSVC_ENABLE_OPTIMIZE();
99 103
100 // Suppresses error/assertion dialogs and enables the logging of 104 // Suppresses error/assertion dialogs and enables the logging of
101 // those errors into silenced_errors_. 105 // those errors into silenced_errors_.
102 void SuppressDialogs() { 106 void SuppressDialogs() {
103 if (dialogs_are_suppressed_) 107 if (dialogs_are_suppressed_)
104 return; 108 return;
105 109
106 logging::SetLogAssertHandler(SilentRuntimeAssertHandler); 110 assert_handler_ = new logging::ScopedLogAssertHandler(
111 base::Bind(SilentRuntimeAssertHandler));
107 112
108 #if defined(OS_WIN) 113 #if defined(OS_WIN)
109 UINT new_flags = SEM_FAILCRITICALERRORS | 114 UINT new_flags = SEM_FAILCRITICALERRORS |
110 SEM_NOGPFAULTERRORBOX | 115 SEM_NOGPFAULTERRORBOX |
111 SEM_NOOPENFILEERRORBOX; 116 SEM_NOOPENFILEERRORBOX;
112 117
113 // Preserve existing error mode, as discussed at http://t/dmea 118 // Preserve existing error mode, as discussed at http://t/dmea
114 UINT existing_flags = SetErrorMode(new_flags); 119 UINT existing_flags = SetErrorMode(new_flags);
115 SetErrorMode(existing_flags | new_flags); 120 SetErrorMode(existing_flags | new_flags);
116 #endif 121 #endif
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 time_deets.year, 421 time_deets.year,
417 time_deets.month, 422 time_deets.month,
418 time_deets.day_of_month, 423 time_deets.day_of_month,
419 time_deets.hour, 424 time_deets.hour,
420 time_deets.minute, 425 time_deets.minute,
421 time_deets.second); 426 time_deets.second);
422 return base_path.InsertBeforeExtensionASCII(suffix); 427 return base_path.InsertBeforeExtensionASCII(suffix);
423 } 428 }
424 429
425 } // namespace logging 430 } // namespace logging
OLDNEW
« no previous file with comments | « base/test/test_suite.cc ('k') | ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698