summaryrefslogtreecommitdiffstats
path: root/base/multiprocess_test.h
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-01 03:28:47 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-01 03:28:47 +0000
commite50130bb863d3d904d8c1bccb9ab86c1bdcf88e5 (patch)
treeecbf141b6c12b41c7111b90a828c357db6beb5f1 /base/multiprocess_test.h
parente7f2be605361283b5ce2ea8d302ef9a8e34c4c69 (diff)
downloadchromium_src-e50130bb863d3d904d8c1bccb9ab86c1bdcf88e5.zip
chromium_src-e50130bb863d3d904d8c1bccb9ab86c1bdcf88e5.tar.gz
chromium_src-e50130bb863d3d904d8c1bccb9ab86c1bdcf88e5.tar.bz2
Add a utility function to run a process as an arbitrary user
- Only for windows - Needed in certain upgrade scenarios, useful for all BUG=32474 TEST= unit tests included Review URL: http://codereview.chromium.org/555192 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/multiprocess_test.h')
-rw-r--r--base/multiprocess_test.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/base/multiprocess_test.h b/base/multiprocess_test.h
index 7b9af1a..4fa5693 100644
--- a/base/multiprocess_test.h
+++ b/base/multiprocess_test.h
@@ -83,21 +83,25 @@ class MultiProcessTest : public PlatformTest {
}
#endif
- private:
-#if defined(OS_WIN)
- base::ProcessHandle SpawnChildImpl(
- const std::wstring& procname,
- bool debug_on_start) {
+protected:
+ CommandLine MakeCmdLine(const std::wstring& procname, bool debug_on_start) {
CommandLine cl(*CommandLine::ForCurrentProcess());
- base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
cl.AppendSwitchWithValue(kRunClientProcess, procname);
-
if (debug_on_start)
cl.AppendSwitch(switches::kDebugOnStart);
+ return cl;
+ }
- base::LaunchApp(cl, false, true, &handle);
+ private:
+#if defined(OS_WIN)
+ base::ProcessHandle SpawnChildImpl(const std::wstring& procname,
+ bool debug_on_start) {
+ base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
+ base::LaunchApp(MakeCmdLine(procname, debug_on_start),
+ false, true, &handle);
return handle;
}
+
#elif defined(OS_POSIX)
// TODO(port): with the CommandLine refactoring, this code is very similar
// to the Windows code. Investigate whether this can be made shorter.
@@ -105,14 +109,9 @@ class MultiProcessTest : public PlatformTest {
const std::wstring& procname,
const base::file_handle_mapping_vector& fds_to_map,
bool debug_on_start) {
- CommandLine cl(*CommandLine::ForCurrentProcess());
base::ProcessHandle handle = base::kNullProcessHandle;
- cl.AppendSwitchWithValue(kRunClientProcess, procname);
-
- if (debug_on_start)
- cl.AppendSwitch(switches::kDebugOnStart);
-
- base::LaunchApp(cl.argv(), fds_to_map, false, &handle);
+ base::LaunchApp(MakeCmdLine(procname, debug_on_start).argv(),
+ fds_to_map, false, &handle);
return handle;
}
#endif