Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: content/browser/mach_broker_mac.mm

Issue 681733003: Removed the ProcessHandle from the RendererClosedDetails payload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Used range-based loop Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/mach_broker_mac.h ('k') | content/browser/mach_broker_mac_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/mach_broker_mac.mm
diff --git a/content/browser/mach_broker_mac.mm b/content/browser/mach_broker_mac.mm
index f2e5f985c32a792b19455d96e9b762bc3a655eb7..d2aea0789261de3e65257000345c5f4308ea85cc 100644
--- a/content/browser/mach_broker_mac.mm
+++ b/content/browser/mach_broker_mac.mm
@@ -195,11 +195,13 @@ void MachBroker::EnsureRunning() {
}
}
-void MachBroker::AddPlaceholderForPid(base::ProcessHandle pid) {
+void MachBroker::AddPlaceholderForPid(base::ProcessHandle pid,
+ int child_process_id) {
lock_.AssertAcquired();
DCHECK_EQ(0u, mach_map_.count(pid));
mach_map_[pid] = MACH_PORT_NULL;
+ child_process_id_map_[pid] = child_process_id;
}
mach_port_t MachBroker::TaskForPid(base::ProcessHandle pid) const {
@@ -222,23 +224,17 @@ void MachBroker::BrowserChildProcessCrashed(const ChildProcessData& data) {
void MachBroker::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
- // TODO(rohitrao): These notifications do not always carry the proper PIDs,
- // especially when the renderer is already gone or has crashed. Find a better
- // way to listen for child process deaths. http://crbug.com/55734
- base::ProcessHandle handle = 0;
switch (type) {
- case NOTIFICATION_RENDERER_PROCESS_CLOSED:
- handle = Details<RenderProcessHost::RendererClosedDetails>(
- details)->handle;
- break;
case NOTIFICATION_RENDERER_PROCESS_TERMINATED:
- handle = Source<RenderProcessHost>(source)->GetHandle();
+ case NOTIFICATION_RENDERER_PROCESS_CLOSED: {
+ RenderProcessHost* host = Source<RenderProcessHost>(source).ptr();
+ InvalidateChildProcessId(host->GetID());
break;
+ }
default:
NOTREACHED() << "Unexpected notification";
break;
}
- InvalidatePid(handle);
}
MachBroker::MachBroker() : listener_thread_started_(false) {
@@ -272,8 +268,22 @@ void MachBroker::InvalidatePid(base::ProcessHandle pid) {
it->second);
MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "mach_port_deallocate";
mach_map_.erase(it);
+ child_process_id_map_.erase(pid);
+}
+
+void MachBroker::InvalidateChildProcessId(int child_process_id) {
+ base::ProcessHandle pid = 0;
+ for (const auto& it : child_process_id_map_) {
Mark Mentovai 2014/11/13 14:00:10 You need to assert that the lock is held to be abl
sramajay 2014/11/13 15:45:28 Ok. I can remove the InvalidatePid with the above
+ if (it.second == child_process_id) {
Mark Mentovai 2014/11/13 14:00:10 It seems like you really want a bidirectional map,
sramajay 2014/11/13 15:45:28 Its not only InvalidatePid(), but FinalizePid() is
Mark Mentovai 2014/11/13 16:04:53 Then it sounds like we should have a map from PID
+ pid = it.first;
+ break;
+ }
+ }
+ if (pid)
+ InvalidatePid(pid);
}
+
// static
std::string MachBroker::GetMachPortName() {
const base::CommandLine* command_line =
« no previous file with comments | « content/browser/mach_broker_mac.h ('k') | content/browser/mach_broker_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698