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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 // Need to include this before most other files because it defines | 7 // Need to include this before most other files because it defines |
8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the | 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the |
10 // ViewMsgLog et al. functions. | 10 // ViewMsgLog et al. functions. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 namespace { | 160 namespace { |
161 base::FilePath SetUpSymlinkIfNeeded(const base::FilePath& symlink_path, | 161 base::FilePath SetUpSymlinkIfNeeded(const base::FilePath& symlink_path, |
162 bool new_log) { | 162 bool new_log) { |
163 DCHECK(!symlink_path.empty()); | 163 DCHECK(!symlink_path.empty()); |
164 | 164 |
165 // If not starting a new log, then just log through the existing | 165 // If not starting a new log, then just log through the existing |
166 // symlink, but if the symlink doesn't exist, create it. If | 166 // symlink, but if the symlink doesn't exist, create it. If |
167 // starting a new log, then delete the old symlink and make a new | 167 // starting a new log, then delete the old symlink and make a new |
168 // one to a fresh log file. | 168 // one to a fresh log file. |
169 base::FilePath target_path; | 169 base::FilePath target_path; |
170 bool symlink_exists = file_util::PathExists(symlink_path); | 170 bool symlink_exists = base::PathExists(symlink_path); |
171 if (new_log || !symlink_exists) { | 171 if (new_log || !symlink_exists) { |
172 target_path = GenerateTimestampedName(symlink_path, base::Time::Now()); | 172 target_path = GenerateTimestampedName(symlink_path, base::Time::Now()); |
173 | 173 |
174 // We don't care if the unlink fails; we're going to continue anyway. | 174 // We don't care if the unlink fails; we're going to continue anyway. |
175 if (::unlink(symlink_path.value().c_str()) == -1) { | 175 if (::unlink(symlink_path.value().c_str()) == -1) { |
176 if (symlink_exists) // only warn if we might expect it to succeed. | 176 if (symlink_exists) // only warn if we might expect it to succeed. |
177 DPLOG(WARNING) << "Unable to unlink " << symlink_path.value(); | 177 DPLOG(WARNING) << "Unable to unlink " << symlink_path.value(); |
178 } | 178 } |
179 if (!file_util::CreateSymbolicLink(target_path, symlink_path)) { | 179 if (!file_util::CreateSymbolicLink(target_path, symlink_path)) { |
180 DPLOG(ERROR) << "Unable to create symlink " << symlink_path.value() | 180 DPLOG(ERROR) << "Unable to create symlink " << symlink_path.value() |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 time_deets.year, | 455 time_deets.year, |
456 time_deets.month, | 456 time_deets.month, |
457 time_deets.day_of_month, | 457 time_deets.day_of_month, |
458 time_deets.hour, | 458 time_deets.hour, |
459 time_deets.minute, | 459 time_deets.minute, |
460 time_deets.second); | 460 time_deets.second); |
461 return base_path.InsertBeforeExtensionASCII(suffix); | 461 return base_path.InsertBeforeExtensionASCII(suffix); |
462 } | 462 } |
463 | 463 |
464 } // namespace logging | 464 } // namespace logging |
OLD | NEW |