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