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

Unified Diff: base/logging.cc

Issue 2053953002: Add chrome_crash_reporter_client_win.cc to the source file list for chrome_elf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/files/file_path.cc ('k') | base/message_loop/message_pump_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.cc
diff --git a/base/logging.cc b/base/logging.cc
index 98cecd094fd84e7312c9a3e9998dfb44cfd05925..0771b47c182e5c18c868f1124a0784bf411d74a9 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -13,8 +13,6 @@
#if defined(OS_WIN)
#include <io.h>
#include <windows.h>
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
typedef HANDLE FileHandle;
typedef HANDLE MutexHandle;
// Windows warns on using write(). It prefers _write().
@@ -289,13 +287,24 @@ bool InitializeLogFileHandle() {
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (g_log_file == INVALID_HANDLE_VALUE || g_log_file == nullptr) {
+ // We are intentionally not using FilePath or FileUtil here to reduce the
+ // dependencies of the logging implementation. For e.g. FilePath and
+ // FileUtil depend on shell32 and user32.dll. This is not acceptable for
+ // some consumers of base logging like chrome_elf, etc.
+ // Please don't change the code below to use FilePath.
// try the current directory
- base::FilePath file_path;
- if (!base::GetCurrentDirectory(&file_path))
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ DWORD len = ::GetCurrentDirectory(arraysize(system_buffer),
+ system_buffer);
+ if (len == 0 || len > arraysize(system_buffer))
return false;
- *g_log_file_name = file_path.Append(
- FILE_PATH_LITERAL("debug.log")).value();
+ *g_log_file_name = system_buffer;
+ // Append a trailing backslash if needed.
+ if (g_log_file_name->back() != L'\\')
+ *g_log_file_name += L"\\";
+ *g_log_file_name += L"debug.log";
g_log_file = CreateFile(g_log_file_name->c_str(), FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
« no previous file with comments | « base/files/file_path.cc ('k') | base/message_loop/message_pump_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698