diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 18:24:38 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 18:24:38 +0000 |
commit | 13081fccbf907aef8476c94d904fc94d6c59a206 (patch) | |
tree | 9470fa1206aba0c8b41ad569a019c7ad484ab7ab | |
parent | 815d63d9f1c68ffa056ad2c2c8fee34f0d0b70b8 (diff) | |
download | chromium_src-13081fccbf907aef8476c94d904fc94d6c59a206.zip chromium_src-13081fccbf907aef8476c94d904fc94d6c59a206.tar.gz chromium_src-13081fccbf907aef8476c94d904fc94d6c59a206.tar.bz2 |
PrependWrapper is platform-specific, so it should take a platform string.
Though the comments said it was POSIX only, I see it used on Windows as
well so I'm updating the comment.
Review URL: http://codereview.chromium.org/3030043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54933 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/command_line.cc | 5 | ||||
-rw-r--r-- | base/command_line.h | 6 | ||||
-rw-r--r-- | chrome/browser/gpu_process_host.cc | 4 | ||||
-rw-r--r-- | chrome/browser/plugin_process_host.cc | 4 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 8 | ||||
-rw-r--r-- | chrome/browser/utility_process_host.cc | 2 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 9 | ||||
-rw-r--r-- | chrome/browser/zygote_host_linux.cc | 7 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 2 |
9 files changed, 23 insertions, 24 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index e180ddf..8d36e16 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -432,6 +432,8 @@ void CommandLine::AppendArguments(const CommandLine& other, } void CommandLine::PrependWrapper(const std::wstring& wrapper) { + if (wrapper.empty()) + return; // The wrapper may have embedded arguments (like "gdb --args"). In this case, // we don't pretend to do anything fancy, we just split on spaces. std::vector<std::wstring> wrapper_and_args; @@ -475,10 +477,9 @@ void CommandLine::AppendArguments(const CommandLine& other, switches_[i->first] = i->second; } -void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { +void CommandLine::PrependWrapper(const std::string& wrapper) { // The wrapper may have embedded arguments (like "gdb --args"). In this case, // we don't pretend to do anything fancy, we just split on spaces. - const std::string wrapper = base::SysWideToNativeMB(wrapper_wide); std::vector<std::string> wrapper_and_args; SplitString(wrapper, ' ', &wrapper_and_args); argv_.insert(argv_.begin(), wrapper_and_args.begin(), wrapper_and_args.end()); diff --git a/base/command_line.h b/base/command_line.h index 2178bdf..331add9 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -173,9 +173,9 @@ class CommandLine { void AppendArguments(const CommandLine& other, bool include_program); - // On POSIX systems it's common to run processes via a wrapper (like - // "valgrind" or "gdb --args"). - void PrependWrapper(const std::wstring& wrapper); + // Insert a command before the current command. Common for debuggers, + // like "valgrind" or "gdb --args". + void PrependWrapper(const StringType& wrapper); // Copy a set of switches (and their values, if any) from another command // line. Commonly used when launching a subprocess. diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc index 19b0993..fe8e5f8 100644 --- a/chrome/browser/gpu_process_host.cc +++ b/chrome/browser/gpu_process_host.cc @@ -78,8 +78,8 @@ bool GpuProcessHost::Init() { return false; const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); - std::wstring gpu_launcher = - browser_command_line.GetSwitchValue(switches::kGpuLauncher); + CommandLine::StringType gpu_launcher = + browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); FilePath exe_path = ChildProcessHost::GetChildPath(gpu_launcher.empty()); if (exe_path.empty()) diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 07ba624..d833247 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -350,8 +350,8 @@ bool PluginProcessHost::Init(const WebPluginInfo& info, // Build command line for plugin. When we have a plugin launcher, we can't // allow "self" on linux and we need the real file path. const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); - std::wstring plugin_launcher = - browser_command_line.GetSwitchValue(switches::kPluginLauncher); + CommandLine::StringType plugin_launcher = + browser_command_line.GetSwitchValueNative(switches::kPluginLauncher); FilePath exe_path = GetChildPath(plugin_launcher.empty()); if (exe_path.empty()) return false; diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 796aa710..3009737 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -272,19 +272,19 @@ bool BrowserRenderProcessHost::Init(bool is_extensions_process) { profile(), widget_helper_); - std::wstring renderer_prefix; + CommandLine::StringType renderer_prefix; #if defined(OS_POSIX) // A command prefix is something prepended to the command line of the spawned // process. It is supported only on POSIX systems. const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); renderer_prefix = - browser_command_line.GetSwitchValue(switches::kRendererCmdPrefix); + browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); #endif // defined(OS_POSIX) // Find the renderer before creating the channel so if this fails early we // return without creating the channel. - FilePath renderer_path = ChildProcessHost::GetChildPath( - renderer_prefix.empty()); + FilePath renderer_path = + ChildProcessHost::GetChildPath(renderer_prefix.empty()); if (renderer_path.empty()) return false; diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc index 7b6772e..e49df71 100644 --- a/chrome/browser/utility_process_host.cc +++ b/chrome/browser/utility_process_host.cc @@ -109,7 +109,7 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { if (has_cmd_prefix) { // launch the utility child process with some prefix (usually "xterm -e gdb // --args"). - cmd_line->PrependWrapper(browser_command_line.GetSwitchValue( + cmd_line->PrependWrapper(browser_command_line.GetSwitchValueNative( switches::kUtilityCmdPrefix)); } diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 8b3ac2d..2c4cf7f 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -143,16 +143,15 @@ bool WorkerProcessHost::Init() { if (value.empty() || value == switches::kWorkerProcess) { // launches a new xterm, and runs the worker process in gdb, reading // optional commands from gdb_chrome file in the working directory. - cmd_line->PrependWrapper(L"xterm -e gdb -x gdb_chrome --args"); + cmd_line->PrependWrapper("xterm -e gdb -x gdb_chrome --args"); } } if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kRendererCmdPrefix)) { - const std::wstring prefix = - CommandLine::ForCurrentProcess()->GetSwitchValue( - switches::kRendererCmdPrefix); - cmd_line->PrependWrapper(prefix); + cmd_line->PrependWrapper( + CommandLine::ForCurrentProcess()->GetSwitchValueNative( + switches::kRendererCmdPrefix)); } #endif diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc index cc91bd2..be0ce5a 100644 --- a/chrome/browser/zygote_host_linux.cc +++ b/chrome/browser/zygote_host_linux.cc @@ -81,9 +81,8 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) { const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { - const std::wstring prefix = - browser_command_line.GetSwitchValue(switches::kZygoteCmdPrefix); - cmd_line.PrependWrapper(prefix); + cmd_line.PrependWrapper( + browser_command_line.GetSwitchValueNative(switches::kZygoteCmdPrefix)); } // Append any switches from the browser process that need to be forwarded on // to the zygote/renderers. @@ -113,7 +112,7 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) { (st.st_mode & S_ISUID) && (st.st_mode & S_IXOTH)) { using_suid_sandbox_ = true; - cmd_line.PrependWrapper(ASCIIToWide(sandbox_binary_.c_str())); + cmd_line.PrependWrapper(sandbox_binary_); SaveSUIDUnsafeEnvironmentVariables(); } else { diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 48849a3..bef3801 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -1209,7 +1209,7 @@ bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, // commandline with a special prefix to invoke the special environment. const char* browser_wrapper = getenv("BROWSER_WRAPPER"); if (browser_wrapper) { - command_line.PrependWrapper(ASCIIToWide(browser_wrapper)); + command_line.PrependWrapper(browser_wrapper); LOG(INFO) << "BROWSER_WRAPPER was set, prefixing command_line with " << browser_wrapper; } |