| 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 "chrome/browser/chromeos/system/syslogs_provider.h" | 5 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.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 // context: This is an in parameter specifying what context should be | 115 // context: This is an in parameter specifying what context should be |
| 116 // passed to the syslog collection script; currently valid | 116 // passed to the syslog collection script; currently valid |
| 117 // values are "sysinfo" or "feedback"; in case of an invalid | 117 // values are "sysinfo" or "feedback"; in case of an invalid |
| 118 // value, the script will currently default to "sysinfo" | 118 // value, the script will currently default to "sysinfo" |
| 119 | 119 |
| 120 LogDictionaryType* GetSystemLogs(base::FilePath* zip_file_name, | 120 LogDictionaryType* GetSystemLogs(base::FilePath* zip_file_name, |
| 121 const std::string& context) { | 121 const std::string& context) { |
| 122 // Create the temp file, logs will go here | 122 // Create the temp file, logs will go here |
| 123 base::FilePath temp_filename; | 123 base::FilePath temp_filename; |
| 124 | 124 |
| 125 if (!file_util::CreateTemporaryFile(&temp_filename)) | 125 if (!base::CreateTemporaryFile(&temp_filename)) |
| 126 return NULL; | 126 return NULL; |
| 127 | 127 |
| 128 std::string cmd = std::string(kSysLogsScript) + " " + context + " >> " + | 128 std::string cmd = std::string(kSysLogsScript) + " " + context + " >> " + |
| 129 temp_filename.value(); | 129 temp_filename.value(); |
| 130 | 130 |
| 131 // Ignore the return value - if the script execution didn't work | 131 // Ignore the return value - if the script execution didn't work |
| 132 // stderr won't go into the output file anyway. | 132 // stderr won't go into the output file anyway. |
| 133 if (::system(cmd.c_str()) == -1) | 133 if (::system(cmd.c_str()) == -1) |
| 134 LOG(WARNING) << "Command " << cmd << " failed to run"; | 134 LOG(WARNING) << "Command " << cmd << " failed to run"; |
| 135 | 135 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 bool compress_logs, | 298 bool compress_logs, |
| 299 SyslogsContext context, | 299 SyslogsContext context, |
| 300 const ReadCompleteCallback& callback) { | 300 const ReadCompleteCallback& callback) { |
| 301 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 301 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 302 | 302 |
| 303 if (is_canceled.Run()) | 303 if (is_canceled.Run()) |
| 304 return; | 304 return; |
| 305 | 305 |
| 306 // Create temp file. | 306 // Create temp file. |
| 307 base::FilePath zip_file; | 307 base::FilePath zip_file; |
| 308 if (compress_logs && !file_util::CreateTemporaryFile(&zip_file)) { | 308 if (compress_logs && !base::CreateTemporaryFile(&zip_file)) { |
| 309 LOG(ERROR) << "Cannot create temp file"; | 309 LOG(ERROR) << "Cannot create temp file"; |
| 310 compress_logs = false; | 310 compress_logs = false; |
| 311 } | 311 } |
| 312 | 312 |
| 313 LogDictionaryType* logs = NULL; | 313 LogDictionaryType* logs = NULL; |
| 314 logs = GetSystemLogs( | 314 logs = GetSystemLogs( |
| 315 compress_logs ? &zip_file : NULL, | 315 compress_logs ? &zip_file : NULL, |
| 316 GetSyslogsContextString(context)); | 316 GetSyslogsContextString(context)); |
| 317 | 317 |
| 318 std::string* zip_content = NULL; | 318 std::string* zip_content = NULL; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 return Singleton<SyslogsProviderImpl, | 397 return Singleton<SyslogsProviderImpl, |
| 398 DefaultSingletonTraits<SyslogsProviderImpl> >::get(); | 398 DefaultSingletonTraits<SyslogsProviderImpl> >::get(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 SyslogsProvider* SyslogsProvider::GetInstance() { | 401 SyslogsProvider* SyslogsProvider::GetInstance() { |
| 402 return SyslogsProviderImpl::GetInstance(); | 402 return SyslogsProviderImpl::GetInstance(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace system | 405 } // namespace system |
| 406 } // namespace chromeos | 406 } // namespace chromeos |
| OLD | NEW |