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

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

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/system_logs/command_line_log_source.h" 5 #include "chrome/browser/chromeos/system_logs/command_line_log_source.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/process/launch.h" 14 #include "base/process/launch.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 namespace { 19 namespace {
20 20
21 // Gathers log data from various scripts/programs. 21 // Gathers log data from various scripts/programs.
22 void ExecuteCommandLines(system_logs::SystemLogsResponse* response) { 22 void ExecuteCommandLines(system_logs::SystemLogsResponse* response) {
23 // TODO(tudalex): Move program calling in a array or something similar to make 23 // TODO(tudalex): Move program calling in a array or something similar to make
24 // it more easier to modify and understand. 24 // it more easier to modify and understand.
25 std::vector<std::pair<std::string, CommandLine> > commands; 25 std::vector<std::pair<std::string, base::CommandLine>> commands;
26 26
27 CommandLine command(base::FilePath("/usr/bin/amixer")); 27 base::CommandLine command(base::FilePath("/usr/bin/amixer"));
28 command.AppendArg("-c0"); 28 command.AppendArg("-c0");
29 command.AppendArg("contents"); 29 command.AppendArg("contents");
30 commands.push_back(std::make_pair("alsa controls", command)); 30 commands.push_back(std::make_pair("alsa controls", command));
31 31
32 command = CommandLine((base::FilePath("/usr/bin/cras_test_client"))); 32 command = base::CommandLine((base::FilePath("/usr/bin/cras_test_client")));
33 command.AppendArg("--dump_server_info"); 33 command.AppendArg("--dump_server_info");
34 command.AppendArg("--dump_audio_thread"); 34 command.AppendArg("--dump_audio_thread");
35 commands.push_back(std::make_pair("cras", command)); 35 commands.push_back(std::make_pair("cras", command));
36 36
37 command = CommandLine((base::FilePath("/usr/bin/audio_diagnostics"))); 37 command = base::CommandLine((base::FilePath("/usr/bin/audio_diagnostics")));
38 commands.push_back(std::make_pair("audio_diagnostics", command)); 38 commands.push_back(std::make_pair("audio_diagnostics", command));
39 39
40 #if 0 40 #if 0
41 // This command hangs as of R39. TODO(alhli): Make cras_test_client more 41 // This command hangs as of R39. TODO(alhli): Make cras_test_client more
42 // robust or add a wrapper script that times out, and fix this or remove 42 // robust or add a wrapper script that times out, and fix this or remove
43 // this code. crbug.com/419523 43 // this code. crbug.com/419523
44 command = CommandLine((base::FilePath("/usr/bin/cras_test_client"))); 44 command = base::CommandLine((base::FilePath("/usr/bin/cras_test_client")));
45 command.AppendArg("--loopback_file"); 45 command.AppendArg("--loopback_file");
46 command.AppendArg("/dev/null"); 46 command.AppendArg("/dev/null");
47 command.AppendArg("--rate"); 47 command.AppendArg("--rate");
48 command.AppendArg("44100"); 48 command.AppendArg("44100");
49 command.AppendArg("--duration_seconds"); 49 command.AppendArg("--duration_seconds");
50 command.AppendArg("0.01"); 50 command.AppendArg("0.01");
51 command.AppendArg("--show_total_rms"); 51 command.AppendArg("--show_total_rms");
52 commands.push_back(std::make_pair("cras_rms", command)); 52 commands.push_back(std::make_pair("cras_rms", command));
53 #endif 53 #endif
54 54
55 command = CommandLine((base::FilePath("/usr/bin/printenv"))); 55 command = base::CommandLine((base::FilePath("/usr/bin/printenv")));
56 commands.push_back(std::make_pair("env", command)); 56 commands.push_back(std::make_pair("env", command));
57 57
58 command = CommandLine(base::FilePath("/usr/bin/setxkbmap")); 58 command = base::CommandLine(base::FilePath("/usr/bin/setxkbmap"));
59 command.AppendArg("-print"); 59 command.AppendArg("-print");
60 command.AppendArg("-query"); 60 command.AppendArg("-query");
61 commands.push_back(std::make_pair("setxkbmap", command)); 61 commands.push_back(std::make_pair("setxkbmap", command));
62 62
63 command = CommandLine(base::FilePath("/usr/bin/xinput")); 63 command = base::CommandLine(base::FilePath("/usr/bin/xinput"));
64 command.AppendArg("list"); 64 command.AppendArg("list");
65 command.AppendArg("--long"); 65 command.AppendArg("--long");
66 commands.push_back(std::make_pair("xinput", command)); 66 commands.push_back(std::make_pair("xinput", command));
67 67
68 command = CommandLine(base::FilePath("/usr/bin/xrandr")); 68 command = base::CommandLine(base::FilePath("/usr/bin/xrandr"));
69 command.AppendArg("--verbose"); 69 command.AppendArg("--verbose");
70 commands.push_back(std::make_pair("xrandr", command)); 70 commands.push_back(std::make_pair("xrandr", command));
71 71
72 // Get a list of file sizes for the logged in user (excluding the names of 72 // Get a list of file sizes for the logged in user (excluding the names of
73 // the files in the Downloads directory for privay reasons). 73 // the files in the Downloads directory for privay reasons).
74 command = CommandLine(base::FilePath("/bin/sh")); 74 command = base::CommandLine(base::FilePath("/bin/sh"));
75 command.AppendArg("-c"); 75 command.AppendArg("-c");
76 command.AppendArg("/usr/bin/du -h /home/chronos/user |" 76 command.AppendArg("/usr/bin/du -h /home/chronos/user |"
77 " grep -v -e \\/home\\/chronos\\/user\\/Downloads\\/"); 77 " grep -v -e \\/home\\/chronos\\/user\\/Downloads\\/");
78 commands.push_back(std::make_pair("user_files", command)); 78 commands.push_back(std::make_pair("user_files", command));
79 79
80 // Get disk space usage information 80 // Get disk space usage information
81 command = CommandLine(base::FilePath("/bin/df")); 81 command = base::CommandLine(base::FilePath("/bin/df"));
82 commands.push_back(std::make_pair("disk_usage", command)); 82 commands.push_back(std::make_pair("disk_usage", command));
83 83
84 for (size_t i = 0; i < commands.size(); ++i) { 84 for (size_t i = 0; i < commands.size(); ++i) {
85 VLOG(1) << "Executting System Logs Command: " << commands[i].first; 85 VLOG(1) << "Executting System Logs Command: " << commands[i].first;
86 std::string output; 86 std::string output;
87 base::GetAppOutput(commands[i].second, &output); 87 base::GetAppOutput(commands[i].second, &output);
88 (*response)[commands[i].first] = output; 88 (*response)[commands[i].first] = output;
89 } 89 }
90 } 90 }
91 91
(...skipping 12 matching lines...) Expand all
104 DCHECK(!callback.is_null()); 104 DCHECK(!callback.is_null());
105 105
106 SystemLogsResponse* response = new SystemLogsResponse; 106 SystemLogsResponse* response = new SystemLogsResponse;
107 BrowserThread::PostBlockingPoolTaskAndReply( 107 BrowserThread::PostBlockingPoolTaskAndReply(
108 FROM_HERE, 108 FROM_HERE,
109 base::Bind(&ExecuteCommandLines, response), 109 base::Bind(&ExecuteCommandLines, response),
110 base::Bind(callback, base::Owned(response))); 110 base::Bind(callback, base::Owned(response)));
111 } 111 }
112 112
113 } // namespace system_logs 113 } // namespace system_logs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698