diff options
-rw-r--r-- | base/process_util.h | 4 | ||||
-rw-r--r-- | base/process_util_posix.cc | 5 | ||||
-rw-r--r-- | base/process_util_win.cc | 11 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 7 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 6 |
6 files changed, 26 insertions, 10 deletions
diff --git a/base/process_util.h b/base/process_util.h index 286330b..615e5b6 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -68,8 +68,8 @@ ProcessId GetCurrentProcId(); ProcessHandle GetCurrentProcessHandle(); // Converts a PID to a process handle. This handle must be closed by -// CloseProcessHandle when you are done with it. -ProcessHandle OpenProcessHandle(ProcessId pid); +// CloseProcessHandle when you are done with it. Returns true on success. +bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle); // Closes the process handle opened by OpenProcessHandle. void CloseProcessHandle(ProcessHandle process); diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 439b806..d55f65d 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -35,10 +35,11 @@ ProcessHandle GetCurrentProcessHandle() { return GetCurrentProcId(); } -ProcessHandle OpenProcessHandle(ProcessId pid) { +bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { // On Posix platforms, process handles are the same as PIDs, so we // don't need to do anything. - return pid; + *handle = pid; + return true; } void CloseProcessHandle(ProcessHandle process) { diff --git a/base/process_util_win.cc b/base/process_util_win.cc index df3d7f20..955c086 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -33,8 +33,15 @@ ProcessHandle GetCurrentProcessHandle() { return ::GetCurrentProcess(); } -ProcessHandle OpenProcessHandle(ProcessId pid) { - return OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE, FALSE, pid); +bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { + ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE, + FALSE, pid); + + if (result == INVALID_HANDLE_VALUE) + return false; + + *handle = result; + return true; } void CloseProcessHandle(ProcessHandle process) { diff --git a/chrome/browser/metrics/metrics_service_uitest.cc b/chrome/browser/metrics/metrics_service_uitest.cc index c61a39d..9e6940ed 100644 --- a/chrome/browser/metrics/metrics_service_uitest.cc +++ b/chrome/browser/metrics/metrics_service_uitest.cc @@ -92,7 +92,8 @@ TEST_F(MetricsServiceTest, CrashRenderers) { int process_id = 0; ASSERT_TRUE(tab->GetProcessID(&process_id)); ASSERT_NE(0, process_id); - base::ProcessHandle process_handle = base::OpenProcessHandle(process_id); + base::ProcessHandle process_handle; + ASSERT_TRUE(base::OpenProcessHandle(process_id, &process_handle)); // Fake Access Violation. base::KillProcess(process_handle, 0xc0000005, true); base::CloseProcessHandle(process_handle); diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 007c5fd..549fc6a 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -173,8 +173,11 @@ void ResourceMessageFilter::OnFilterAdded(IPC::Channel* channel) { // Called on the IPC thread: void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) { DCHECK(!handle()); - set_handle(base::OpenProcessHandle(peer_pid)); - DCHECK(handle()); + base::ProcessHandle peer_handle; + if (!base::OpenProcessHandle(peer_pid, &peer_handle)) { + NOTREACHED(); + } + set_handle(peer_handle); // Hook AudioRendererHost to this object after channel is connected so it can // this object for sending messages. audio_renderer_host_->IPCChannelConnected(this); diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index 066bda3..1c6a809 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -100,7 +100,11 @@ int PluginChannel::GenerateRouteID() { } void PluginChannel::OnChannelConnected(int32 peer_pid) { - renderer_handle_.Set(base::OpenProcessHandle(peer_pid)); + base::ProcessHandle handle; + if (!base::OpenProcessHandle(peer_pid, &handle)) { + NOTREACHED(); + } + renderer_handle_.Set(handle); PluginChannelBase::OnChannelConnected(peer_pid); } |