| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/chromeos/logging.h" | 5 #include "chrome/browser/chromeos/logging.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/task_scheduler/post_task.h" | 11 #include "base/task_scheduler/post_task.h" |
| 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/logging_chrome.h" | 13 #include "chrome/common/logging_chrome.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 | 15 |
| 15 namespace logging { | 16 namespace logging { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // This should be true for exactly the period between the end of | 20 // This should be true for exactly the period between the end of |
| 20 // InitChromeLogging() and the beginning of CleanupChromeLogging(). | 21 // InitChromeLogging() and the beginning of CleanupChromeLogging(). |
| 21 bool chrome_logging_redirected_ = false; | 22 bool chrome_logging_redirected_ = false; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 void RedirectChromeLogging(const base::CommandLine& command_line) { | 46 void RedirectChromeLogging(const base::CommandLine& command_line) { |
| 46 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 47 | 48 |
| 48 if (chrome_logging_redirected_) { | 49 if (chrome_logging_redirected_) { |
| 49 // TODO: Support multiple active users. http://crbug.com/230345 | 50 // TODO: Support multiple active users. http://crbug.com/230345 |
| 50 LOG(WARNING) << "NOT redirecting logging for multi-profiles case."; | 51 LOG(WARNING) << "NOT redirecting logging for multi-profiles case."; |
| 51 return; | 52 return; |
| 52 } | 53 } |
| 53 | 54 |
| 54 DCHECK(!chrome_logging_redirected_) | 55 if (command_line.HasSwitch(switches::kDisableLoggingRedirect)) |
| 55 << "Attempted to redirect logging when it was already initialized."; | 56 return; |
| 56 | 57 |
| 57 // Redirect logs to the session log directory, if set. Otherwise | 58 // Redirect logs to the session log directory, if set. Otherwise |
| 58 // defaults to the profile dir. | 59 // defaults to the profile dir. |
| 59 const base::FilePath log_path = GetSessionLogFile(command_line); | 60 const base::FilePath log_path = GetSessionLogFile(command_line); |
| 60 | 61 |
| 61 // Always force a new symlink when redirecting. | 62 // Always force a new symlink when redirecting. |
| 62 base::PostTaskWithTraitsAndReplyWithResult( | 63 base::PostTaskWithTraitsAndReplyWithResult( |
| 63 FROM_HERE, {base::MayBlock()}, | 64 FROM_HERE, {base::MayBlock()}, |
| 64 base::BindOnce(&SetUpSymlinkIfNeeded, log_path, true), | 65 base::BindOnce(&SetUpSymlinkIfNeeded, log_path, true), |
| 65 base::BindOnce(&SymlinkSetUp, command_line, log_path)); | 66 base::BindOnce(&SymlinkSetUp, command_line, log_path)); |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace logging | 69 } // namespace logging |
| OLD | NEW |