summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvargas <rvargas@chromium.org>2015-03-31 21:10:12 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-01 04:11:15 +0000
commitf8d789c4558c7575f4d388d44730d18fdf15772c (patch)
tree54807f725d613c10d0026a98cedb89189bef1a06
parentd65edb7b2d228497056e18100c882f7cf7d59c36 (diff)
downloadchromium_src-f8d789c4558c7575f4d388d44730d18fdf15772c.zip
chromium_src-f8d789c4558c7575f4d388d44730d18fdf15772c.tar.gz
chromium_src-f8d789c4558c7575f4d388d44730d18fdf15772c.tar.bz2
Remove uses of KillProcess.
BUG=417532 Review URL: https://codereview.chromium.org/1035323002 Cr-Commit-Position: refs/heads/master@{#323179}
-rw-r--r--base/process/kill.cc2
-rw-r--r--base/process/kill_win.cc2
-rw-r--r--base/process/launch_win.cc3
-rw-r--r--base/test/launcher/test_launcher.cc2
-rw-r--r--chrome/browser/apps/guest_view/web_view_browsertest.cc7
-rw-r--r--chrome/browser/chrome_plugin_browsertest.cc6
-rw-r--r--chrome/browser/extensions/api/processes/processes_api.cc5
-rw-r--r--chrome/browser/task_manager/task_manager.cc11
-rw-r--r--chrome/browser/ui/cocoa/hung_renderer_controller.mm9
-rw-r--r--chrome/browser/ui/hung_plugin_tab_helper.cc4
-rw-r--r--chromeos/process_proxy/process_proxy.cc5
-rw-r--r--chromeos/process_proxy/process_proxy_unittest.cc12
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc5
-rw-r--r--content/public/browser/browser_message_filter.cc4
-rw-r--r--extensions/browser/extension_function_dispatcher.cc20
15 files changed, 61 insertions, 36 deletions
diff --git a/base/process/kill.cc b/base/process/kill.cc
index a647d96..5d8ba6a 100644
--- a/base/process/kill.cc
+++ b/base/process/kill.cc
@@ -15,7 +15,7 @@ bool KillProcesses(const FilePath::StringType& executable_name,
NamedProcessIterator iter(executable_name, filter);
while (const ProcessEntry* entry = iter.NextProcessEntry()) {
Process process = Process::Open(entry->pid());
- result &= KillProcess(process.Handle(), exit_code, true);
+ result &= process.Terminate(exit_code, true);
}
return result;
}
diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc
index 3c93047..f8dc94e 100644
--- a/base/process/kill_win.cc
+++ b/base/process/kill_win.cc
@@ -81,7 +81,7 @@ 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);
+ process_.Terminate(kProcessKilledExitCode, false);
// Now, just cleanup as if the process exited normally.
OnObjectSignaled(process_.Handle());
diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc
index c2bd295..ebc19b8 100644
--- a/base/process/launch_win.cc
+++ b/base/process/launch_win.cc
@@ -219,7 +219,8 @@ Process LaunchProcess(const string16& cmdline,
if (0 == AssignProcessToJobObject(options.job_handle,
process_info.process_handle())) {
DLOG(ERROR) << "Could not AssignProcessToObject.";
- KillProcess(process_info.process_handle(), kProcessKilledExitCode, true);
+ Process scoped_process(process_info.TakeProcessHandle());
+ scoped_process.Terminate(kProcessKilledExitCode, true);
return Process();
}
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 1d48060..0b09004 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -310,7 +310,7 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
exit_code = -1; // Set a non-zero exit code to signal a failure.
// Ensure that the process terminates.
- KillProcess(process.Handle(), -1, true);
+ process.Terminate(-1, true);
}
{
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc
index 079deed..14b2f9f 100644
--- a/chrome/browser/apps/guest_view/web_view_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/path_service.h"
+#include "base/process/process.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
@@ -2664,9 +2665,9 @@ IN_PROC_BROWSER_TEST_F(
rules_registry_id, "ui").get());
// Kill the embedder's render process, so the webview will go as well.
- content::RenderProcessHost* host =
- embedder_web_contents->GetRenderProcessHost();
- base::KillProcess(host->GetHandle(), 0, false);
+ base::Process process = base::Process::DeprecatedGetProcessFromHandle(
+ embedder_web_contents->GetRenderProcessHost()->GetHandle());
+ process.Terminate(0, false);
observer->WaitForEmbedderRenderProcessTerminate();
EXPECT_FALSE(registry_service->GetRulesRegistry(
diff --git a/chrome/browser/chrome_plugin_browsertest.cc b/chrome/browser/chrome_plugin_browsertest.cc
index 795cfda..7504520 100644
--- a/chrome/browser/chrome_plugin_browsertest.cc
+++ b/chrome/browser/chrome_plugin_browsertest.cc
@@ -11,7 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
-#include "base/process/kill.h"
+#include "base/process/process.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
@@ -171,7 +171,9 @@ class ChromePluginTest : public InProcessBrowserTest {
iter.GetData().process_type != content::PROCESS_TYPE_PPAPI_PLUGIN) {
continue;
}
- base::KillProcess(iter.GetData().handle, 0, true);
+ base::Process process = base::Process::DeprecatedGetProcessFromHandle(
+ iter.GetData().handle);
+ process.Terminate(0, true);
found = true;
}
ASSERT_TRUE(found) << "Didn't find Flash process!";
diff --git a/chrome/browser/extensions/api/processes/processes_api.cc b/chrome/browser/extensions/api/processes/processes_api.cc
index 56a7cb7..e2cc202 100644
--- a/chrome/browser/extensions/api/processes/processes_api.cc
+++ b/chrome/browser/extensions/api/processes/processes_api.cc
@@ -640,8 +640,9 @@ void TerminateFunction::TerminateProcess() {
if (model->IsResourceFirstInGroup(i)) {
if (process_id_ == model->GetUniqueChildProcessId(i)) {
found = true;
- killed = base::KillProcess(model->GetProcess(i),
- content::RESULT_CODE_KILLED, true);
+ base::Process process =
+ base::Process::DeprecatedGetProcessFromHandle(model->GetProcess(i));
+ killed = process.Terminate(content::RESULT_CODE_KILLED, true);
UMA_HISTOGRAM_COUNTS("ChildProcess.KilledByExtensionAPI", 1);
break;
}
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc
index 0bf4708..c9df8ec 100644
--- a/chrome/browser/task_manager/task_manager.cc
+++ b/chrome/browser/task_manager/task_manager.cc
@@ -1549,10 +1549,13 @@ bool TaskManager::IsBrowserProcess(int index) const {
}
void TaskManager::KillProcess(int index) {
- base::ProcessHandle process = model_->GetProcess(index);
- DCHECK(process);
- if (process != base::GetCurrentProcessHandle())
- base::KillProcess(process, content::RESULT_CODE_KILLED, false);
+ base::ProcessHandle process_handle = model_->GetProcess(index);
+ DCHECK(process_handle);
+ if (process_handle != base::GetCurrentProcessHandle()) {
+ base::Process process =
+ base::Process::DeprecatedGetProcessFromHandle(process_handle);
+ process.Terminate(content::RESULT_CODE_KILLED, false);
+ }
}
void TaskManager::ActivateProcess(int index) {
diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.mm b/chrome/browser/ui/cocoa/hung_renderer_controller.mm
index d37254e..a72eeca 100644
--- a/chrome/browser/ui/cocoa/hung_renderer_controller.mm
+++ b/chrome/browser/ui/cocoa/hung_renderer_controller.mm
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/bundle_locations.h"
+#include "base/process/process.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#import "chrome/browser/ui/cocoa/multi_key_equivalent_button.h"
@@ -120,9 +121,11 @@ class HungRendererWebContentsObserverBridge
}
- (IBAction)kill:(id)sender {
- if (hungContents_)
- base::KillProcess(hungContents_->GetRenderProcessHost()->GetHandle(),
- content::RESULT_CODE_HUNG, false);
+ if (hungContents_) {
+ base::Process process = base::Process::DeprecatedGetProcessFromHandle(
+ hungContents_->GetRenderProcessHost()->GetHandle());
+ process.Terminate(content::RESULT_CODE_HUNG, false);
+ }
// Cannot call performClose:, because the close button is disabled.
[self close];
}
diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc
index bb9a21c..afcd1e8 100644
--- a/chrome/browser/ui/hung_plugin_tab_helper.cc
+++ b/chrome/browser/ui/hung_plugin_tab_helper.cc
@@ -112,7 +112,9 @@ void KillPluginOnIOThread(int child_id) {
base::Bind(&DumpAndTerminatePluginInBlockingPool,
base::Owned(new base::win::ScopedHandle(handle))));
#else
- base::KillProcess(data.handle, content::RESULT_CODE_HUNG, false);
+ base::Process process =
+ base::Process::DeprecatedGetProcessFromHandle(data.handle);
+ process.Terminate(content::RESULT_CODE_HUNG, false);
#endif
break;
}
diff --git a/chromeos/process_proxy/process_proxy.cc b/chromeos/process_proxy/process_proxy.cc
index 8ce37ef..7551caa 100644
--- a/chromeos/process_proxy/process_proxy.cc
+++ b/chromeos/process_proxy/process_proxy.cc
@@ -12,8 +12,8 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process/kill.h"
#include "base/process/launch.h"
+#include "base/process/process.h"
#include "base/threading/thread.h"
#include "third_party/cros_system_api/switches/chrome_switches.h"
@@ -144,7 +144,8 @@ void ProcessProxy::Close() {
callback_ = ProcessOutputCallback();
callback_runner_ = NULL;
- base::KillProcess(pid_, 0, true /* wait */);
+ base::Process process = base::Process::DeprecatedGetProcessFromHandle(pid_);
+ process.Terminate(0, true /* wait */);
// TODO(tbarzic): What if this fails?
StopWatching();
diff --git a/chromeos/process_proxy/process_proxy_unittest.cc b/chromeos/process_proxy/process_proxy_unittest.cc
index e6b9c46..97c7495 100644
--- a/chromeos/process_proxy/process_proxy_unittest.cc
+++ b/chromeos/process_proxy/process_proxy_unittest.cc
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/process/kill.h"
+#include "base/process/process.h"
#include "base/threading/thread.h"
#include "chromeos/process_proxy/process_proxy_registry.h"
@@ -132,7 +133,9 @@ class RegistryNotifiedOnProcessExitTestRunner : public TestRunner {
output_received_ = true;
EXPECT_EQ(type, "stdout");
EXPECT_EQ(output, "p");
- base::KillProcess(pid_, 0 , true);
+ base::Process process =
+ base::Process::DeprecatedGetProcessFromHandle(pid_);
+ process.Terminate(0, true);
return;
}
EXPECT_EQ("exit", type);
@@ -197,8 +200,11 @@ class ProcessProxyTest : public testing::Test {
base::TerminationStatus status = base::GetTerminationStatus(pid_, NULL);
EXPECT_NE(base::TERMINATION_STATUS_STILL_RUNNING, status);
- if (status == base::TERMINATION_STATUS_STILL_RUNNING)
- base::KillProcess(pid_, 0, true);
+ if (status == base::TERMINATION_STATUS_STILL_RUNNING) {
+ base::Process process =
+ base::Process::DeprecatedGetProcessFromHandle(pid_);
+ process.Terminate(0, true);
+ }
base::MessageLoop::current()->PostTask(FROM_HERE,
base::MessageLoop::QuitClosure());
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 8ceecc1..d28338d 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1437,7 +1437,10 @@ bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) {
StopChildProcess(GetHandle());
return true;
#else
- return base::KillProcess(GetHandle(), exit_code, wait);
+ if (!child_process_launcher_.get() || child_process_launcher_->IsStarting())
+ return false;
+
+ return child_process_launcher_->GetProcess().Terminate(exit_code, wait);
#endif
}
diff --git a/content/public/browser/browser_message_filter.cc b/content/public/browser/browser_message_filter.cc
index 8ffb957..cb75ff1 100644
--- a/content/public/browser/browser_message_filter.cc
+++ b/content/public/browser/browser_message_filter.cc
@@ -8,7 +8,6 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/process/kill.h"
#include "base/process/process_handle.h"
#include "base/task_runner.h"
#include "content/browser/browser_child_process_host_impl.h"
@@ -184,8 +183,7 @@ void BrowserMessageFilter::BadMessageReceived() {
BrowserChildProcessHostImpl::HistogramBadMessageTerminated(
PROCESS_TYPE_RENDERER);
- base::KillProcess(PeerHandle(), content::RESULT_CODE_KILLED_BAD_MESSAGE,
- false);
+ peer_process_.Terminate(content::RESULT_CODE_KILLED_BAD_MESSAGE, false);
}
BrowserMessageFilter::~BrowserMessageFilter() {
diff --git a/extensions/browser/extension_function_dispatcher.cc b/extensions/browser/extension_function_dispatcher.cc
index fcf4ab4..1fa43ec 100644
--- a/extensions/browser/extension_function_dispatcher.cc
+++ b/extensions/browser/extension_function_dispatcher.cc
@@ -84,19 +84,19 @@ base::LazyInstance<Static> g_global_io_data = LAZY_INSTANCE_INITIALIZER;
// Kills the specified process because it sends us a malformed message.
// Track the specific function's |histogram_value|, as this may indicate a bug
// in that API's implementation on the renderer.
-void KillBadMessageSender(base::ProcessHandle process,
+void KillBadMessageSender(const base::Process& process,
functions::HistogramValue histogram_value) {
NOTREACHED();
content::RecordAction(base::UserMetricsAction("BadMessageTerminate_EFD"));
UMA_HISTOGRAM_ENUMERATION("Extensions.BadMessageFunctionName",
histogram_value, functions::ENUM_BOUNDARY);
- if (process)
- base::KillProcess(process, content::RESULT_CODE_KILLED_BAD_MESSAGE, false);
+ if (process.IsValid())
+ process.Terminate(content::RESULT_CODE_KILLED_BAD_MESSAGE, false);
}
void CommonResponseCallback(IPC::Sender* ipc_sender,
int routing_id,
- base::ProcessHandle peer_process,
+ const base::Process& peer_process,
int request_id,
ExtensionFunction::ResponseType type,
const base::ListValue& results,
@@ -136,8 +136,10 @@ void IOThreadResponseCallback(
if (!ipc_sender.get())
return;
- CommonResponseCallback(ipc_sender.get(), routing_id, ipc_sender->PeerHandle(),
- request_id, type, results, error, histogram_value);
+ base::Process peer_process =
+ base::Process::DeprecatedGetProcessFromHandle(ipc_sender->PeerHandle());
+ CommonResponseCallback(ipc_sender.get(), routing_id, peer_process, request_id,
+ type, results, error, histogram_value);
}
} // namespace
@@ -184,9 +186,11 @@ class ExtensionFunctionDispatcher::UIThreadResponseCallbackWrapper
const base::ListValue& results,
const std::string& error,
functions::HistogramValue histogram_value) {
+ base::Process process = base::Process::DeprecatedGetProcessFromHandle(
+ render_view_host_->GetProcess()->GetHandle());
CommonResponseCallback(render_view_host_, render_view_host_->GetRoutingID(),
- render_view_host_->GetProcess()->GetHandle(),
- request_id, type, results, error, histogram_value);
+ process, request_id, type, results, error,
+ histogram_value);
}
base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_;