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