summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/logging_chrome.cc27
-rw-r--r--chrome/common/logging_chrome.h3
-rw-r--r--chrome/common/logging_chrome_uitest.cc10
3 files changed, 17 insertions, 23 deletions
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index 3f497f3..ee0caaa 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -16,6 +16,7 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/debug_util.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
@@ -114,13 +115,7 @@ void InitChromeLogging(const CommandLine& command_line,
log_mode = logging::LOG_NONE;
}
-#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(),
+ logging::InitLogging(GetLogFileName().value().c_str(),
log_mode,
logging::LOCK_LOG_FILE,
delete_old_log_file);
@@ -165,16 +160,16 @@ void CleanupChromeLogging() {
chrome_logging_initialized_ = false;
}
-std::wstring GetLogFileName() {
+FilePath GetLogFileName() {
std::wstring filename = base::SysInfo::GetEnvVar(env_vars::kLogFileName);
- if (filename != L"")
- return filename;
+ if (!filename.empty())
+ return FilePath::FromWStringHack(filename);
- const std::wstring log_filename(L"chrome_debug.log");
- std::wstring log_path;
+ const FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log"));
+ FilePath log_path;
if (PathService::Get(chrome::DIR_LOGS, &log_path)) {
- file_util::AppendToPath(&log_path, log_filename);
+ log_path = log_path.Append(log_filename);
return log_path;
} else {
// error with path service, just use some default file somewhere
@@ -194,11 +189,7 @@ size_t GetFatalAssertions(AssertionList* assertions) {
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
+ log_file.open(GetLogFileName().value().c_str());
if (!log_file.is_open())
return 0;
diff --git a/chrome/common/logging_chrome.h b/chrome/common/logging_chrome.h
index b68a61f..434b2fe 100644
--- a/chrome/common/logging_chrome.h
+++ b/chrome/common/logging_chrome.h
@@ -11,6 +11,7 @@
#include "base/logging.h"
class CommandLine;
+class FilePath;
namespace logging {
@@ -34,7 +35,7 @@ void InitChromeLogging(const CommandLine& command_line,
void CleanupChromeLogging();
// Returns the fully-qualified name of the log file.
-std::wstring GetLogFileName();
+FilePath GetLogFileName();
// Returns true when error/assertion dialogs are to be shown,
// false otherwise.
diff --git a/chrome/common/logging_chrome_uitest.cc b/chrome/common/logging_chrome_uitest.cc
index 1211f8c..fd3fcc6 100644
--- a/chrome/common/logging_chrome_uitest.cc
+++ b/chrome/common/logging_chrome_uitest.cc
@@ -45,8 +45,9 @@ namespace {
TEST_F(ChromeLoggingTest, LogFileName) {
SaveEnvironmentVariable(std::wstring());
- std::wstring filename = logging::GetLogFileName();
- ASSERT_NE(std::wstring::npos, filename.find(L"chrome_debug.log"));
+ FilePath filename = logging::GetLogFileName();
+ ASSERT_NE(FilePath::StringType::npos,
+ filename.value().find(FILE_PATH_LITERAL("chrome_debug.log")));
RestoreEnvironmentVariable();
}
@@ -55,8 +56,9 @@ TEST_F(ChromeLoggingTest, LogFileName) {
TEST_F(ChromeLoggingTest, EnvironmentLogFileName) {
SaveEnvironmentVariable(std::wstring(L"test value"));
- std::wstring filename = logging::GetLogFileName();
- ASSERT_EQ(std::wstring(L"test value"), filename);
+ FilePath filename = logging::GetLogFileName();
+ ASSERT_EQ(FilePath(FILE_PATH_LITERAL("test value")).value(),
+ filename.value());
RestoreEnvironmentVariable();
}