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

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: Fixed mac issues 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
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..091e501cb1cda0707f26ba9b4e43fe26daffe54c 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,23 @@ 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 (ChildProcessIdMap::iterator it = child_process_id_map_.begin();
Charlie Reis 2014/11/10 19:57:25 Why not have the map go the other way? Then you c
sramajay 2014/11/11 14:16:05 InvalidatePid is called from other BrowserChildPro
+ it != child_process_id_map_.end(); ++it) {
+ if (it->second == child_process_id) {
+ pid = it->first;
+ break;
+ }
+ }
+ if (pid)
+ InvalidatePid(pid);
}
+
// static
std::string MachBroker::GetMachPortName() {
const base::CommandLine* command_line =

Powered by Google App Engine
This is Rietveld 408576698