Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 typedef HANDLE FileHandle; | 10 typedef HANDLE FileHandle; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 } | 204 } |
| 205 | 205 |
| 206 static void Init(LogLockingState lock_log, const PathChar* new_log_file) { | 206 static void Init(LogLockingState lock_log, const PathChar* new_log_file) { |
| 207 if (initialized) | 207 if (initialized) |
| 208 return; | 208 return; |
| 209 lock_log_file = lock_log; | 209 lock_log_file = lock_log; |
| 210 if (lock_log_file == LOCK_LOG_FILE) { | 210 if (lock_log_file == LOCK_LOG_FILE) { |
| 211 #if defined(OS_WIN) | 211 #if defined(OS_WIN) |
| 212 if (!log_mutex) { | 212 if (!log_mutex) { |
| 213 std::wstring safe_name; | 213 std::wstring safe_name; |
| 214 if (new_log_file) | 214 if (!new_log_file) { |
| 215 safe_name = GetDefaultLogFile(); | |
| 216 } else if (new_log_file[0]) { | |
|
brettw
2012/09/11 19:20:54
Should we just be asserting that people don't give
wtc
2012/09/11 21:44:46
We can't assert that because in Release builds, Ch
wtc
2012/09/11 22:36:50
For this function (LoggingLock::Init), any non-emp
brettw
2012/09/11 22:43:31
Let's add a comment here that if the client sent n
wtc
2012/09/12 20:29:57
I will add some comments to base/logging.h to docu
| |
| 215 safe_name = new_log_file; | 217 safe_name = new_log_file; |
| 216 else | 218 } else { |
| 217 safe_name = GetDefaultLogFile(); | 219 safe_name = L"<NotLoggingToFile>"; |
| 220 } | |
|
wtc
2012/09/11 04:17:49
I am assuming |new_log_file| may have three cases.
| |
| 218 // \ is not a legal character in mutex names so we replace \ with / | 221 // \ is not a legal character in mutex names so we replace \ with / |
| 219 std::replace(safe_name.begin(), safe_name.end(), '\\', '/'); | 222 std::replace(safe_name.begin(), safe_name.end(), '\\', '/'); |
| 220 std::wstring t(L"Global\\"); | 223 std::wstring t(L"Global\\"); |
| 221 t.append(safe_name); | 224 t.append(safe_name); |
| 222 log_mutex = ::CreateMutex(NULL, FALSE, t.c_str()); | 225 log_mutex = ::CreateMutex(NULL, FALSE, t.c_str()); |
| 223 | 226 |
| 224 if (log_mutex == NULL) { | 227 if (log_mutex == NULL) { |
| 225 #if DEBUG | 228 #if DEBUG |
| 226 // Keep the error code for debugging | 229 // Keep the error code for debugging |
| 227 int error = GetLastError(); // NOLINT | 230 int error = GetLastError(); // NOLINT |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 } | 854 } |
| 852 | 855 |
| 853 // This was defined at the beginning of this file. | 856 // This was defined at the beginning of this file. |
| 854 #undef write | 857 #undef write |
| 855 | 858 |
| 856 } // namespace logging | 859 } // namespace logging |
| 857 | 860 |
| 858 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 861 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
| 859 return out << WideToUTF8(std::wstring(wstr)); | 862 return out << WideToUTF8(std::wstring(wstr)); |
| 860 } | 863 } |
| OLD | NEW |