Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: chrome/browser/chromeos/system_logs/commandline_log_source.cc

Issue 10827130: Refactoring the SysInfoProvider. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/commandline_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"
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
53 std::vector< std::pair<std::string, CommandLine> >::iterator it;
satorux1 2012/08/16 10:50:57 move this iterator declaration inside of 'for' or
tudalex(Chromium) 2012/08/16 22:33:03 Done.
54 for (it = commands.begin(); it != commands.end(); ++it) {
55 std::string output;
56 base::GetAppOutput(it->second, &output);
57 (*response)[it->first] = output;
58 }
59 }
60
61 } // namespace
62
63 namespace chromeos {
64
65 void CommandLineLogSource::Fetch(const SysLogsFetcherCallback& callback) {
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
67 DCHECK(!callback.is_null());
68
69 SystemLogsResponse* response = new SystemLogsResponse;
70 BrowserThread::PostBlockingPoolTaskAndReply(
71 FROM_HERE,
72 base::Bind(&ExecuteCommandLines, response),
73 base::Bind(callback, base::Owned(response)));
74 }
75
76 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698