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