| 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_logs/command_line_log_source.h" | 5 #include "chrome/browser/chromeos/system_logs/command_line_log_source.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/process/launch.h" | 16 #include "base/process/launch.h" |
| 17 #include "base/sys_info.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 | 19 |
| 19 using content::BrowserThread; | 20 using content::BrowserThread; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Gathers log data from various scripts/programs. | 24 // Gathers log data from various scripts/programs. |
| 24 void ExecuteCommandLines(system_logs::SystemLogsResponse* response) { | 25 void ExecuteCommandLines(system_logs::SystemLogsResponse* response) { |
| 25 // TODO(tudalex): Move program calling in a array or something similar to make | 26 // TODO(tudalex): Move program calling in a array or something similar to make |
| 26 // it more easier to modify and understand. | 27 // it more easier to modify and understand. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 60 |
| 60 #if defined(USE_X11) | 61 #if defined(USE_X11) |
| 61 command = base::CommandLine(base::FilePath("/usr/bin/xrandr")); | 62 command = base::CommandLine(base::FilePath("/usr/bin/xrandr")); |
| 62 command.AppendArg("--verbose"); | 63 command.AppendArg("--verbose"); |
| 63 commands.push_back(std::make_pair("xrandr", command)); | 64 commands.push_back(std::make_pair("xrandr", command)); |
| 64 #elif defined(USE_OZONE) | 65 #elif defined(USE_OZONE) |
| 65 command = base::CommandLine(base::FilePath("/usr/bin/modetest")); | 66 command = base::CommandLine(base::FilePath("/usr/bin/modetest")); |
| 66 commands.push_back(std::make_pair("modetest", command)); | 67 commands.push_back(std::make_pair("modetest", command)); |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 69 // Get a list of file sizes for the logged in user (excluding the names of | 70 // Get a list of file sizes for the whole system (excluding the names of the |
| 70 // the files in the Downloads directory for privay reasons). | 71 // files in the Downloads directory for privay reasons). |
| 71 command = base::CommandLine(base::FilePath("/bin/sh")); | 72 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 72 command.AppendArg("-c"); | 73 // The following command would hang if run in Linux Chrome OS build on a |
| 73 command.AppendArg("/usr/bin/du -h /home/chronos/user |" | 74 // Linux Workstation. |
| 74 " grep -v -e \\/home\\/chronos\\/user\\/Downloads\\/"); | 75 command = base::CommandLine(base::FilePath("/bin/sh")); |
| 75 commands.push_back(std::make_pair("user_files", command)); | 76 command.AppendArg("-c"); |
| 77 command.AppendArg( |
| 78 "/usr/bin/du -h / | grep -v -e \\/home\\/.*\\/Downloads\\/"); |
| 79 commands.push_back(std::make_pair("system_files", command)); |
| 80 } |
| 76 | 81 |
| 77 // Get disk space usage information | 82 // Get disk space usage information |
| 78 command = base::CommandLine(base::FilePath("/bin/df")); | 83 command = base::CommandLine(base::FilePath("/bin/df")); |
| 79 commands.push_back(std::make_pair("disk_usage", command)); | 84 commands.push_back(std::make_pair("disk_usage", command)); |
| 80 | 85 |
| 81 for (size_t i = 0; i < commands.size(); ++i) { | 86 for (size_t i = 0; i < commands.size(); ++i) { |
| 82 VLOG(1) << "Executting System Logs Command: " << commands[i].first; | 87 VLOG(1) << "Executting System Logs Command: " << commands[i].first; |
| 83 std::string output; | 88 std::string output; |
| 84 base::GetAppOutput(commands[i].second, &output); | 89 base::GetAppOutput(commands[i].second, &output); |
| 85 (*response)[commands[i].first] = output; | 90 (*response)[commands[i].first] = output; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 101 DCHECK(!callback.is_null()); | 106 DCHECK(!callback.is_null()); |
| 102 | 107 |
| 103 SystemLogsResponse* response = new SystemLogsResponse; | 108 SystemLogsResponse* response = new SystemLogsResponse; |
| 104 BrowserThread::PostBlockingPoolTaskAndReply( | 109 BrowserThread::PostBlockingPoolTaskAndReply( |
| 105 FROM_HERE, | 110 FROM_HERE, |
| 106 base::Bind(&ExecuteCommandLines, response), | 111 base::Bind(&ExecuteCommandLines, response), |
| 107 base::Bind(callback, base::Owned(response))); | 112 base::Bind(callback, base::Owned(response))); |
| 108 } | 113 } |
| 109 | 114 |
| 110 } // namespace system_logs | 115 } // namespace system_logs |
| OLD | NEW |