| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/system_logs/debug_log_writer.h" | 5 #include "chrome/browser/chromeos/system_logs/debug_log_writer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 const base::FilePath& tar_file_path, | 115 const base::FilePath& tar_file_path, |
| 116 const base::FilePath& compressed_output_path, | 116 const base::FilePath& compressed_output_path, |
| 117 const DebugLogWriter::StoreLogsCallback& callback, | 117 const DebugLogWriter::StoreLogsCallback& callback, |
| 118 bool compression_command_success) { | 118 bool compression_command_success) { |
| 119 if (!compression_command_success) { | 119 if (!compression_command_success) { |
| 120 LOG(ERROR) << "Failed compressing " << compressed_output_path.value(); | 120 LOG(ERROR) << "Failed compressing " << compressed_output_path.value(); |
| 121 content::BrowserThread::PostTask( | 121 content::BrowserThread::PostTask( |
| 122 content::BrowserThread::UI, | 122 content::BrowserThread::UI, |
| 123 FROM_HERE, | 123 FROM_HERE, |
| 124 base::Bind(callback, base::FilePath(), false)); | 124 base::Bind(callback, base::FilePath(), false)); |
| 125 base::DeleteFile(tar_file_path, true); | 125 base::DeleteFile(tar_file_path, false); |
| 126 base::DeleteFile(compressed_output_path, true); | 126 base::DeleteFile(compressed_output_path, false); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 content::BrowserThread::PostTask( | 130 content::BrowserThread::PostTask( |
| 131 content::BrowserThread::UI, | 131 content::BrowserThread::UI, |
| 132 FROM_HERE, | 132 FROM_HERE, |
| 133 base::Bind(callback, compressed_output_path, true)); | 133 base::Bind(callback, compressed_output_path, true)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Gzips |tar_file_path| and stores results in |compressed_output_path|. | 136 // Gzips |tar_file_path| and stores results in |compressed_output_path|. |
| 137 void CompressArchive(const base::FilePath& tar_file_path, | 137 void CompressArchive(const base::FilePath& tar_file_path, |
| 138 const base::FilePath& compressed_output_path, | 138 const base::FilePath& compressed_output_path, |
| 139 const DebugLogWriter::StoreLogsCallback& callback, | 139 const DebugLogWriter::StoreLogsCallback& callback, |
| 140 bool add_user_logs_command_success) { | 140 bool add_user_logs_command_success) { |
| 141 if (!add_user_logs_command_success) { | 141 if (!add_user_logs_command_success) { |
| 142 LOG(ERROR) << "Failed adding user logs to " << tar_file_path.value(); | 142 LOG(ERROR) << "Failed adding user logs to " << tar_file_path.value(); |
| 143 content::BrowserThread::PostTask( | 143 content::BrowserThread::PostTask( |
| 144 content::BrowserThread::UI, | 144 content::BrowserThread::UI, |
| 145 FROM_HERE, | 145 FROM_HERE, |
| 146 base::Bind(callback, base::FilePath(), false)); | 146 base::Bind(callback, base::FilePath(), false)); |
| 147 base::DeleteFile(tar_file_path, true); | 147 base::DeleteFile(tar_file_path, false); |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| 151 std::vector<std::string> argv; | 151 std::vector<std::string> argv; |
| 152 argv.push_back(kGzipCommand); | 152 argv.push_back(kGzipCommand); |
| 153 argv.push_back(tar_file_path.value()); | 153 argv.push_back(tar_file_path.value()); |
| 154 RunCommand(argv, | 154 RunCommand(argv, |
| 155 base::Bind(&OnCompressArchiveCompleted, | 155 base::Bind(&OnCompressArchiveCompleted, |
| 156 tar_file_path, | 156 tar_file_path, |
| 157 compressed_output_path, | 157 compressed_output_path, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 fileshelf.Append(FILE_PATH_LITERAL("combined-logs.tar")); | 266 fileshelf.Append(FILE_PATH_LITERAL("combined-logs.tar")); |
| 267 | 267 |
| 268 // Get system logs from /var/log first, then add user-specific stuff. | 268 // Get system logs from /var/log first, then add user-specific stuff. |
| 269 StartLogRetrieval(file_path, | 269 StartLogRetrieval(file_path, |
| 270 false, | 270 false, |
| 271 sequence_token_name, | 271 sequence_token_name, |
| 272 base::Bind(&OnSystemLogsAdded, callback)); | 272 base::Bind(&OnSystemLogsAdded, callback)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace chromeos | 275 } // namespace chromeos |
| OLD | NEW |