diff options
author | rvargas <rvargas@chromium.org> | 2015-03-04 14:38:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-04 22:39:24 +0000 |
commit | 4683e5ee356b1ba60813306ff6cb12de80060143 (patch) | |
tree | 93af5589876974f4ad540de19a47fc9f47e78f26 | |
parent | 40b0d46d7c7660cb8cb8bfc68df1b233f0811cd3 (diff) | |
download | chromium_src-4683e5ee356b1ba60813306ff6cb12de80060143.zip chromium_src-4683e5ee356b1ba60813306ff6cb12de80060143.tar.gz chromium_src-4683e5ee356b1ba60813306ff6cb12de80060143.tar.bz2 |
Remove base::KillProcessById
BUG=417532
Review URL: https://codereview.chromium.org/970943003
Cr-Commit-Position: refs/heads/master@{#319143}
-rw-r--r-- | base/process/kill.cc | 7 | ||||
-rw-r--r-- | base/process/kill.h | 6 | ||||
-rw-r--r-- | base/process/kill_win.cc | 16 | ||||
-rw-r--r-- | chrome/browser/process_singleton_win.cc | 4 | ||||
-rw-r--r-- | net/tools/stress_cache/stress_cache.cc | 6 | ||||
-rw-r--r-- | win8/delegate_execute/delegate_execute.cc | 6 | ||||
-rw-r--r-- | win8/delegate_execute/delegate_execute_operation.cc | 8 | ||||
-rw-r--r-- | win8/delegate_execute/delegate_execute_operation.h | 5 |
8 files changed, 18 insertions, 40 deletions
diff --git a/base/process/kill.cc b/base/process/kill.cc index caca348..a647d96 100644 --- a/base/process/kill.cc +++ b/base/process/kill.cc @@ -14,11 +14,8 @@ bool KillProcesses(const FilePath::StringType& executable_name, bool result = true; NamedProcessIterator iter(executable_name, filter); while (const ProcessEntry* entry = iter.NextProcessEntry()) { -#if defined(OS_WIN) - result &= KillProcessById(entry->pid(), exit_code, true); -#else - result &= KillProcess(entry->pid(), exit_code, true); -#endif + Process process = Process::Open(entry->pid()); + result &= KillProcess(process.Handle(), exit_code, true); } return result; } diff --git a/base/process/kill.h b/base/process/kill.h index fb6423f..df0d95e 100644 --- a/base/process/kill.h +++ b/base/process/kill.h @@ -57,12 +57,6 @@ BASE_EXPORT bool KillProcess(ProcessHandle process, int exit_code, bool wait); BASE_EXPORT bool KillProcessGroup(ProcessHandle process_group_id); #endif // defined(OS_POSIX) -#if defined(OS_WIN) -BASE_EXPORT bool KillProcessById(ProcessId process_id, - int exit_code, - bool wait); -#endif // defined(OS_WIN) - // Get the termination status of the process by interpreting the // circumstances of the child process' death. |exit_code| is set to // the status returned by waitpid() on POSIX, and from diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc index 4f0f2ef..3c93047 100644 --- a/base/process/kill_win.cc +++ b/base/process/kill_win.cc @@ -101,22 +101,6 @@ bool KillProcess(ProcessHandle process, int exit_code, bool wait) { return result; } -// Attempts to kill the process identified by the given process -// entry structure, giving it the specified exit code. -// Returns true if this is successful, false otherwise. -bool KillProcessById(ProcessId process_id, int exit_code, bool wait) { - HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, - FALSE, // Don't inherit handle - process_id); - if (!process) { - DPLOG(ERROR) << "Unable to open process " << process_id; - return false; - } - bool ret = KillProcess(process, exit_code, wait); - CloseHandle(process); - return ret; -} - TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) { DWORD tmp_exit_code = 0; diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index 63a0c48..439dfb2 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -11,6 +11,7 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/process/kill.h" +#include "base/process/process.h" #include "base/process/process_info.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" @@ -266,6 +267,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { remote_window_ = NULL; return PROCESS_NONE; } + base::Process process = base::Process::Open(process_id); // The window is hung. Scan for every window to find a visible one. bool visible_window = false; @@ -285,7 +287,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { } // Time to take action. Kill the browser process. - base::KillProcessById(process_id, content::RESULT_CODE_HUNG, true); + base::KillProcess(process.Handle(), content::RESULT_CODE_HUNG, true); remote_window_ = NULL; return PROCESS_NONE; } diff --git a/net/tools/stress_cache/stress_cache.cc b/net/tools/stress_cache/stress_cache.cc index d43cb74..b63ce21 100644 --- a/net/tools/stress_cache/stress_cache.cc +++ b/net/tools/stress_cache/stress_cache.cc @@ -25,8 +25,8 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" -#include "base/process/kill.h" #include "base/process/launch.h" +#include "base/process/process.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -203,8 +203,8 @@ void CrashCallback() { if (rand() % 100 > 30) { printf("sweet death...\n"); #if defined(OS_WIN) - // Windows does more work on _exit() that we would like, so we use Kill. - base::KillProcessById(base::GetCurrentProcId(), kExpectedCrash, false); + // Windows does more work on _exit() than we would like. + base::Process::Current().Terminate(kExpectedCrash); #elif defined(OS_POSIX) // On POSIX, _exit() will terminate the process with minimal cleanup, // and it is cleaner than killing. diff --git a/win8/delegate_execute/delegate_execute.cc b/win8/delegate_execute/delegate_execute.cc index 0d2bbbb..2574619 100644 --- a/win8/delegate_execute/delegate_execute.cc +++ b/win8/delegate_execute/delegate_execute.cc @@ -108,9 +108,9 @@ int RelaunchChrome(const DelegateExecuteOperation& operation) { AtlTrace("Unexpected release of the relaunch mutex!!\n"); } else if (result == WAIT_TIMEOUT) { // This could mean that Chrome is hung. Proceed to exterminate. - DWORD pid = operation.GetParentPid(); - AtlTrace("%ds timeout. Killing Chrome %d\n", kWaitSeconds, pid); - base::KillProcessById(pid, 0, false); + base::Process process = operation.GetParent(); + AtlTrace("%ds timeout. Killing Chrome %d\n", kWaitSeconds, process.Pid()); + process.Terminate(0); } else { AtlTrace("Failed to wait for relaunch mutex, result is 0x%x\n", result); } diff --git a/win8/delegate_execute/delegate_execute_operation.cc b/win8/delegate_execute/delegate_execute_operation.cc index a4a61a12..277b74b 100644 --- a/win8/delegate_execute/delegate_execute_operation.cc +++ b/win8/delegate_execute/delegate_execute_operation.cc @@ -51,15 +51,15 @@ bool DelegateExecuteOperation::Init(const base::CommandLine* cmd_line) { return true; } -DWORD DelegateExecuteOperation::GetParentPid() const { +base::Process DelegateExecuteOperation::GetParent() const { std::vector<base::string16> parts; base::SplitString(mutex_, L'.', &parts); if (parts.size() != 3) - return 0; + return base::Process(); DWORD pid; if (!base::StringToUint(parts[2], reinterpret_cast<uint32*>(&pid))) - return 0; - return pid; + return base::Process(); + return base::Process::Open(pid); } } // namespace delegate_execute diff --git a/win8/delegate_execute/delegate_execute_operation.h b/win8/delegate_execute/delegate_execute_operation.h index 26bc19e..3dbc702 100644 --- a/win8/delegate_execute/delegate_execute_operation.h +++ b/win8/delegate_execute/delegate_execute_operation.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/files/file_path.h" +#include "base/process/process.h" #include "base/strings/string16.h" namespace base { @@ -59,8 +60,8 @@ class DelegateExecuteOperation { return mutex_; } - // Returns the process id of the parent or 0 on failure. - DWORD GetParentPid() const; + // Returns the parent process. + base::Process GetParent() const; const base::FilePath& shortcut() const { return relaunch_shortcut_; |