| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/system_logs/command_line_log_source.h" |
| 6 |
| 7 #include <string> |
| 8 #include <vector> |
| 9 |
| 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" |
| 12 #include "base/file_path.h" |
| 13 #include "base/logging.h" |
| 14 #include "base/process_util.h" |
| 15 #include "content/public/browser/browser_thread.h" |
| 16 |
| 17 using content::BrowserThread; |
| 18 |
| 19 namespace { |
| 20 |
| 21 // Gathers log data from various scripts/programs. |
| 22 void ExecuteCommandLines(chromeos::SystemLogsResponse* response) { |
| 23 // TODO(tudalex): Move program calling in a array or something similar to make |
| 24 // it more easier to modify and understand. |
| 25 std::vector<std::pair<std::string, CommandLine> > commands; |
| 26 |
| 27 // Needed to initialize an empty command, but the constructor was private |
| 28 CommandLine command(FilePath("/usr/bin/cras_test_client")); |
| 29 command.AppendArg("--dump_server_info"); |
| 30 commands.push_back(std::make_pair("cras", command)); |
| 31 |
| 32 command = CommandLine((FilePath("set"))); |
| 33 commands.push_back(std::make_pair("env", command)); |
| 34 |
| 35 command = CommandLine(FilePath("/usr/bin/setxkbmap")); |
| 36 command.AppendArg("-print"); |
| 37 command.AppendArg("-query"); |
| 38 commands.push_back(std::make_pair("setxkbmap", command)); |
| 39 |
| 40 command = CommandLine(FilePath("/usr/bin/xrandr")); |
| 41 command.AppendArg("--verbose"); |
| 42 commands.push_back(std::make_pair("xrandr", command)); |
| 43 |
| 44 command = CommandLine(FilePath("/opt/google/touchpad/tpcontrol")); |
| 45 commands.push_back(std::make_pair("hack-33025-touchpad", command)); |
| 46 |
| 47 command = CommandLine(FilePath("/opt/google/touchpad/generate_userfeedback")); |
| 48 commands.push_back(std::make_pair("hack-33025-touchpad_activity", command)); |
| 49 |
| 50 for (size_t i = 0; i < commands.size(); ++i) { |
| 51 std::string output; |
| 52 base::GetAppOutput(commands[i].second, &output); |
| 53 (*response)[commands[i].first] = output; |
| 54 } |
| 55 } |
| 56 |
| 57 } // namespace |
| 58 |
| 59 namespace chromeos { |
| 60 |
| 61 void CommandLineLogSource::Fetch(const SysLogsSourceCallback& callback) { |
| 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 63 DCHECK(!callback.is_null()); |
| 64 |
| 65 SystemLogsResponse* response = new SystemLogsResponse; |
| 66 BrowserThread::PostBlockingPoolTaskAndReply( |
| 67 FROM_HERE, |
| 68 base::Bind(&ExecuteCommandLines, response), |
| 69 base::Bind(callback, base::Owned(response))); |
| 70 } |
| 71 |
| 72 } // namespace chromeos |
| OLD | NEW |