Commit b982d511 authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Use base::CommandLine in remoting/

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272455 0039d316-1c4b-4281-b951-d872f2087c98
parent dd70f2bf
......@@ -46,7 +46,7 @@ static void LoadNative(JNIEnv* env, jclass clazz, jobject context) {
// runtime API keys have been specified by the environment. Unfortunately, we
// neither launch Chromium nor have a command line, so we need to prevent
// them from DCHECKing out when they go looking.
CommandLine::Init(0, NULL);
base::CommandLine::Init(0, NULL);
// Create the singleton now so that the Chromoting threads will be set up.
remoting::ChromotingJniRuntime::GetInstance();
......
......@@ -259,7 +259,8 @@ void DaemonProcess::CrashNetworkProcess(
void DaemonProcess::Initialize() {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
const CommandLine* command_line = CommandLine::ForCurrentProcess();
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
// Get the name of the host configuration file.
base::FilePath default_config_dir = remoting::GetConfigDir();
base::FilePath config_path = default_config_dir.Append(
......
......@@ -23,7 +23,8 @@
namespace remoting {
int DesktopProcessMain() {
const CommandLine* command_line = CommandLine::ForCurrentProcess();
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
std::string channel_name =
command_line->GetSwitchValueASCII(kDaemonPipeSwitchName);
......
......@@ -160,9 +160,9 @@ DesktopResizerLinux::DesktopResizerLinux()
: display_(XOpenDisplay(NULL)),
screen_(DefaultScreen(display_)),
root_(RootWindow(display_, screen_)),
exact_resize_(CommandLine::ForCurrentProcess()->
exact_resize_(base::CommandLine::ForCurrentProcess()->
HasSwitch("server-supports-exact-resize")) {
XRRSelectInput (display_, root_, RRScreenChangeNotifyMask);
XRRSelectInput(display_, root_, RRScreenChangeNotifyMask);
}
DesktopResizerLinux::~DesktopResizerLinux() {
......
......@@ -86,27 +86,30 @@ void Usage(const base::FilePath& program_name) {
// Runs the binary specified by the command line, elevated.
int RunElevated() {
const CommandLine::SwitchMap& switches =
CommandLine::ForCurrentProcess()->GetSwitches();
CommandLine::StringVector args = CommandLine::ForCurrentProcess()->GetArgs();
const base::CommandLine::SwitchMap& switches =
base::CommandLine::ForCurrentProcess()->GetSwitches();
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
// Create the child process command line by copying switches from the current
// command line.
CommandLine command_line(CommandLine::NO_PROGRAM);
for (CommandLine::SwitchMap::const_iterator i = switches.begin();
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
for (base::CommandLine::SwitchMap::const_iterator i = switches.begin();
i != switches.end(); ++i) {
if (i->first != kElevateSwitchName)
command_line.AppendSwitchNative(i->first, i->second);
}
for (CommandLine::StringVector::const_iterator i = args.begin();
for (base::CommandLine::StringVector::const_iterator i = args.begin();
i != args.end(); ++i) {
command_line.AppendArgNative(*i);
}
// Get the name of the binary to launch.
base::FilePath binary =
CommandLine::ForCurrentProcess()->GetSwitchValuePath(kElevateSwitchName);
CommandLine::StringType parameters = command_line.GetCommandLineString();
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
kElevateSwitchName);
base::CommandLine::StringType parameters =
command_line.GetCommandLineString();
// Launch the child process requesting elevation.
SHELLEXECUTEINFO info;
......@@ -157,7 +160,7 @@ int HostMain(int argc, char** argv) {
base::mac::ScopedNSAutoreleasePool pool;
#endif
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
// Initialize Breakpad as early as possible. On Mac the command-line needs to
// be initialized first, so that the preference for crash-reporting can be
......@@ -184,7 +187,8 @@ int HostMain(int argc, char** argv) {
#endif // defined(OS_WIN)
// Parse the command line.
const CommandLine* command_line = CommandLine::ForCurrentProcess();
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kHelpSwitchName) ||
command_line->HasSwitch(kQuestionSwitchName)) {
Usage(command_line->GetProgram());
......
......@@ -131,7 +131,7 @@ int It2MeNativeMessagingHostMain(int argc, char** argv) {
// This object instance is required by Chrome code (such as MessageLoop).
base::AtExitManager exit_manager;
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
remoting::InitHostLogging();
return StartIt2MeNativeMessagingHost();
......
......@@ -371,7 +371,7 @@ void InitializePlugin() {
g_at_exit_manager = new base::AtExitManager;
// Init an empty command line for common objects that use it.
CommandLine::Init(0, NULL);
base::CommandLine::Init(0, NULL);
if (remoting::LoadResources("")) {
g_ui_name = new std::string(
......@@ -449,7 +449,7 @@ NPError GetValue(NPP instance, NPPVariable variable, void* value) {
// NP_GetValue() can be called before NP_Initialize().
InitializePlugin();
switch(variable) {
switch (variable) {
default:
VLOG(2) << "GetValue - default " << variable;
return NPERR_GENERIC_ERROR;
......@@ -533,10 +533,10 @@ EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* npnetscape_funcs
VLOG(2) << "NP_Initialize";
InitializePlugin();
if(npnetscape_funcs == NULL)
if (npnetscape_funcs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(((npnetscape_funcs->version & 0xff00) >> 8) > NP_VERSION_MAJOR)
if (((npnetscape_funcs->version & 0xff00) >> 8) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
g_npnetscape_funcs = npnetscape_funcs;
......
......@@ -209,7 +209,7 @@ class HostProcess
// Initializes IPC control channel and config file path from |cmd_line|.
// Called on the UI thread.
bool InitWithCommandLine(const CommandLine* cmd_line);
bool InitWithCommandLine(const base::CommandLine* cmd_line);
// Called on the UI thread to start monitoring the configuration file.
void StartWatchingConfigChanges();
......@@ -361,7 +361,7 @@ HostProcess::~HostProcess() {
task_runner->DeleteSoon(FROM_HERE, context_.release());
}
bool HostProcess::InitWithCommandLine(const CommandLine* cmd_line) {
bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) {
#if defined(REMOTING_MULTI_PROCESS)
// Parse the handle value and convert it to a handle/file descriptor.
std::string channel_name =
......@@ -631,7 +631,7 @@ void HostProcess::OnChannelError() {
void HostProcess::StartOnUiThread() {
DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
if (!InitWithCommandLine(CommandLine::ForCurrentProcess())) {
if (!InitWithCommandLine(base::CommandLine::ForCurrentProcess())) {
// Shutdown the host if the command line is invalid.
context_->network_task_runner()->PostTask(
FROM_HERE, base::Bind(&HostProcess::ShutdownHost, this,
......@@ -642,14 +642,14 @@ void HostProcess::StartOnUiThread() {
#if defined(OS_LINUX)
// If an audio pipe is specific on the command-line then initialize
// AudioCapturerLinux to capture from it.
base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()->
base::FilePath audio_pipe_name = base::CommandLine::ForCurrentProcess()->
GetSwitchValuePath(kAudioPipeSwitchName);
if (!audio_pipe_name.empty()) {
remoting::AudioCapturerLinux::InitializePipeReader(
context_->audio_task_runner(), audio_pipe_name);
}
base::FilePath gnubby_socket_name = CommandLine::ForCurrentProcess()->
base::FilePath gnubby_socket_name = base::CommandLine::ForCurrentProcess()->
GetSwitchValuePath(kAuthSocknameSwitchName);
if (!gnubby_socket_name.empty())
remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name);
......
......@@ -33,7 +33,7 @@ ServiceUrls::ServiceUrls()
directory_bot_jid_(kDirectoryBotJid) {
#if !defined(NDEBUG)
// Allow debug builds to override urls via command line.
CommandLine* command_line = CommandLine::ForCurrentProcess();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
CHECK(command_line);
if (command_line->HasSwitch(kDirectoryBaseUrlSwitch)) {
directory_base_url_ = command_line->GetSwitchValueASCII(
......
......@@ -85,7 +85,7 @@ bool RunHostScriptWithTimeout(
LOG(ERROR) << "GetScriptPath() failed.";
return false;
}
CommandLine command_line(script_path);
base::CommandLine command_line(script_path);
for (unsigned int i = 0; i < args.size(); ++i) {
command_line.AppendArg(args[i]);
}
......@@ -132,7 +132,7 @@ DaemonController::State DaemonControllerDelegateLinux::GetState() {
if (!GetScriptPath(&script_path)) {
return DaemonController::STATE_NOT_IMPLEMENTED;
}
CommandLine command_line(script_path);
base::CommandLine command_line(script_path);
command_line.AppendArg("--get-status");
std::string status;
......@@ -182,7 +182,7 @@ scoped_ptr<base::DictionaryValue> DaemonControllerDelegateLinux::GetConfig() {
result->SetString(kXmppLoginConfigPath, value);
}
} else {
result.reset(); // Return NULL in case of error.
result.reset(); // Return NULL in case of error.
}
}
......@@ -282,7 +282,7 @@ std::string DaemonControllerDelegateLinux::GetVersion() {
if (!GetScriptPath(&script_path)) {
return std::string();
}
CommandLine command_line(script_path);
base::CommandLine command_line(script_path);
command_line.AppendArg("--host-version");
std::string version;
......
......@@ -592,30 +592,33 @@ void Me2MeNativeMessagingHost::EnsureElevatedHostCreated() {
return;
}
const CommandLine* current_command_line = CommandLine::ForCurrentProcess();
const CommandLine::SwitchMap& switches = current_command_line->GetSwitches();
CommandLine::StringVector args = current_command_line->GetArgs();
const base::CommandLine* current_command_line =
base::CommandLine::ForCurrentProcess();
const base::CommandLine::SwitchMap& switches =
current_command_line->GetSwitches();
base::CommandLine::StringVector args = current_command_line->GetArgs();
// Create the child process command line by copying switches from the current
// command line.
CommandLine command_line(CommandLine::NO_PROGRAM);
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch(kElevatingSwitchName);
command_line.AppendSwitchASCII(kInputSwitchName, input_pipe_name);
command_line.AppendSwitchASCII(kOutputSwitchName, output_pipe_name);
DCHECK(!current_command_line->HasSwitch(kElevatingSwitchName));
for (CommandLine::SwitchMap::const_iterator i = switches.begin();
for (base::CommandLine::SwitchMap::const_iterator i = switches.begin();
i != switches.end(); ++i) {
command_line.AppendSwitchNative(i->first, i->second);
}
for (CommandLine::StringVector::const_iterator i = args.begin();
for (base::CommandLine::StringVector::const_iterator i = args.begin();
i != args.end(); ++i) {
command_line.AppendArgNative(*i);
}
// Get the name of the binary to launch.
base::FilePath binary = current_command_line->GetProgram();
CommandLine::StringType parameters = command_line.GetCommandLineString();
base::CommandLine::StringType parameters =
command_line.GetCommandLineString();
// Launch the child process requesting elevation.
SHELLEXECUTEINFO info;
......
......@@ -93,7 +93,8 @@ int StartMe2MeNativeMessagingHost() {
// Pass handle of the native view to the controller so that the UAC prompts
// are focused properly.
const CommandLine* command_line = CommandLine::ForCurrentProcess();
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
int64 native_view_handle = 0;
if (command_line->HasSwitch(kParentWindowSwitchName)) {
std::string native_view =
......@@ -254,7 +255,7 @@ int Me2MeNativeMessagingHostMain(int argc, char** argv) {
// This object instance is required by Chrome code (such as MessageLoop).
base::AtExitManager exit_manager;
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
remoting::InitHostLogging();
return StartMe2MeNativeMessagingHost();
......
......@@ -86,8 +86,9 @@ void OnDone(HostStarter::Result result) {
int main(int argc, char** argv) {
// google_apis::GetOAuth2ClientID/Secret need a static CommandLine.
CommandLine::Init(argc, argv);
const CommandLine* command_line = CommandLine::ForCurrentProcess();
base::CommandLine::Init(argc, argv);
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
std::string host_name = command_line->GetSwitchValueASCII("name");
std::string host_pin = command_line->GetSwitchValueASCII("pin");
......
......@@ -21,7 +21,7 @@ bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) {
// Normally, the ConfigFileWatcher class would be used for retrieving config
// settings, but this code needs to execute before Breakpad is initialised,
// which itself should happen as early as possible during startup.
CommandLine* command_line = CommandLine::ForCurrentProcess();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kHostConfigSwitchName)) {
base::FilePath config_file_path =
command_line->GetSwitchValuePath(kHostConfigSwitchName);
......
......@@ -65,8 +65,8 @@ HostService* HostService::GetInstance() {
return Singleton<HostService>::get();
}
bool HostService::InitWithCommandLine(const CommandLine* command_line) {
CommandLine::StringVector args = command_line->GetArgs();
bool HostService::InitWithCommandLine(const base::CommandLine* command_line) {
base::CommandLine::StringVector args = command_line->GetArgs();
if (!args.empty()) {
LOG(ERROR) << "No positional parameters expected.";
return false;
......@@ -433,11 +433,11 @@ VOID WINAPI HostService::ServiceMain(DWORD argc, WCHAR* argv[]) {
int DaemonProcessMain() {
HostService* service = HostService::GetInstance();
if (!service->InitWithCommandLine(CommandLine::ForCurrentProcess())) {
if (!service->InitWithCommandLine(base::CommandLine::ForCurrentProcess())) {
return kUsageExitCode;
}
return service->Run();
}
} // namespace remoting
} // namespace remoting
......@@ -287,7 +287,7 @@ bool ReceiveCreateProcessResponse(
bool SendCreateProcessRequest(
HANDLE pipe,
const base::FilePath::StringType& application_name,
const CommandLine::StringType& command_line,
const base::CommandLine::StringType& command_line,
DWORD creation_flags,
const base::char16* desktop_name) {
// |CreateProcessRequest| structure passes the same parameters to
......@@ -370,11 +370,10 @@ bool SendCreateProcessRequest(
bool CreateRemoteSessionProcess(
uint32 session_id,
const base::FilePath::StringType& application_name,
const CommandLine::StringType& command_line,
const base::CommandLine::StringType& command_line,
DWORD creation_flags,
const base::char16* desktop_name,
PROCESS_INFORMATION* process_information_out)
{
PROCESS_INFORMATION* process_information_out) {
DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA);
base::win::ScopedHandle pipe;
......@@ -399,7 +398,7 @@ bool CreateRemoteSessionProcess(
return true;
}
} // namespace
} // namespace
namespace remoting {
......@@ -448,7 +447,7 @@ bool CreateSessionToken(uint32 session_id, ScopedHandle* token_out) {
}
bool LaunchProcessWithToken(const base::FilePath& binary,
const CommandLine::StringType& command_line,
const base::CommandLine::StringType& command_line,
HANDLE user_token,
SECURITY_ATTRIBUTES* process_attributes,
SECURITY_ATTRIBUTES* thread_attributes,
......@@ -521,4 +520,4 @@ bool LaunchProcessWithToken(const base::FilePath& binary,
return true;
}
} // namespace remoting
} // namespace remoting
......@@ -291,7 +291,7 @@ void UnprivilegedProcessDelegate::LaunchProcess(
"%d", reinterpret_cast<ULONG_PTR>(client.Get()));
// Pass the IPC channel via the command line.
CommandLine command_line(target_command_->argv());
base::CommandLine command_line(target_command_->argv());
command_line.AppendSwitchASCII(kDaemonPipeSwitchName, pipe_handle);
// Create our own window station and desktop accessible by |logon_sid|.
......@@ -418,4 +418,4 @@ void UnprivilegedProcessDelegate::ReportProcessLaunched(
event_handler_->OnProcessLaunched(limited_handle.Pass());
}
} // namespace remoting
} // namespace remoting
......@@ -348,7 +348,7 @@ void WtsSessionProcessDelegate::Core::DoLaunchProcess() {
DCHECK(!pipe_.IsValid());
DCHECK(!worker_process_.IsValid());
CommandLine command_line(target_command_->argv());
base::CommandLine command_line(target_command_->argv());
if (launch_elevated_) {
// The job object is not ready. Retry starting the host process later.
if (!job_.IsValid()) {
......@@ -564,4 +564,4 @@ void WtsSessionProcessDelegate::KillProcess() {
core_->KillProcess();
}
} // namespace remoting
} // namespace remoting
......@@ -34,20 +34,21 @@ void usage(const char* program_name) {
} // namespace
int main(int argc, char** argv) {
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
base::AtExitManager exit_manager;
remoting::InitHostLogging();
const CommandLine* command_line = CommandLine::ForCurrentProcess();
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kHelpSwitchName) ||
command_line->HasSwitch(kQuestionSwitchName)) {
usage(argv[0]);
return kSuccessExitCode;
}
CommandLine::StringVector args = command_line->GetArgs();
base::CommandLine::StringVector args = command_line->GetArgs();
if (args.size() != 1) {
usage(argv[0]);
return kUsageExitCode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment