diff options
author | rvargas <rvargas@chromium.org> | 2014-12-01 14:53:09 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-01 22:53:31 +0000 |
commit | 6293e5b91f8f3992e30796eac3a9758b12223519 (patch) | |
tree | bedca9813fdc1bca01d8601794ab469e566d7536 | |
parent | 2644f688b10594e42df1ed4f38eee931159f7661 (diff) | |
download | chromium_src-6293e5b91f8f3992e30796eac3a9758b12223519.zip chromium_src-6293e5b91f8f3992e30796eac3a9758b12223519.tar.gz chromium_src-6293e5b91f8f3992e30796eac3a9758b12223519.tar.bz2 |
Update base::LaunchElevatedProcess to return a Process instead of a handle.
BUG=417532
Review URL: https://codereview.chromium.org/755783002
Cr-Commit-Position: refs/heads/master@{#306280}
-rw-r--r-- | base/process/launch.h | 11 | ||||
-rw-r--r-- | base/process/launch_win.cc | 16 | ||||
-rw-r--r-- | chrome/installer/util/google_update_util.cc | 2 | ||||
-rw-r--r-- | content/browser/child_process_launcher.cc | 4 |
4 files changed, 11 insertions, 22 deletions
diff --git a/base/process/launch.h b/base/process/launch.h index 261019b..6134622 100644 --- a/base/process/launch.h +++ b/base/process/launch.h @@ -14,6 +14,7 @@ #include "base/base_export.h" #include "base/basictypes.h" #include "base/environment.h" +#include "base/process/process.h" #include "base/process/process_handle.h" #include "base/strings/string_piece.h" @@ -180,12 +181,10 @@ BASE_EXPORT bool LaunchProcess(const string16& cmdline, // Launches a process with elevated privileges. This does not behave exactly // like LaunchProcess as it uses ShellExecuteEx instead of CreateProcess to // create the process. This means the process will have elevated privileges -// and thus some common operations like OpenProcess will fail. The process will -// be available through the |process_handle| argument. Currently the only -// supported LaunchOptions are |start_hidden| and |wait|. -BASE_EXPORT bool LaunchElevatedProcess(const CommandLine& cmdline, - const LaunchOptions& options, - ProcessHandle* process_handle); +// and thus some common operations like OpenProcess will fail. Currently the +// only supported LaunchOptions are |start_hidden| and |wait|. +BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline, + const LaunchOptions& options); #elif defined(OS_POSIX) // A POSIX-specific version of LaunchProcess that takes an argv array diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc index a3303a5..59a6e0e 100644 --- a/base/process/launch_win.cc +++ b/base/process/launch_win.cc @@ -244,9 +244,8 @@ bool LaunchProcess(const CommandLine& cmdline, return rv; } -bool LaunchElevatedProcess(const CommandLine& cmdline, - const LaunchOptions& options, - ProcessHandle* process_handle) { +Process LaunchElevatedProcess(const CommandLine& cmdline, + const LaunchOptions& options) { const string16 file = cmdline.GetProgram().value(); const string16 arguments = cmdline.GetArgumentsString(); @@ -263,20 +262,13 @@ bool LaunchElevatedProcess(const CommandLine& cmdline, if (!ShellExecuteEx(&shex_info)) { DPLOG(ERROR); - return false; + return Process(); } if (options.wait) WaitForSingleObject(shex_info.hProcess, INFINITE); - // If the caller wants the process handle give it to them, otherwise just - // close it. Closing it does not terminate the process. - if (process_handle) - *process_handle = shex_info.hProcess; - else - CloseHandle(shex_info.hProcess); - - return true; + return Process(shex_info.hProcess); } bool SetJobObjectLimitFlags(HANDLE job_object, DWORD limit_flags) { diff --git a/chrome/installer/util/google_update_util.cc b/chrome/installer/util/google_update_util.cc index 1b8c74d..68e4675 100644 --- a/chrome/installer/util/google_update_util.cc +++ b/chrome/installer/util/google_update_util.cc @@ -182,7 +182,7 @@ void ElevateIfNeededToReenableUpdates() { if (base::win::GetVersion() >= base::win::VERSION_VISTA && base::win::UserAccountControlIsEnabled()) { - base::LaunchElevatedProcess(cmd, launch_options, NULL); + base::LaunchElevatedProcess(cmd, launch_options); } else { base::LaunchProcess(cmd, launch_options, NULL); } diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 3529a74..080ce03 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -317,9 +317,7 @@ void ChildProcessLauncher::Context::LaunchInternal( if (launch_elevated) { base::LaunchOptions options; options.start_hidden = true; - base::ProcessHandle handle = base::kNullProcessHandle; - if (base::LaunchElevatedProcess(*cmd_line, options, &handle)) - process = base::Process(handle); + process = base::LaunchElevatedProcess(*cmd_line, options); } else { process = StartSandboxedProcess(delegate, cmd_line); } |