summaryrefslogtreecommitdiffstats
path: root/webkit/support/webkit_support.cc
diff options
context:
space:
mode:
authortkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 02:20:58 +0000
committertkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 02:20:58 +0000
commitd766a00e4e8eeb31271b9d7ef2cf0b120602129f (patch)
tree1799b35ff8bc63411b0a163efb64496dd0dfd8f3 /webkit/support/webkit_support.cc
parentd656b8af5feef13c5d8550e27261f945c563f676 (diff)
downloadchromium_src-d766a00e4e8eeb31271b9d7ef2cf0b120602129f.zip
chromium_src-d766a00e4e8eeb31271b9d7ef2cf0b120602129f.tar.gz
chromium_src-d766a00e4e8eeb31271b9d7ef2cf0b120602129f.tar.bz2
webkit_support: Move the logger initialization code so that it is
called after AtExitManager initialization, and call InitLogging() only if !unit_test_mode. InitLogging() needs AtExitManager because it uses PathService. TEST=This is a part of test code. BUG=none Review URL: http://codereview.chromium.org/3030018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support/webkit_support.cc')
-rw-r--r--webkit/support/webkit_support.cc88
1 files changed, 44 insertions, 44 deletions
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 16611cb5..e354d49 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -51,11 +51,54 @@ using WebKit::WebURL;
namespace {
+// All fatal log messages (e.g. DCHECK failures) imply unit test failures
+void UnitTestAssertHandler(const std::string& str) {
+ FAIL() << str;
+}
+
+void InitLogging(bool enable_gp_fault_error_box) {
+ logging::SetLogAssertHandler(UnitTestAssertHandler);
+
+#if defined(OS_WIN)
+ if (!::IsDebuggerPresent()) {
+ UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
+ if (!enable_gp_fault_error_box)
+ new_flags |= SEM_NOGPFAULTERRORBOX;
+
+ // Preserve existing error mode, as discussed at
+ // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
+ UINT existing_flags = SetErrorMode(new_flags);
+ SetErrorMode(existing_flags | new_flags);
+ }
+#endif
+
+ FilePath log_filename;
+ PathService::Get(base::DIR_EXE, &log_filename);
+ log_filename = log_filename.AppendASCII("DumpRenderTree.log");
+ logging::InitLogging(
+ log_filename.value().c_str(),
+ // Only log to a file. This prevents debugging output from disrupting
+ // whether or not we pass.
+ logging::LOG_ONLY_TO_FILE,
+ // We might have multiple DumpRenderTree processes going at once.
+ logging::LOCK_LOG_FILE,
+ logging::DELETE_OLD_LOG_FILE);
+
+ // We want process and thread IDs because we may have multiple processes.
+ const bool kProcessId = true;
+ const bool kThreadId = true;
+ const bool kTimestamp = true;
+ const bool kTickcount = true;
+ logging::SetLogItems(kProcessId, kThreadId, !kTimestamp, kTickcount);
+}
+
class TestEnvironment {
public:
explicit TestEnvironment(bool unit_test_mode) {
- if (!unit_test_mode)
+ if (!unit_test_mode) {
at_exit_manager_.reset(new base::AtExitManager);
+ InitLogging(false);
+ }
main_message_loop_.reset(new MessageLoopForUI);
// TestWebKitClient must be instantiated after the MessageLoopForUI.
webkit_client_.reset(new TestWebKitClient(unit_test_mode));
@@ -112,47 +155,6 @@ FilePath GetWebKitRootDirFilePath() {
}
}
-// All fatal log messages (e.g. DCHECK failures) imply unit test failures
-void UnitTestAssertHandler(const std::string& str) {
- FAIL() << str;
-}
-
-void InitLogging(bool enable_gp_fault_error_box) {
- logging::SetLogAssertHandler(UnitTestAssertHandler);
-
-#if defined(OS_WIN)
- if (!::IsDebuggerPresent()) {
- UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
- if (!enable_gp_fault_error_box)
- new_flags |= SEM_NOGPFAULTERRORBOX;
-
- // Preserve existing error mode, as discussed at
- // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
- UINT existing_flags = SetErrorMode(new_flags);
- SetErrorMode(existing_flags | new_flags);
- }
-#endif
-
- FilePath log_filename;
- PathService::Get(base::DIR_EXE, &log_filename);
- log_filename = log_filename.AppendASCII("DumpRenderTree.log");
- logging::InitLogging(
- log_filename.value().c_str(),
- // Only log to a file. This prevents debugging output from disrupting
- // whether or not we pass.
- logging::LOG_ONLY_TO_FILE,
- // We might have multiple DumpRenderTree processes going at once.
- logging::LOCK_LOG_FILE,
- logging::DELETE_OLD_LOG_FILE);
-
- // We want process and thread IDs because we may have multiple processes.
- const bool kProcessId = true;
- const bool kThreadId = true;
- const bool kTimestamp = true;
- const bool kTickcount = true;
- logging::SetLogItems(kProcessId, kThreadId, !kTimestamp, kTickcount);
-}
-
} // namespace
namespace webkit_support {
@@ -174,8 +176,6 @@ static void SetUpTestEnvironmentImpl(bool unit_test_mode) {
const char* kFixedArguments[] = {"DumpRenderTree"};
CommandLine::Init(arraysize(kFixedArguments), kFixedArguments);
- InitLogging(false);
-
webkit_support::BeforeInitialize();
webkit_support::test_environment = new TestEnvironment(unit_test_mode);
webkit_support::AfterInitialize();