Skip to content

Commit

Permalink
Prefix CommandLine usage with base namespace (Part 7: cloud_print/)
Browse files Browse the repository at this point in the history
Prefix all CommandLine usage in the cloud_print/ directory with
the base:: namespace.

R=vitalybuka@chromium.org
BUG=422426

Review URL: https://codereview.chromium.org/735053002

Cr-Commit-Position: refs/heads/master@{#304744}
  • Loading branch information
galpeter authored and Commit bot committed Nov 19, 2014
1 parent 539d886 commit 588a3ea
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 43 deletions.
4 changes: 2 additions & 2 deletions cloud_print/common/win/install_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void CreateUninstallKey(const base::string16& uninstall_id,
base::FilePath unstall_binary;
CHECK(PathService::Get(base::FILE_EXE, &unstall_binary));

CommandLine uninstall_command(unstall_binary);
base::CommandLine uninstall_command(unstall_binary);
uninstall_command.AppendSwitch(uninstall_switch);
key.WriteValue(kUninstallString,
uninstall_command.GetCommandLineString().c_str());
Expand Down Expand Up @@ -200,7 +200,7 @@ void DeleteProgramDir(const std::string& delete_switch) {
return;
base::CopyFile(installer_source, temp_path);
base::DeleteFileAfterReboot(temp_path);
CommandLine command_line(temp_path);
base::CommandLine command_line(temp_path);
command_line.AppendSwitchPath(delete_switch, installer_source.DirName());
base::LaunchOptions options;
base::ProcessHandle process_handle;
Expand Down
14 changes: 8 additions & 6 deletions cloud_print/gcp20/prototype/command_line_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ uint16 ReadHttpPort(uint16 default_value) {
uint32 http_port = 0;

std::string http_port_string =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kHttpPort);

if (!base::StringToUint(http_port_string, &http_port))
Expand All @@ -32,9 +32,10 @@ uint16 ReadHttpPort(uint16 default_value) {

uint32 ReadTtl(uint32 default_value) {
uint32 ttl = 0;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();

if (!base::StringToUint(
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kTtl),
command_line->GetSwitchValueASCII(switches::kTtl),
&ttl)) {
ttl = default_value;
}
Expand All @@ -45,15 +46,15 @@ uint32 ReadTtl(uint32 default_value) {

std::string ReadServiceNamePrefix(const std::string& default_value) {
std::string service_name =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kServiceName);

return service_name.empty() ? default_value : service_name;
}

std::string ReadDomainName(const std::string& default_value) {
std::string domain_name =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kDomainName);

if (domain_name.empty())
Expand All @@ -75,8 +76,9 @@ std::string ReadDomainName(const std::string& default_value) {
}

std::string ReadStatePath(const std::string& default_value) {
std::string filename = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kStatePath);
std::string filename =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kStatePath);

if (filename.empty())
return default_value;
Expand Down
12 changes: 7 additions & 5 deletions cloud_print/gcp20/prototype/dns_sd_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ void DnsSdServer::UpdateMetadata(const std::vector<std::string>& metadata) {
// then send it now.

uint32 current_ttl = GetCurrentTLL();
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoAnnouncement)) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kNoAnnouncement)) {
DnsResponseBuilder builder(current_ttl);

builder.AppendTxt(serv_params_.service_name_, current_ttl, metadata_, true);
Expand Down Expand Up @@ -183,8 +184,8 @@ void DnsSdServer::ProcessMessage(int len, net::IOBufferWithSize* buf) {

VLOG(1) << "Current TTL for respond: " << current_ttl;

bool unicast_respond =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kUnicastRespond);
bool unicast_respond = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUnicastRespond);
socket_->SendTo(buffer.get(), buffer.get()->size(),
unicast_respond ? recv_address_ : multicast_address_,
base::Bind(&DoNothingAfterSendToSocket));
Expand All @@ -205,7 +206,7 @@ void DnsSdServer::ProccessQuery(uint32 current_ttl, const DnsQueryRecord& query,
builder->AppendPtr(query.qname, current_ttl,
serv_params_.service_name_, true);

if (CommandLine::ForCurrentProcess()->HasSwitch(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExtendedResponce)) {
builder->AppendSrv(serv_params_.service_name_, current_ttl,
kSrvPriority, kSrvWeight, serv_params_.http_port_,
Expand Down Expand Up @@ -280,7 +281,8 @@ void DnsSdServer::OnDatagramReceived() {
}

void DnsSdServer::SendAnnouncement(uint32 ttl) {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoAnnouncement)) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kNoAnnouncement)) {
DnsResponseBuilder builder(ttl);

builder.AppendPtr(serv_params_.service_type_, ttl,
Expand Down
7 changes: 4 additions & 3 deletions cloud_print/gcp20/prototype/gcp20_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ void OnAbort(int val) {
int main(int argc, char* argv[]) {
base::AtExitManager at_exit;
Printer printer;
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();

logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);

if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kHelp) ||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kHelpShort)) {
if (command_line->HasSwitch(switches::kHelp) ||
command_line->HasSwitch(switches::kHelpShort)) {
switches::PrintUsage();
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion cloud_print/gcp20/prototype/print_job_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ LocalPrintJob::CreateResult PrintJobHandler::CreatePrintJob(
return LocalPrintJob::CREATE_INVALID_TICKET;

// Let's simulate at least some errors just for testing.
if (CommandLine::ForCurrentProcess()->HasSwitch(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSimulatePrintingErrors)) {
if (base::RandDouble() <= kPaperJamProbability) {
*error_description = "Paper jam, try again";
Expand Down
3 changes: 2 additions & 1 deletion cloud_print/gcp20/prototype/printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ PrivetHttpServer::RegistrationErrorStatus Printer::RegistrationStart(
state_.user = user;
state_.registration_state = PrinterState::REGISTRATION_STARTED;

if (CommandLine::ForCurrentProcess()->HasSwitch("disable-confirmation")) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
"disable-confirmation")) {
state_.confirmation_state = PrinterState::CONFIRMATION_CONFIRMED;
VLOG(0) << "Registration confirmed by default.";
} else {
Expand Down
6 changes: 4 additions & 2 deletions cloud_print/gcp20/prototype/privet_http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ void PrivetHttpServer::OnHttpRequest(int connection_id,
if (!ValidateRequestMethod(connection_id, url.path(), info.method))
return;

if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableXTocken)) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableXTocken)) {
net::HttpServerRequestInfo::HeadersMap::const_iterator iter =
info.headers.find("x-privet-token");
if (iter == info.headers.end()) {
Expand Down Expand Up @@ -192,7 +193,8 @@ bool PrivetHttpServer::ValidateRequestMethod(int connection_id,
return false;
}

if (CommandLine::ForCurrentProcess()->HasSwitch("disable-method-check"))
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
"disable-method-check"))
return true;

if ((IsGetMethod(request) && method != "GET") ||
Expand Down
8 changes: 4 additions & 4 deletions cloud_print/service/win/chrome_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void CloseChrome(HANDLE process, DWORD thread_id) {
ShutdownChrome(process, thread_id);
}

bool LaunchProcess(const CommandLine& cmdline,
bool LaunchProcess(const base::CommandLine& cmdline,
base::win::ScopedHandle* process_handle,
DWORD* thread_id) {
STARTUPINFO startup_info = {};
Expand Down Expand Up @@ -149,7 +149,7 @@ void DeleteAutorunKeys(const base::FilePath& user_data_dir) {
base::win::RegistryValueIterator value(HKEY_CURRENT_USER, kAutoRunKeyPath);
for (; value.Valid(); ++value) {
if (value.Type() == REG_SZ && value.Value()) {
CommandLine cmd = CommandLine::FromString(value.Value());
base::CommandLine cmd = base::CommandLine::FromString(value.Value());
if (cmd.GetSwitchValueASCII(switches::kProcessType) ==
switches::kServiceProcess &&
cmd.HasSwitch(switches::kUserDataDir)) {
Expand Down Expand Up @@ -201,7 +201,7 @@ void ChromeLauncher::Run() {
base::FilePath chrome_path = chrome_launcher_support::GetAnyChromePath();

if (!chrome_path.empty()) {
CommandLine cmd(chrome_path);
base::CommandLine cmd(chrome_path);
CopyChromeSwitchesFromCurrentProcess(&cmd);

// Required switches.
Expand Down Expand Up @@ -278,7 +278,7 @@ std::string ChromeLauncher::CreateServiceStateFile(
return std::string();
}

CommandLine cmd(chrome_path);
base::CommandLine cmd(chrome_path);
CopyChromeSwitchesFromCurrentProcess(&cmd);
cmd.AppendSwitchPath(switches::kUserDataDir, temp_user_data.path());
cmd.AppendSwitchPath(switches::kCloudPrintSetupProxy, printers_file);
Expand Down
10 changes: 6 additions & 4 deletions cloud_print/service/win/cloud_print_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CloudPrintServiceModule

bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode) {
CHECK(pnRetCode);
CommandLine command_line(CommandLine::NO_PROGRAM);
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.ParseFromString(lpCmdLine);

LOG(INFO) << command_line.GetCommandLineString();
Expand Down Expand Up @@ -198,7 +198,8 @@ class CloudPrintServiceModule
}

private:
HRESULT ParseCommandLine(const CommandLine& command_line, bool* is_service) {
HRESULT ParseCommandLine(const base::CommandLine& command_line,
bool* is_service) {
if (!is_service)
return E_INVALIDARG;
*is_service = false;
Expand Down Expand Up @@ -404,15 +405,16 @@ BOOL CloudPrintServiceModule::ConsoleCtrlHandler(DWORD type) {
}

int main(int argc, char** argv) {
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::AtExitManager at_exit;

logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);

logging::SetMinLogLevel(
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableLogging) ?
command_line->HasSwitch(switches::kEnableLogging) ?
logging::LOG_INFO : logging::LOG_FATAL);

return _AtlModule.WinMain(0);
Expand Down
2 changes: 1 addition & 1 deletion cloud_print/service/win/cloud_print_service_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow) {
base::AtExitManager at_exit;
CommandLine::Init(0, NULL);
base::CommandLine::Init(0, NULL);

base::MessageLoopForUI loop;
scoped_refptr<SetupDialog> dialog(new SetupDialog());
Expand Down
5 changes: 3 additions & 2 deletions cloud_print/service/win/installer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void DeleteShortcuts() {
} // namespace

HRESULT ProcessInstallerSwitches() {
const CommandLine& command_line(*CommandLine::ForCurrentProcess());
const base::CommandLine& command_line(
*base::CommandLine::ForCurrentProcess());

if (command_line.HasSwitch(kInstallSwitch)) {
base::FilePath old_location =
Expand Down Expand Up @@ -139,6 +140,6 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
__in LPSTR lpCmdLine,
__in int nCmdShow) {
base::AtExitManager at_exit;
CommandLine::Init(0, NULL);
base::CommandLine::Init(0, NULL);
return ProcessInstallerSwitches();
}
6 changes: 3 additions & 3 deletions cloud_print/service/win/service_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ HRESULT OpenService(const base::string16& name, DWORD access,

ServiceController::ServiceController()
: name_(cloud_print::LoadLocalString(IDS_SERVICE_NAME)),
command_line_(CommandLine::NO_PROGRAM) {
command_line_(base::CommandLine::NO_PROGRAM) {
}

ServiceController::~ServiceController() {
Expand Down Expand Up @@ -164,7 +164,7 @@ HRESULT ServiceController::InstallService(const base::string16& user,
base::FilePath service_path = GetBinary();
if (!base::PathExists(service_path))
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
CommandLine command_line(service_path);
base::CommandLine command_line(service_path);
command_line.AppendSwitch(run_switch);
if (!user_data_dir.empty())
command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir);
Expand Down Expand Up @@ -304,7 +304,7 @@ void ServiceController::UpdateState() {
return;
}

command_line_ = CommandLine::FromString(config->lpBinaryPathName);
command_line_ = base::CommandLine::FromString(config->lpBinaryPathName);
if (!command_line_.HasSwitch(kServiceSwitch)) {
state_ = STATE_NOT_FOUND;
return;
Expand Down
4 changes: 2 additions & 2 deletions cloud_print/service/win/service_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ base::string16 GetCurrentUserName() {
return result;
}

void CopyChromeSwitchesFromCurrentProcess(CommandLine* destination) {
void CopyChromeSwitchesFromCurrentProcess(base::CommandLine* destination) {
static const char* const kSwitchesToCopy[] = {
switches::kCloudPrintURL,
switches::kCloudPrintXmppEndpoint,
Expand All @@ -58,7 +58,7 @@ void CopyChromeSwitchesFromCurrentProcess(CommandLine* destination) {
switches::kLsoUrl,
switches::kV,
};
destination->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
destination->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kSwitchesToCopy,
arraysize(kSwitchesToCopy));
}
Expand Down
11 changes: 6 additions & 5 deletions cloud_print/virtual_driver/win/install/setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void SpoolerServiceCommand(const char* command) {
base::FilePath net_path = GetNativeSystemPath(L"net");
if (net_path.empty())
return;
CommandLine command_line(net_path);
base::CommandLine command_line(net_path);
command_line.AppendArg(command);
command_line.AppendArg("spooler");
command_line.AppendArg("/y");
Expand Down Expand Up @@ -126,7 +126,7 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) {
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
}

CommandLine command_line(regsvr32_path);
base::CommandLine command_line(regsvr32_path);
command_line.AppendArg("/s");
if (!install) {
command_line.AppendArg("/u");
Expand Down Expand Up @@ -503,7 +503,8 @@ HRESULT DoInstall(const base::FilePath& install_path) {
}

HRESULT ExecuteCommands() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();

base::FilePath exe_path;
if (FAILED(PathService::Get(base::DIR_EXE, &exe_path)) ||
Expand Down Expand Up @@ -537,7 +538,7 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
using namespace cloud_print;

base::AtExitManager at_exit_manager;
CommandLine::Init(0, NULL);
base::CommandLine::Init(0, NULL);

HRESULT retval = ExecuteCommands();

Expand All @@ -552,7 +553,7 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
<< " HRESULT=0x" << std::setbase(16) << retval;

// Installer is silent by default as required by Google Update.
if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch("verbose")) {
DisplayWindowsMessage(NULL, retval, LoadLocalString(IDS_DRIVER_NAME));
}
return retval;
Expand Down
4 changes: 2 additions & 2 deletions cloud_print/virtual_driver/win/port_monitor/port_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool LaunchPrintDialog(const base::FilePath& xps_path,
return false;
}

CommandLine command_line(chrome_path);
base::CommandLine command_line(chrome_path);

base::FilePath chrome_profile = GetChromeProfilePath();
if (!chrome_profile.empty())
Expand Down Expand Up @@ -250,7 +250,7 @@ void LaunchChromeDownloadPage() {
base::FilePath ie_path;
PathService::Get(base::DIR_PROGRAM_FILESX86, &ie_path);
ie_path = ie_path.Append(kIePath);
CommandLine command_line(ie_path);
base::CommandLine command_line(ie_path);
command_line.AppendArg(kChromeInstallUrl);

base::LaunchOptions options;
Expand Down

0 comments on commit 588a3ea

Please sign in to comment.