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

Side by Side Diff: chrome/browser/chromeos/syslogs/commandline_fetcher.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/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 {
22
23 void Execute(const chromeos::SysLogsFetcherCallback& request) {
satorux1 2012/08/09 21:15:07 Function comment is missing.
tudalex(Chromium) 2012/08/10 00:30:31 Done.
24 // TODO(tudalex): Move program calling in a array or something similar to make
25 // it more easier to modify and understand.
26 std::vector<std::pair<std::string, CommandLine> > commands;
27 chromeos::SysLogsResponse* response = new chromeos::SysLogsResponse;
28 // Needed to initialize an empty command, but the constructor was private
29 CommandLine command(FilePath("/usr/bin/cras_test_client"));
30 command.AppendArg("--dump_server_info");
31 commands.push_back(std::make_pair("cras", command));
32
33 command = CommandLine((FilePath("set")));
34 commands.push_back(std::make_pair("env", command));
35
36 command = CommandLine(FilePath("/usr/bin/setxkbmap"));
37 command.AppendArg("-print");
38 command.AppendArg("-query");
39 commands.push_back(std::make_pair("setxkbmap", command));
40
41 command = CommandLine(FilePath("/usr/bin/xrandr"));
42 command.AppendArg("--verbose");
43 commands.push_back(std::make_pair("xrandr", command));
44
45 command = CommandLine(FilePath("/opt/google/touchpad/tpcontrol"));
46 commands.push_back(std::make_pair("hack-33025-touchpad", command));
47
48 command = CommandLine(FilePath("/opt/google/touchpad/generate_userfeedback"));
49 commands.push_back(std::make_pair("hack-33025-touchpad_activity", command));
50
51
52 std::vector< std::pair<std::string, CommandLine> >::iterator it;
53 for (it = commands.begin(); it != commands.end(); ++it) {
54 std::string output;
55 base::GetAppOutput(it->second, &output);
56 (*response)[it->first] = output;
57 }
58 content::BrowserThread::PostTask(content::BrowserThread::UI,
satorux1 2012/08/09 21:15:07 This is unusual. Please use PostTaskAndReply idiom
tudalex(Chromium) 2012/08/10 00:30:31 Done.
59 FROM_HERE,
60 base::Bind(request, response));
61 }
62
63 } // namespace
64
65 namespace chromeos {
66
67 void CommandLineFetcher::Fetch(const SysLogsFetcherCallback& request) {
satorux1 2012/08/09 21:15:07 so you are on the UI thread here, right? Please do
tudalex(Chromium) 2012/08/10 00:30:31 Done.
68 BrowserThread::PostBlockingPoolTask(FROM_HERE,
69 base::Bind(&Execute,
70 request));
71 }
72
73 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698