diff options
26 files changed, 107 insertions, 100 deletions
diff --git a/base/process/kill.h b/base/process/kill.h index de72d7a..f697701 100644 --- a/base/process/kill.h +++ b/base/process/kill.h @@ -9,6 +9,7 @@ #define BASE_PROCESS_KILL_H_ #include "base/files/file_path.h" +#include "base/process/process.h" #include "base/process/process_handle.h" #include "base/time/time.h" @@ -146,10 +147,10 @@ BASE_EXPORT bool CleanupProcesses(const FilePath::StringType& executable_name, // On Linux this method does not block the calling thread. // On OS X this method may block for up to 2 seconds. // -// NOTE: The process handle must have been opened with the PROCESS_TERMINATE -// and SYNCHRONIZE permissions. +// NOTE: The process must have been opened with the PROCESS_TERMINATE and +// SYNCHRONIZE permissions. // -BASE_EXPORT void EnsureProcessTerminated(ProcessHandle process_handle); +BASE_EXPORT void EnsureProcessTerminated(Process process); #if defined(OS_POSIX) && !defined(OS_MACOSX) // The nicer version of EnsureProcessTerminated() that is patient and will diff --git a/base/process/kill_mac.cc b/base/process/kill_mac.cc index 9257ee6..a2632f6 100644 --- a/base/process/kill_mac.cc +++ b/base/process/kill_mac.cc @@ -165,8 +165,8 @@ void WaitForChildToDie(pid_t child, int timeout) { } // namespace -void EnsureProcessTerminated(ProcessHandle process) { - WaitForChildToDie(process, kWaitBeforeKillSeconds); +void EnsureProcessTerminated(Process process) { + WaitForChildToDie(process.pid(), kWaitBeforeKillSeconds); } } // namespace base diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc index d17e990..3f304ca 100644 --- a/base/process/kill_posix.cc +++ b/base/process/kill_posix.cc @@ -463,13 +463,13 @@ class BackgroundReaper : public PlatformThread::Delegate { } // namespace -void EnsureProcessTerminated(ProcessHandle process) { +void EnsureProcessTerminated(Process process) { // If the child is already dead, then there's nothing to do. - if (IsChildDead(process)) + if (IsChildDead(process.pid())) return; const unsigned timeout = 2; // seconds - BackgroundReaper* reaper = new BackgroundReaper(process, timeout); + BackgroundReaper* reaper = new BackgroundReaper(process.pid(), timeout); PlatformThread::CreateNonJoinable(0, reaper); } diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc index b102a87..0a0c99c 100644 --- a/base/process/kill_win.cc +++ b/base/process/kill_win.cc @@ -38,7 +38,7 @@ static const int kWaitInterval = 2000; class TimerExpiredTask : public win::ObjectWatcher::Delegate { public: - explicit TimerExpiredTask(ProcessHandle process); + explicit TimerExpiredTask(Process process); ~TimerExpiredTask(); void TimedOut(); @@ -50,24 +50,23 @@ class TimerExpiredTask : public win::ObjectWatcher::Delegate { void KillProcess(); // The process that we are watching. - ProcessHandle process_; + Process process_; win::ObjectWatcher watcher_; DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask); }; -TimerExpiredTask::TimerExpiredTask(ProcessHandle process) : process_(process) { - watcher_.StartWatching(process_, this); +TimerExpiredTask::TimerExpiredTask(Process process) : process_(process.Pass()) { + watcher_.StartWatching(process_.Handle(), this); } TimerExpiredTask::~TimerExpiredTask() { TimedOut(); - DCHECK(!process_) << "Make sure to close the handle."; } void TimerExpiredTask::TimedOut() { - if (process_) + if (process_.IsValid()) KillProcess(); } @@ -76,8 +75,7 @@ void TimerExpiredTask::OnObjectSignaled(HANDLE object) { tracked_objects::ScopedTracker tracking_profile( FROM_HERE_WITH_EXPLICIT_FUNCTION("TimerExpiredTask_OnObjectSignaled")); - CloseHandle(process_); - process_ = NULL; + process_.Close(); } void TimerExpiredTask::KillProcess() { @@ -88,10 +86,10 @@ void TimerExpiredTask::KillProcess() { // terminates. We just care that it eventually terminates, and that's what // TerminateProcess should do for us. Don't check for the result code since // it fails quite often. This should be investigated eventually. - base::KillProcess(process_, kProcessKilledExitCode, false); + base::KillProcess(process_.Handle(), kProcessKilledExitCode, false); // Now, just cleanup as if the process exited normally. - OnObjectSignaled(process_); + OnObjectSignaled(process_.Handle()); } } // namespace @@ -241,19 +239,18 @@ bool CleanupProcesses(const FilePath::StringType& executable_name, return false; } -void EnsureProcessTerminated(ProcessHandle process) { - DCHECK(process != GetCurrentProcess()); +void EnsureProcessTerminated(Process process) { + DCHECK(!process.is_current()); // If already signaled, then we are done! - if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { - CloseHandle(process); + if (WaitForSingleObject(process.Handle(), 0) == WAIT_OBJECT_0) { return; } MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&TimerExpiredTask::TimedOut, - base::Owned(new TimerExpiredTask(process))), + base::Owned(new TimerExpiredTask(process.Pass()))), base::TimeDelta::FromMilliseconds(kWaitInterval)); } diff --git a/base/process/launch.h b/base/process/launch.h index 06abb29..0450ddf 100644 --- a/base/process/launch.h +++ b/base/process/launch.h @@ -22,7 +22,6 @@ #include "base/posix/file_descriptor_shuffle.h" #elif defined(OS_WIN) #include <windows.h> -#include "base/win/scoped_handle.h" #endif namespace base { @@ -174,9 +173,8 @@ BASE_EXPORT bool LaunchProcess(const CommandLine& cmdline, // // Example (including literal quotes) // cmdline = "c:\windows\explorer.exe" -foo "c:\bar\" -BASE_EXPORT bool LaunchProcess(const string16& cmdline, - const LaunchOptions& options, - win::ScopedHandle* process_handle); +BASE_EXPORT Process LaunchProcess(const string16& cmdline, + const LaunchOptions& options); // Launches a process with elevated privileges. This does not behave exactly // like LaunchProcess as it uses ShellExecuteEx instead of CreateProcess to diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc index 3c787fe..1d83ef9 100644 --- a/base/process/launch_win.cc +++ b/base/process/launch_win.cc @@ -232,6 +232,17 @@ bool LaunchProcess(const string16& cmdline, return true; } +// TODO(rvargas) crbug.com/416721: Remove this stub after LaunchProcess is +// fully migrated to use Process. +Process LaunchProcess(const string16& cmdline, + const LaunchOptions& options) { + win::ScopedHandle process_handle; + if (LaunchProcess(cmdline, options, &process_handle)) + return Process(process_handle.Take()); + + return Process(); +} + bool LaunchProcess(const CommandLine& cmdline, const LaunchOptions& options, ProcessHandle* process_handle) { diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc index c98884d..af88fe1 100644 --- a/base/process/process_util_unittest.cc +++ b/base/process/process_util_unittest.cc @@ -888,14 +888,14 @@ bool IsProcessDead(base::ProcessHandle child) { } TEST_F(ProcessUtilTest, DelayedTermination) { - base::ProcessHandle child_process = SpawnChild("process_util_test_never_die"); - ASSERT_TRUE(child_process); - base::EnsureProcessTerminated(child_process); - base::WaitForSingleProcess(child_process, base::TimeDelta::FromSeconds(5)); + base::Process child_process(SpawnChild("process_util_test_never_die")); + ASSERT_TRUE(child_process.IsValid()); + base::EnsureProcessTerminated(child_process.Duplicate()); + base::WaitForSingleProcess(child_process.Handle(), + base::TimeDelta::FromSeconds(5)); // Check that process was really killed. - EXPECT_TRUE(IsProcessDead(child_process)); - base::CloseProcessHandle(child_process); + EXPECT_TRUE(IsProcessDead(child_process.Handle())); } MULTIPROCESS_TEST_MAIN(process_util_test_never_die) { @@ -906,16 +906,14 @@ MULTIPROCESS_TEST_MAIN(process_util_test_never_die) { } TEST_F(ProcessUtilTest, ImmediateTermination) { - base::ProcessHandle child_process = - SpawnChild("process_util_test_die_immediately"); - ASSERT_TRUE(child_process); + base::Process child_process(SpawnChild("process_util_test_die_immediately")); + ASSERT_TRUE(child_process.IsValid()); // Give it time to die. sleep(2); - base::EnsureProcessTerminated(child_process); + base::EnsureProcessTerminated(child_process.Duplicate()); // Check that process was really killed. - EXPECT_TRUE(IsProcessDead(child_process)); - base::CloseProcessHandle(child_process); + EXPECT_TRUE(IsProcessDead(child_process.Handle())); } MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc index 98976a1..c28b233 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc @@ -47,7 +47,6 @@ NativeMessageProcessHost::NativeMessageProcessHost( native_host_name_(native_host_name), launcher_(launcher.Pass()), closed_(false), - process_handle_(base::kNullProcessHandle), #if defined(OS_POSIX) read_file_(-1), #endif @@ -103,7 +102,7 @@ void NativeMessageProcessHost::LaunchHostProcess() { void NativeMessageProcessHost::OnHostProcessLaunched( NativeProcessLauncher::LaunchResult result, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file) { DCHECK(task_runner_->BelongsToCurrentThread()); @@ -125,7 +124,7 @@ void NativeMessageProcessHost::OnHostProcessLaunched( break; } - process_handle_ = process_handle; + process_ = process.Pass(); #if defined(OS_POSIX) // This object is not the owner of the file so it should not keep an fd. read_file_ = read_file.GetPlatformFile(); @@ -349,17 +348,17 @@ void NativeMessageProcessHost::Close(const std::string& error_message) { client_->CloseChannel(error_message); } - if (process_handle_ != base::kNullProcessHandle) { + if (process_.IsValid()) { // Kill the host process if necessary to make sure we don't leave zombies. // On OSX base::EnsureProcessTerminated() may block, so we have to post a // task on the blocking pool. #if defined(OS_MACOSX) content::BrowserThread::PostBlockingPoolTask( - FROM_HERE, base::Bind(&base::EnsureProcessTerminated, process_handle_)); + FROM_HERE, + base::Bind(&base::EnsureProcessTerminated, Passed(&process_))); #else - base::EnsureProcessTerminated(process_handle_); + base::EnsureProcessTerminated(process_.Pass()); #endif - process_handle_ = base::kNullProcessHandle; } } diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.h b/chrome/browser/extensions/api/messaging/native_message_process_host.h index cb8c42f..67ef800 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host.h +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.h @@ -72,7 +72,7 @@ class NativeMessageProcessHost : // Callback for NativeProcessLauncher::Launch(). void OnHostProcessLaunched(NativeProcessLauncher::LaunchResult result, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file); @@ -108,7 +108,7 @@ class NativeMessageProcessHost : // due to an error. bool closed_; - base::ProcessHandle process_handle_; + base::Process process_; // Input stream reader. scoped_ptr<net::FileStream> read_stream_; diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc index 68e5c92..55afb31 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc @@ -82,8 +82,7 @@ class FakeLauncher : public NativeProcessLauncher { const std::string& native_host_name, LaunchedCallback callback) const override { callback.Run(NativeProcessLauncher::RESULT_SUCCESS, - base::kNullProcessHandle, - read_file_.Pass(), write_file_.Pass()); + base::Process(), read_file_.Pass(), write_file_.Pass()); } private: diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher.cc b/chrome/browser/extensions/api/messaging/native_process_launcher.cc index 484b387..14c01fb 100644 --- a/chrome/browser/extensions/api/messaging/native_process_launcher.cc +++ b/chrome/browser/extensions/api/messaging/native_process_launcher.cc @@ -62,12 +62,12 @@ class NativeProcessLauncherImpl : public NativeProcessLauncher { LaunchedCallback callback); void PostErrorResult(const LaunchedCallback& callback, LaunchResult error); void PostResult(const LaunchedCallback& callback, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file); void CallCallbackOnIOThread(LaunchedCallback callback, LaunchResult result, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file); @@ -192,12 +192,12 @@ void NativeProcessLauncherImpl::Core::DoLaunchOnThreadPool( base::Int64ToString(window_handle_)); #endif // !defined(OS_WIN) - base::ProcessHandle process_handle; + base::Process process; base::File read_file; base::File write_file; if (NativeProcessLauncher::LaunchNativeProcess( - command_line, &process_handle, &read_file, &write_file)) { - PostResult(callback, process_handle, read_file.Pass(), write_file.Pass()); + command_line, &process, &read_file, &write_file)) { + PostResult(callback, process.Pass(), read_file.Pass(), write_file.Pass()); } else { PostErrorResult(callback, RESULT_FAILED_TO_START); } @@ -206,14 +206,14 @@ void NativeProcessLauncherImpl::Core::DoLaunchOnThreadPool( void NativeProcessLauncherImpl::Core::CallCallbackOnIOThread( LaunchedCallback callback, LaunchResult result, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (detached_) return; - callback.Run(result, process_handle, read_file.Pass(), write_file.Pass()); + callback.Run(result, process.Pass(), read_file.Pass(), write_file.Pass()); } void NativeProcessLauncherImpl::Core::PostErrorResult( @@ -222,20 +222,20 @@ void NativeProcessLauncherImpl::Core::PostErrorResult( content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, base::Bind(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread, this, - callback, error, base::kNullProcessHandle, + callback, error, Passed(base::Process()), Passed(base::File()), Passed(base::File()))); } void NativeProcessLauncherImpl::Core::PostResult( const LaunchedCallback& callback, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file) { content::BrowserThread::PostTask( content::BrowserThread::IO, FROM_HERE, base::Bind(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread, this, - callback, RESULT_SUCCESS, process_handle, - Passed(read_file.Pass()), Passed(write_file.Pass()))); + callback, RESULT_SUCCESS, Passed(&process), + Passed(&read_file), Passed(&write_file))); } NativeProcessLauncherImpl::NativeProcessLauncherImpl( diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher.h b/chrome/browser/extensions/api/messaging/native_process_launcher.h index db41309..00172ea 100644 --- a/chrome/browser/extensions/api/messaging/native_process_launcher.h +++ b/chrome/browser/extensions/api/messaging/native_process_launcher.h @@ -34,7 +34,7 @@ class NativeProcessLauncher { // to false in case of a failure. Handler must take ownership of the IO // handles. typedef base::Callback<void(LaunchResult result, - base::ProcessHandle process_handle, + base::Process process, base::File read_file, base::File write_file)> LaunchedCallback; @@ -68,7 +68,7 @@ class NativeProcessLauncher { // Launches native messaging process. static bool LaunchNativeProcess(const base::CommandLine& command_line, - base::ProcessHandle* process_handle, + base::Process* process, base::File* read_file, base::File* write_file); diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc b/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc index aac9ce2..bd2b316 100644 --- a/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc +++ b/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc @@ -50,7 +50,7 @@ base::FilePath NativeProcessLauncher::FindManifest( // static bool NativeProcessLauncher::LaunchNativeProcess( const CommandLine& command_line, - base::ProcessHandle* process_handle, + base::Process* process, base::File* read_file, base::File* write_file) { base::FileHandleMappingVector fd_map; @@ -81,7 +81,8 @@ bool NativeProcessLauncher::LaunchNativeProcess( options.allow_new_privs = true; #endif - if (!base::LaunchProcess(command_line, options, process_handle)) { + base::ProcessHandle process_handle; + if (!base::LaunchProcess(command_line, options, &process_handle)) { LOG(ERROR) << "Error launching process"; return false; } @@ -90,6 +91,7 @@ bool NativeProcessLauncher::LaunchNativeProcess( write_pipe_read_fd.reset(); read_pipe_write_fd.reset(); + *process = base::Process(process_handle); *read_file = base::File(read_pipe_read_fd.release()); *write_file = base::File(write_pipe_write_fd.release()); diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc b/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc index 59b1b39..d0ae6ed 100644 --- a/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc +++ b/chrome/browser/extensions/api/messaging/native_process_launcher_win.cc @@ -89,7 +89,7 @@ base::FilePath NativeProcessLauncher::FindManifest( // static bool NativeProcessLauncher::LaunchNativeProcess( const CommandLine& command_line, - base::ProcessHandle* process_handle, + base::Process* process, base::File* read_file, base::File* write_file) { // Timeout for the IO pipes. @@ -151,8 +151,8 @@ bool NativeProcessLauncher::LaunchNativeProcess( base::LaunchOptions options; options.start_hidden = true; - base::win::ScopedHandle cmd_handle; - if (!base::LaunchProcess(command.c_str(), options, &cmd_handle)) { + base::Process cmd_process = base::LaunchProcess(command.c_str(), options); + if (!cmd_process.IsValid()) { LOG(ERROR) << "Error launching process " << command_line.GetProgram().MaybeAsASCII(); return false; @@ -163,13 +163,13 @@ bool NativeProcessLauncher::LaunchNativeProcess( bool stdin_connected = ConnectNamedPipe(stdin_pipe.Get(), NULL) ? TRUE : GetLastError() == ERROR_PIPE_CONNECTED; if (!stdout_connected || !stdin_connected) { - base::KillProcess(cmd_handle.Get(), 0, false); + base::KillProcess(cmd_process.Handle(), 0, false); LOG(ERROR) << "Failed to connect IO pipes when starting " << command_line.GetProgram().MaybeAsASCII(); return false; } - *process_handle = cmd_handle.Take(); + *process = cmd_process.Pass(); *read_file = base::File(stdout_pipe.Take()); *write_file = base::File(stdin_pipe.Take()); diff --git a/chrome/browser/first_run/upgrade_util_win.cc b/chrome/browser/first_run/upgrade_util_win.cc index ff19c04..1a489a8 100644 --- a/chrome/browser/first_run/upgrade_util_win.cc +++ b/chrome/browser/first_run/upgrade_util_win.cc @@ -258,13 +258,13 @@ bool SwapNewChromeExeIfPresent() { std::wstring rename_cmd; if (key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd) == ERROR_SUCCESS) { - base::win::ScopedHandle handle; base::LaunchOptions options; options.wait = true; options.start_hidden = true; - if (base::LaunchProcess(rename_cmd, options, &handle)) { + base::Process process = base::LaunchProcess(rename_cmd, options); + if (process.IsValid()) { DWORD exit_code; - ::GetExitCodeProcess(handle.Get(), &exit_code); + ::GetExitCodeProcess(process.Handle(), &exit_code); if (exit_code == installer::RENAME_SUCCESSFUL) return true; } diff --git a/chrome/browser/ui/views/uninstall_view.cc b/chrome/browser/ui/views/uninstall_view.cc index 0ce1b03..b8f4b84 100644 --- a/chrome/browser/ui/views/uninstall_view.cc +++ b/chrome/browser/ui/views/uninstall_view.cc @@ -118,7 +118,7 @@ bool UninstallView::Accept() { std::advance(i, browsers_combo_->selected_index()); base::LaunchOptions options; options.start_hidden = true; - base::LaunchProcess(i->second, options, NULL); + base::LaunchProcess(i->second, options); } return true; } diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc index ce03d85..f08d90f 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -519,8 +519,7 @@ BOOL __stdcall LaunchGoogleChrome() { // Couldn't get Omaha's process launcher, Omaha may not be installed at // system level. Try just running Chrome instead. ret = base::LaunchProcess(chrome_command.GetCommandLineString(), - base::LaunchOptions(), - NULL); + base::LaunchOptions()).IsValid(); } if (impersonation_success) diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc index 0d505c8..fd66c01 100644 --- a/chrome/installer/test/alternate_version_generator.cc +++ b/chrome/installer/test/alternate_version_generator.cc @@ -214,13 +214,13 @@ bool MappedFile::Initialize(base::File file) { bool RunProcessAndWait(const wchar_t* exe_path, const std::wstring& cmdline, int* exit_code) { bool result = true; - base::win::ScopedHandle process; base::LaunchOptions options; options.wait = true; options.start_hidden = true; - if (base::LaunchProcess(cmdline, options, &process)) { + base::Process process = base::LaunchProcess(cmdline, options); + if (process.IsValid()) { if (exit_code) { - if (!GetExitCodeProcess(process.Get(), + if (!GetExitCodeProcess(process.Handle(), reinterpret_cast<DWORD*>(exit_code))) { PLOG(DFATAL) << "Failed getting the exit code for \"" << cmdline << "\"."; diff --git a/chrome/installer/util/google_update_util.cc b/chrome/installer/util/google_update_util.cc index 68e4675..db07f84 100644 --- a/chrome/installer/util/google_update_util.cc +++ b/chrome/installer/util/google_update_util.cc @@ -89,13 +89,13 @@ bool GetUserLevelGoogleUpdateInstallCommandLine(base::string16* cmd_string) { bool LaunchProcessAndWaitWithTimeout(const base::string16& cmd_string, base::TimeDelta timeout) { bool success = false; - base::win::ScopedHandle process; int exit_code = 0; VLOG(0) << "Launching: " << cmd_string; - if (!base::LaunchProcess(cmd_string, base::LaunchOptions(), - &process)) { + base::Process process = + base::LaunchProcess(cmd_string, base::LaunchOptions()); + if (!process.IsValid()) { PLOG(ERROR) << "Failed to launch (" << cmd_string << ")"; - } else if (!base::WaitForExitCodeWithTimeout(process.Get(), &exit_code, + } else if (!base::WaitForExitCodeWithTimeout(process.Handle(), &exit_code, timeout)) { // The GetExitCodeProcess failed or timed-out. LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than " diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index ae96bed..22905ef 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -156,7 +156,9 @@ void InstallUtil::TriggerActiveSetupCommand() { base::LaunchOptions launch_options; if (base::win::IsMetroProcess()) launch_options.force_breakaway_from_job_ = true; - if (!base::LaunchProcess(cmd.GetCommandLineString(), launch_options, NULL)) + base::Process process = + base::LaunchProcess(cmd.GetCommandLineString(), launch_options); + if (!process.IsValid()) PLOG(ERROR) << cmd.GetCommandLineString(); } diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc index 6597758..ad51a8e 100644 --- a/cloud_print/virtual_driver/win/install/setup.cc +++ b/cloud_print/virtual_driver/win/install/setup.cc @@ -138,16 +138,16 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) { base::LaunchOptions options; options.wait = true; - base::win::ScopedHandle regsvr32_handle; - if (!base::LaunchProcess(command_line.GetCommandLineString(), options, - ®svr32_handle)) { + base::Process regsvr32_process = + base::LaunchProcess(command_line.GetCommandLineString(), options); + if (!regsvr32_process.IsValid()) { LOG(ERROR) << "Unable to launch regsvr32.exe."; return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); } DWORD exit_code = S_OK; if (install) { - if (!GetExitCodeProcess(regsvr32_handle.Get(), &exit_code)) { + if (!GetExitCodeProcess(regsvr32_process.Handle(), &exit_code)) { LOG(ERROR) << "Unable to get regsvr32.exe exit code."; return GetLastHResult(); } diff --git a/components/storage_monitor/storage_monitor_linux.cc b/components/storage_monitor/storage_monitor_linux.cc index 9d0b75a..991585b 100644 --- a/components/storage_monitor/storage_monitor_linux.cc +++ b/components/storage_monitor/storage_monitor_linux.cc @@ -222,7 +222,7 @@ StorageMonitor::EjectStatus EjectPathOnFileThread( if (!base::WaitForExitCodeWithTimeout(handle, &exit_code, base::TimeDelta::FromMilliseconds(3000))) { base::KillProcess(handle, -1, false); - base::EnsureProcessTerminated(handle); + base::EnsureProcessTerminated(base::Process(handle)); return StorageMonitor::EJECT_FAILURE; } diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 0870e6c..636fd88 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -531,7 +531,7 @@ void ChildProcessLauncher::Context::TerminateInternal( ZygoteHostImpl::GetInstance()->EnsureProcessTerminated(process.Handle()); } else #endif // !OS_MACOSX - base::EnsureProcessTerminated(process.Handle()); + base::EnsureProcessTerminated(process.Pass()); #endif // OS_POSIX #endif // defined(OS_ANDROID) } diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc index f0b9161..bd64221 100644 --- a/content/zygote/zygote_linux.cc +++ b/content/zygote/zygote_linux.cc @@ -248,7 +248,7 @@ void Zygote::HandleReapRequest(int fd, // with this for now. #if !defined(THREAD_SANITIZER) // TODO(jln): this old code is completely broken. See crbug.com/274855. - base::EnsureProcessTerminated(child_info.internal_pid); + base::EnsureProcessTerminated(base::Process(child_info.internal_pid)); #else LOG(WARNING) << "Zygote process omitting a call to " << "base::EnsureProcessTerminated() for child pid " << child diff --git a/remoting/host/setup/daemon_installer_win.cc b/remoting/host/setup/daemon_installer_win.cc index 39f2986..2968ce1 100644 --- a/remoting/host/setup/daemon_installer_win.cc +++ b/remoting/host/setup/daemon_installer_win.cc @@ -102,7 +102,7 @@ class DaemonCommandLineInstallerWin private: // Handle of the launched process. - base::win::ScopedHandle process_; + base::Process process_; // Used to determine when the launched process terminates. base::win::ObjectWatcher process_watcher_; @@ -300,13 +300,14 @@ void DaemonCommandLineInstallerWin::Install() { kOmahaLanguage)); base::LaunchOptions options; - if (!base::LaunchProcess(command_line, options, &process_)) { + process_ = base::LaunchProcess(command_line, options); + if (!process_.IsValid()) { result = GetLastError(); Done(HRESULT_FROM_WIN32(result)); return; } - if (!process_watcher_.StartWatching(process_.Get(), this)) { + if (!process_watcher_.StartWatching(process_.Handle(), this)) { result = GetLastError(); Done(HRESULT_FROM_WIN32(result)); return; @@ -316,7 +317,7 @@ void DaemonCommandLineInstallerWin::Install() { void DaemonCommandLineInstallerWin::OnObjectSignaled(HANDLE object) { // Check if the updater process returned success. DWORD exit_code; - if (GetExitCodeProcess(process_.Get(), &exit_code) && exit_code == 0) { + if (GetExitCodeProcess(process_.Handle(), &exit_code) && exit_code == 0) { Done(S_OK); } else { Done(E_FAIL); diff --git a/win8/test/metro_registration_helper.cc b/win8/test/metro_registration_helper.cc index c5d6735..59b2235 100644 --- a/win8/test/metro_registration_helper.cc +++ b/win8/test/metro_registration_helper.cc @@ -53,13 +53,13 @@ bool RegisterTestDefaultBrowser() { CommandLine register_command(registrar); register_command.AppendArg("/RegServer"); - base::win::ScopedHandle register_handle; - if (base::LaunchProcess(register_command.GetCommandLineString(), - base::LaunchOptions(), - ®ister_handle)) { + base::Process register_process = + base::LaunchProcess(register_command.GetCommandLineString(), + base::LaunchOptions()); + if (register_process.IsValid()) { int ret = 0; if (base::WaitForExitCodeWithTimeout( - register_handle.Get(), &ret, + register_process.Handle(), &ret, base::TimeDelta::FromSeconds(kRegistrationTimeoutSeconds))) { if (ret == 0) { return true; |