diff options
26 files changed, 100 insertions, 107 deletions
diff --git a/base/process/kill.h b/base/process/kill.h index f697701..de72d7a 100644 --- a/base/process/kill.h +++ b/base/process/kill.h @@ -9,7 +9,6 @@ #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" @@ -147,10 +146,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 must have been opened with the PROCESS_TERMINATE and -// SYNCHRONIZE permissions. +// NOTE: The process handle must have been opened with the PROCESS_TERMINATE +// and SYNCHRONIZE permissions. // -BASE_EXPORT void EnsureProcessTerminated(Process process); +BASE_EXPORT void EnsureProcessTerminated(ProcessHandle process_handle); #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 a2632f6..9257ee6 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(Process process) { - WaitForChildToDie(process.pid(), kWaitBeforeKillSeconds); +void EnsureProcessTerminated(ProcessHandle process) { + WaitForChildToDie(process, kWaitBeforeKillSeconds); } } // namespace base diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc index 3f304ca..d17e990 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(Process process) { +void EnsureProcessTerminated(ProcessHandle process) { // If the child is already dead, then there's nothing to do. - if (IsChildDead(process.pid())) + if (IsChildDead(process)) return; const unsigned timeout = 2; // seconds - BackgroundReaper* reaper = new BackgroundReaper(process.pid(), timeout); + BackgroundReaper* reaper = new BackgroundReaper(process, timeout); PlatformThread::CreateNonJoinable(0, reaper); } diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc index 0a0c99c..b102a87 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(Process process); + explicit TimerExpiredTask(ProcessHandle process); ~TimerExpiredTask(); void TimedOut(); @@ -50,23 +50,24 @@ class TimerExpiredTask : public win::ObjectWatcher::Delegate { void KillProcess(); // The process that we are watching. - Process process_; + ProcessHandle process_; win::ObjectWatcher watcher_; DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask); }; -TimerExpiredTask::TimerExpiredTask(Process process) : process_(process.Pass()) { - watcher_.StartWatching(process_.Handle(), this); +TimerExpiredTask::TimerExpiredTask(ProcessHandle process) : process_(process) { + watcher_.StartWatching(process_, this); } TimerExpiredTask::~TimerExpiredTask() { TimedOut(); + DCHECK(!process_) << "Make sure to close the handle."; } void TimerExpiredTask::TimedOut() { - if (process_.IsValid()) + if (process_) KillProcess(); } @@ -75,7 +76,8 @@ void TimerExpiredTask::OnObjectSignaled(HANDLE object) { tracked_objects::ScopedTracker tracking_profile( FROM_HERE_WITH_EXPLICIT_FUNCTION("TimerExpiredTask_OnObjectSignaled")); - process_.Close(); + CloseHandle(process_); + process_ = NULL; } void TimerExpiredTask::KillProcess() { @@ -86,10 +88,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_.Handle(), kProcessKilledExitCode, false); + base::KillProcess(process_, kProcessKilledExitCode, false); // Now, just cleanup as if the process exited normally. - OnObjectSignaled(process_.Handle()); + OnObjectSignaled(process_); } } // namespace @@ -239,18 +241,19 @@ bool CleanupProcesses(const FilePath::StringType& executable_name, return false; } -void EnsureProcessTerminated(Process process) { - DCHECK(!process.is_current()); +void EnsureProcessTerminated(ProcessHandle process) { + DCHECK(process != GetCurrentProcess()); // If already signaled, then we are done! - if (WaitForSingleObject(process.Handle(), 0) == WAIT_OBJECT_0) { + if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { + CloseHandle(process); return; } MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&TimerExpiredTask::TimedOut, - base::Owned(new TimerExpiredTask(process.Pass()))), + base::Owned(new TimerExpiredTask(process))), base::TimeDelta::FromMilliseconds(kWaitInterval)); } diff --git a/base/process/launch.h b/base/process/launch.h index 0450ddf..06abb29 100644 --- a/base/process/launch.h +++ b/base/process/launch.h @@ -22,6 +22,7 @@ #include "base/posix/file_descriptor_shuffle.h" #elif defined(OS_WIN) #include <windows.h> +#include "base/win/scoped_handle.h" #endif namespace base { @@ -173,8 +174,9 @@ BASE_EXPORT bool LaunchProcess(const CommandLine& cmdline, // // Example (including literal quotes) // cmdline = "c:\windows\explorer.exe" -foo "c:\bar\" -BASE_EXPORT Process LaunchProcess(const string16& cmdline, - const LaunchOptions& options); +BASE_EXPORT bool LaunchProcess(const string16& cmdline, + const LaunchOptions& options, + win::ScopedHandle* process_handle); // 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 1d83ef9..3c787fe 100644 --- a/base/process/launch_win.cc +++ b/base/process/launch_win.cc @@ -232,17 +232,6 @@ 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 af88fe1..c98884d 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::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)); + 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)); // Check that process was really killed. - EXPECT_TRUE(IsProcessDead(child_process.Handle())); + EXPECT_TRUE(IsProcessDead(child_process)); + base::CloseProcessHandle(child_process); } MULTIPROCESS_TEST_MAIN(process_util_test_never_die) { @@ -906,14 +906,16 @@ MULTIPROCESS_TEST_MAIN(process_util_test_never_die) { } TEST_F(ProcessUtilTest, ImmediateTermination) { - base::Process child_process(SpawnChild("process_util_test_die_immediately")); - ASSERT_TRUE(child_process.IsValid()); + base::ProcessHandle child_process = + SpawnChild("process_util_test_die_immediately"); + ASSERT_TRUE(child_process); // Give it time to die. sleep(2); - base::EnsureProcessTerminated(child_process.Duplicate()); + base::EnsureProcessTerminated(child_process); // Check that process was really killed. - EXPECT_TRUE(IsProcessDead(child_process.Handle())); + EXPECT_TRUE(IsProcessDead(child_process)); + base::CloseProcessHandle(child_process); } 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 c28b233..98976a1 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc @@ -47,6 +47,7 @@ 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 @@ -102,7 +103,7 @@ void NativeMessageProcessHost::LaunchHostProcess() { void NativeMessageProcessHost::OnHostProcessLaunched( NativeProcessLauncher::LaunchResult result, - base::Process process, + base::ProcessHandle process_handle, base::File read_file, base::File write_file) { DCHECK(task_runner_->BelongsToCurrentThread()); @@ -124,7 +125,7 @@ void NativeMessageProcessHost::OnHostProcessLaunched( break; } - process_ = process.Pass(); + process_handle_ = process_handle; #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(); @@ -348,17 +349,17 @@ void NativeMessageProcessHost::Close(const std::string& error_message) { client_->CloseChannel(error_message); } - if (process_.IsValid()) { + if (process_handle_ != base::kNullProcessHandle) { // 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, Passed(&process_))); + FROM_HERE, base::Bind(&base::EnsureProcessTerminated, process_handle_)); #else - base::EnsureProcessTerminated(process_.Pass()); + base::EnsureProcessTerminated(process_handle_); #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 67ef800..cb8c42f 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::Process process, + base::ProcessHandle process_handle, base::File read_file, base::File write_file); @@ -108,7 +108,7 @@ class NativeMessageProcessHost : // due to an error. bool closed_; - base::Process process_; + base::ProcessHandle process_handle_; // 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 55afb31..68e5c92 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,7 +82,8 @@ class FakeLauncher : public NativeProcessLauncher { const std::string& native_host_name, LaunchedCallback callback) const override { callback.Run(NativeProcessLauncher::RESULT_SUCCESS, - base::Process(), read_file_.Pass(), write_file_.Pass()); + base::kNullProcessHandle, + 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 14c01fb..484b387 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::Process process, + base::ProcessHandle process_handle, base::File read_file, base::File write_file); void CallCallbackOnIOThread(LaunchedCallback callback, LaunchResult result, - base::Process process, + base::ProcessHandle process_handle, 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::Process process; + base::ProcessHandle process_handle; base::File read_file; base::File write_file; if (NativeProcessLauncher::LaunchNativeProcess( - command_line, &process, &read_file, &write_file)) { - PostResult(callback, process.Pass(), read_file.Pass(), write_file.Pass()); + command_line, &process_handle, &read_file, &write_file)) { + PostResult(callback, process_handle, 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::Process process, + base::ProcessHandle process_handle, base::File read_file, base::File write_file) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (detached_) return; - callback.Run(result, process.Pass(), read_file.Pass(), write_file.Pass()); + callback.Run(result, process_handle, 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, Passed(base::Process()), + callback, error, base::kNullProcessHandle, Passed(base::File()), Passed(base::File()))); } void NativeProcessLauncherImpl::Core::PostResult( const LaunchedCallback& callback, - base::Process process, + base::ProcessHandle process_handle, 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, Passed(&process), - Passed(&read_file), Passed(&write_file))); + callback, RESULT_SUCCESS, process_handle, + Passed(read_file.Pass()), Passed(write_file.Pass()))); } 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 00172ea..db41309 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::Process process, + base::ProcessHandle process_handle, 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::Process* process, + base::ProcessHandle* process_handle, 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 bd2b316..aac9ce2 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::Process* process, + base::ProcessHandle* process_handle, base::File* read_file, base::File* write_file) { base::FileHandleMappingVector fd_map; @@ -81,8 +81,7 @@ bool NativeProcessLauncher::LaunchNativeProcess( options.allow_new_privs = true; #endif - base::ProcessHandle process_handle; - if (!base::LaunchProcess(command_line, options, &process_handle)) { + if (!base::LaunchProcess(command_line, options, process_handle)) { LOG(ERROR) << "Error launching process"; return false; } @@ -91,7 +90,6 @@ 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 d0ae6ed..59b1b39 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::Process* process, + base::ProcessHandle* process_handle, 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::Process cmd_process = base::LaunchProcess(command.c_str(), options); - if (!cmd_process.IsValid()) { + base::win::ScopedHandle cmd_handle; + if (!base::LaunchProcess(command.c_str(), options, &cmd_handle)) { 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_process.Handle(), 0, false); + base::KillProcess(cmd_handle.Get(), 0, false); LOG(ERROR) << "Failed to connect IO pipes when starting " << command_line.GetProgram().MaybeAsASCII(); return false; } - *process = cmd_process.Pass(); + *process_handle = cmd_handle.Take(); *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 1a489a8..ff19c04 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; - base::Process process = base::LaunchProcess(rename_cmd, options); - if (process.IsValid()) { + if (base::LaunchProcess(rename_cmd, options, &handle)) { DWORD exit_code; - ::GetExitCodeProcess(process.Handle(), &exit_code); + ::GetExitCodeProcess(handle.Get(), &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 b8f4b84..0ce1b03 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); + base::LaunchProcess(i->second, options, NULL); } return true; } diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc index f08d90f..ce03d85 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -519,7 +519,8 @@ 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()).IsValid(); + base::LaunchOptions(), + NULL); } if (impersonation_success) diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc index fd66c01..0d505c8 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; - base::Process process = base::LaunchProcess(cmdline, options); - if (process.IsValid()) { + if (base::LaunchProcess(cmdline, options, &process)) { if (exit_code) { - if (!GetExitCodeProcess(process.Handle(), + if (!GetExitCodeProcess(process.Get(), 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 db07f84..68e4675 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; - base::Process process = - base::LaunchProcess(cmd_string, base::LaunchOptions()); - if (!process.IsValid()) { + if (!base::LaunchProcess(cmd_string, base::LaunchOptions(), + &process)) { PLOG(ERROR) << "Failed to launch (" << cmd_string << ")"; - } else if (!base::WaitForExitCodeWithTimeout(process.Handle(), &exit_code, + } else if (!base::WaitForExitCodeWithTimeout(process.Get(), &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 22905ef..ae96bed 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -156,9 +156,7 @@ void InstallUtil::TriggerActiveSetupCommand() { base::LaunchOptions launch_options; if (base::win::IsMetroProcess()) launch_options.force_breakaway_from_job_ = true; - base::Process process = - base::LaunchProcess(cmd.GetCommandLineString(), launch_options); - if (!process.IsValid()) + if (!base::LaunchProcess(cmd.GetCommandLineString(), launch_options, NULL)) 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 ad51a8e..6597758 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::Process regsvr32_process = - base::LaunchProcess(command_line.GetCommandLineString(), options); - if (!regsvr32_process.IsValid()) { + base::win::ScopedHandle regsvr32_handle; + if (!base::LaunchProcess(command_line.GetCommandLineString(), options, + ®svr32_handle)) { LOG(ERROR) << "Unable to launch regsvr32.exe."; return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); } DWORD exit_code = S_OK; if (install) { - if (!GetExitCodeProcess(regsvr32_process.Handle(), &exit_code)) { + if (!GetExitCodeProcess(regsvr32_handle.Get(), &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 991585b..9d0b75a 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(base::Process(handle)); + base::EnsureProcessTerminated(handle); return StorageMonitor::EJECT_FAILURE; } diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 636fd88..0870e6c 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.Pass()); + base::EnsureProcessTerminated(process.Handle()); #endif // OS_POSIX #endif // defined(OS_ANDROID) } diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc index bd64221..f0b9161 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(base::Process(child_info.internal_pid)); + base::EnsureProcessTerminated(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 2968ce1..39f2986 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::Process process_; + base::win::ScopedHandle process_; // Used to determine when the launched process terminates. base::win::ObjectWatcher process_watcher_; @@ -300,14 +300,13 @@ void DaemonCommandLineInstallerWin::Install() { kOmahaLanguage)); base::LaunchOptions options; - process_ = base::LaunchProcess(command_line, options); - if (!process_.IsValid()) { + if (!base::LaunchProcess(command_line, options, &process_)) { result = GetLastError(); Done(HRESULT_FROM_WIN32(result)); return; } - if (!process_watcher_.StartWatching(process_.Handle(), this)) { + if (!process_watcher_.StartWatching(process_.Get(), this)) { result = GetLastError(); Done(HRESULT_FROM_WIN32(result)); return; @@ -317,7 +316,7 @@ void DaemonCommandLineInstallerWin::Install() { void DaemonCommandLineInstallerWin::OnObjectSignaled(HANDLE object) { // Check if the updater process returned success. DWORD exit_code; - if (GetExitCodeProcess(process_.Handle(), &exit_code) && exit_code == 0) { + if (GetExitCodeProcess(process_.Get(), &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 59b2235..c5d6735 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::Process register_process = - base::LaunchProcess(register_command.GetCommandLineString(), - base::LaunchOptions()); - if (register_process.IsValid()) { + base::win::ScopedHandle register_handle; + if (base::LaunchProcess(register_command.GetCommandLineString(), + base::LaunchOptions(), + ®ister_handle)) { int ret = 0; if (base::WaitForExitCodeWithTimeout( - register_process.Handle(), &ret, + register_handle.Get(), &ret, base::TimeDelta::FromSeconds(kRegistrationTimeoutSeconds))) { if (ret == 0) { return true; |