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

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 chromeos {
22
23 void CommandLineLogSource::Fetch(const SysLogsFetcherCallback& request) {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
25
26 SystemLogsResponse* response = new SystemLogsResponse;
satorux1 2012/08/13 18:29:03 who deletes |response|? will this be deleted by Sy
tudalex(Chromium) 2012/08/14 03:24:00 Yes, it is deleted there.
27 BrowserThread::PostBlockingPoolTaskAndReply(FROM_HERE,
28 base::Bind(
29 &CommandLineLogSource::Execute,
satorux1 2012/08/13 18:29:03 indentation is wrong. four spaces, instead of two.
tudalex(Chromium) 2012/08/14 03:24:00 Thanks, I was wondering what the best approach wou
30 response),
31 base::Bind(request, response));
satorux1 2012/08/13 18:29:03 if you want to delete |response| after the callbac
tudalex(Chromium) 2012/08/14 03:24:00 Used base::Owned().
32 }
33
34 void CommandLineLogSource::Execute(SystemLogsResponse* response) {
satorux1 2012/08/13 18:29:03 Could you move this to anonymous namespace in the
tudalex(Chromium) 2012/08/14 03:24:00 I had it originally in an anonymous namespace in p
satorux1 2012/08/14 05:51:52 It's probably a matter of taste, but I personally
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698