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

Unified Diff: chrome/common/logging_chrome.cc

Issue 8059: Port parts of chrome/common to Linux.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/common.scons ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/logging_chrome.cc
===================================================================
--- chrome/common/logging_chrome.cc (revision 4761)
+++ chrome/common/logging_chrome.cc (working copy)
@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include <iostream>
#include <fstream>
@@ -10,6 +14,7 @@
#include "chrome/common/logging_chrome.h"
#include "base/command_line.h"
+#include "base/debug_util.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
@@ -31,7 +36,7 @@
// with that error in the str parameter.
#pragma optimize("", off)
static void SilentRuntimeAssertHandler(const std::string& str) {
- __debugbreak();
+ DebugUtil::BreakDebugger();
}
#pragma optimize("", on)
@@ -43,6 +48,7 @@
logging::SetLogAssertHandler(SilentRuntimeAssertHandler);
+#if defined(OS_WIN)
UINT new_flags = SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX;
@@ -50,6 +56,7 @@
// Preserve existing error mode, as discussed at http://t/dmea
UINT existing_flags = SetErrorMode(new_flags);
SetErrorMode(existing_flags | new_flags);
+#endif
dialogs_are_suppressed_ = true;
}
@@ -84,7 +91,13 @@
log_mode = logging::LOG_NONE;
}
- logging::InitLogging(GetLogFileName().c_str(),
+#if defined(OS_POSIX)
+ std::string log_file_name = WideToUTF8(GetLogFileName());
+#elif defined(OS_WIN)
+ std::wstring log_file_name = GetLogFileName();
+#endif
+
+ logging::InitLogging(log_file_name.c_str(),
log_mode,
logging::LOCK_LOG_FILE,
delete_old_log_file);
@@ -130,11 +143,9 @@
}
std::wstring GetLogFileName() {
- wchar_t filename[MAX_PATH];
- unsigned status = GetEnvironmentVariable(env_vars::kLogFileName,
- filename, MAX_PATH);
- if (status && (status <= MAX_PATH))
- return std::wstring(filename);
+ std::wstring filename = base::SysInfo::GetEnvVar(env_vars::kLogFileName);
+ if (filename != L"")
+ return filename;
const std::wstring log_filename(L"chrome_debug.log");
std::wstring log_path;
@@ -160,7 +171,11 @@
size_t assertion_count = 0;
std::ifstream log_file;
+#if defined(OS_WIN)
log_file.open(GetLogFileName().c_str());
+#elif defined(OS_POSIX)
+ log_file.open(WideToUTF8(GetLogFileName()).c_str());
+#endif
if (!log_file.is_open())
return 0;
« no previous file with comments | « chrome/common/common.scons ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698