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

Unified Diff: content/browser/child_process_launcher.cc

Issue 13845008: [Mac] Remove base::LaunchSynchronize and rewrite content::MachBroker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix link_settings Created 7 years, 8 months 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/app/content_main_runner.cc ('k') | content/browser/mach_broker_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 66e7c83085c3dfdc759cf9f806644e49c170d50d..bde7f93fac8c5956efec89330622d96047dfdefb 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -266,30 +266,30 @@ class ChildProcessLauncher::Context
options.fds_to_remap = &fds_to_map;
#if defined(OS_MACOSX)
- // Use synchronization to make sure that the MachBroker is ready to
- // receive a check-in from the new process before the new process
- // actually tries to check in.
- base::LaunchSynchronizationHandle synchronization_handle;
- options.synchronize = &synchronization_handle;
+ // Hold the MachBroker lock for the duration of LaunchProcess. The child
+ // will send its task port to the parent almost immediately after startup.
+ // The Mach message will be delivered to the parent, but updating the
+ // record of the launch will wait until after the placeholder PID is
+ // inserted below. This ensures that while the child process may send its
+ // port to the parent prior to the parent leaving LaunchProcess, the
+ // order in which the record in MachBroker is updated is correct.
+ MachBroker* broker = MachBroker::GetInstance();
+ broker->GetLock().Acquire();
+
+ // Make sure the MachBroker is running, and inform it to expect a
+ // check-in from the new process.
+ broker->EnsureRunning();
#endif // defined(OS_MACOSX)
bool launched = base::LaunchProcess(*cmd_line, options, &handle);
#if defined(OS_MACOSX)
- if (launched) {
- MachBroker* broker = MachBroker::GetInstance();
- {
- base::AutoLock lock(broker->GetLock());
-
- // Make sure the MachBroker is running, and inform it to expect a
- // check-in from the new process.
- broker->EnsureRunning();
- broker->AddPlaceholderForPid(handle);
- }
+ if (launched)
+ broker->AddPlaceholderForPid(handle);
- // Now that the MachBroker is ready, the child may continue.
- base::LaunchSynchronize(synchronization_handle);
- }
+ // After updating the broker, release the lock and let the child's
+ // messasge be processed on the broker's thread.
+ broker->GetLock().Release();
#endif // defined(OS_MACOSX)
if (!launched)
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/browser/mach_broker_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698