summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-10 06:48:18 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-10 06:48:18 +0000
commit675112ffb6168a9e9579305d4618fc7f0a2e6e74 (patch)
treed7123c168aa76fd6c6d441471ef1aa1fac189bfe
parent474f059570ce28bc9f93a140e4396d5e35d9c09c (diff)
downloadchromium_src-675112ffb6168a9e9579305d4618fc7f0a2e6e74.zip
chromium_src-675112ffb6168a9e9579305d4618fc7f0a2e6e74.tar.gz
chromium_src-675112ffb6168a9e9579305d4618fc7f0a2e6e74.tar.bz2
Revert 35888 - Mac: Other approach for IPCing child task_ts.
Based on http://www.foldr.org/~michaelw/log/2009/03/13/ , right now in proofofconcept quality. Works for worker processes too and seems more reliable in general. Makes it impossible to call LaunchApp() concurrently though. Next try: Submitting to get perf numbers, will revert. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=35883 Review URL: http://codereview.chromium.org/549002 TBR=thakis@chromium.org Review URL: http://codereview.chromium.org/536009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35890 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/process_util_posix.cc146
-rw-r--r--chrome/browser/browser.cc4
-rw-r--r--chrome/browser/child_process_launcher.cc12
3 files changed, 2 insertions, 160 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 1b6dc44..21626732 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -28,17 +28,6 @@
const int kMicrosecondsPerSecond = 1000000;
-#if defined(OS_MACOSX)
-
-std::map<pid_t, task_t> g_map;
-
-task_t foobar(pid_t pid) {
-return g_map[pid];
-}
-#endif
-
-
-
namespace base {
namespace {
@@ -291,146 +280,11 @@ void SetAllFDsToCloseOnExec() {
}
}
-#if defined(OS_MACOSX)
-
-#define CHECK_MACH_ERROR(err, s) \
-do { \
- if (err != KERN_SUCCESS) { \
- fprintf(stderr, "%s 0x%x", s, (int)err); \
- exit(1); \
- } \
-} while (0)
-
-static int
-setup_recv_port (mach_port_t *recv_port)
-{
- kern_return_t err;
- mach_port_t port = MACH_PORT_NULL;
- err = mach_port_allocate (mach_task_self (),
- MACH_PORT_RIGHT_RECEIVE, &port);
- CHECK_MACH_ERROR (err, "mach_port_allocate failed:");
-
- err = mach_port_insert_right (mach_task_self (),
- port,
- port,
- MACH_MSG_TYPE_MAKE_SEND);
- CHECK_MACH_ERROR (err, "mach_port_insert_right failed:");
-
- *recv_port = port;
- return 0;
-}
-
-static int
-send_port (mach_port_t remote_port, mach_port_t port)
-{
- kern_return_t err;
-
- struct {
- mach_msg_header_t header;
- mach_msg_body_t body;
- mach_msg_port_descriptor_t task_port;
- } msg;
-
- msg.header.msgh_remote_port = remote_port;
- msg.header.msgh_local_port = MACH_PORT_NULL;
- msg.header.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, 0) |
- MACH_MSGH_BITS_COMPLEX;
- msg.header.msgh_size = sizeof msg;
-
- msg.body.msgh_descriptor_count = 1;
- msg.task_port.name = port;
- msg.task_port.disposition = MACH_MSG_TYPE_COPY_SEND;
- msg.task_port.type = MACH_MSG_PORT_DESCRIPTOR;
-
- err = mach_msg_send (&msg.header);
- CHECK_MACH_ERROR (err, "mach_msg_send failed:");
-
- return 0;
-}
-
-static int
-recv_port (mach_port_t recv_port, mach_port_t *port)
-{
- kern_return_t err;
- struct {
- mach_msg_header_t header;
- mach_msg_body_t body;
- mach_msg_port_descriptor_t task_port;
- mach_msg_trailer_t trailer;
- } msg;
-
- err = mach_msg (&msg.header, MACH_RCV_MSG,
- 0, sizeof msg, recv_port,
- MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
- CHECK_MACH_ERROR (err, "mach_msg failed:");
-
- *port = msg.task_port.name;
- return 0;
-}
-
-static task_t child_task = MACH_PORT_NULL;
-
-pid_t
-sampling_fork ()
-{
- kern_return_t err;
- mach_port_t parent_recv_port = MACH_PORT_NULL;
- mach_port_t child_recv_port = MACH_PORT_NULL;
-
- if (setup_recv_port (&parent_recv_port) != 0)
- return -1;
- err = task_set_bootstrap_port (mach_task_self (), parent_recv_port);
- CHECK_MACH_ERROR (err, "task_set_bootstrap_port failed:");
-
- pid_t pid;
- switch (pid = fork ()) {
- case -1:
- err = mach_port_deallocate (mach_task_self(), parent_recv_port);
- CHECK_MACH_ERROR (err, "mach_port_deallocate failed:");
- return pid;
- case 0: /* child */
- err = task_get_bootstrap_port (mach_task_self (), &parent_recv_port);
- CHECK_MACH_ERROR (err, "task_get_bootstrap_port failed:");
- if (setup_recv_port (&child_recv_port) != 0)
- return -1;
- if (send_port (parent_recv_port, mach_task_self ()) != 0)
- return -1;
- if (send_port (parent_recv_port, child_recv_port) != 0)
- return -1;
- if (recv_port (child_recv_port, &bootstrap_port) != 0)
- return -1;
- err = task_set_bootstrap_port (mach_task_self (), bootstrap_port);
- CHECK_MACH_ERROR (err, "task_set_bootstrap_port failed:");
- break;
- default: /* parent */
- err = task_set_bootstrap_port (mach_task_self (), bootstrap_port);
- CHECK_MACH_ERROR (err, "task_set_bootstrap_port failed:");
- if (recv_port (parent_recv_port, &child_task) != 0)
- return -1;
- if (recv_port (parent_recv_port, &child_recv_port) != 0)
- return -1;
- if (send_port (child_recv_port, bootstrap_port) != 0)
- return -1;
- err = mach_port_deallocate (mach_task_self(), parent_recv_port);
- CHECK_MACH_ERROR (err, "mach_port_deallocate failed:");
- break;
- }
-
- return pid;
-}
-#endif
-
bool LaunchApp(const std::vector<std::string>& argv,
const environment_vector& environ,
const file_handle_mapping_vector& fds_to_remap,
bool wait, ProcessHandle* process_handle) {
-#if defined(OS_MACOSX)
- // Needs to be mutexed! :-(
- pid_t pid = sampling_fork();
- g_map[pid] = child_task;
-#else
pid_t pid = fork();
-#endif
if (pid < 0)
return false;
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 6a0ba3e..91f0101 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -2557,9 +2557,9 @@ void Browser::InitCommandState() {
command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, true);
// TODO(viettrungluu): Temporarily disabled on Mac. Must disable here (not in
// BWC) so that it also affects the page menu. http://crbug.com/13156
-//#if !defined(OS_MACOSX)
+#if !defined(OS_MACOSX)
command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true);
-//#endif
+#endif
command_updater_.UpdateCommandEnabled(IDC_SELECT_PROFILE, true);
command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
diff --git a/chrome/browser/child_process_launcher.cc b/chrome/browser/child_process_launcher.cc
index be2b801..1ab66c6 100644
--- a/chrome/browser/child_process_launcher.cc
+++ b/chrome/browser/child_process_launcher.cc
@@ -23,10 +23,6 @@
#include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
#endif
-#if defined(OS_MACOSX)
-#include "chrome/browser/mach_broker_mac.h"
-#endif
-
#if defined(OS_POSIX)
#include "base/global_descriptors_posix.h"
#endif
@@ -167,14 +163,6 @@ class ChildProcessLauncher::Context
// Actually launch the app.
if (!base::LaunchApp(cmd_line->argv(), env, fds_to_map, false, &handle))
handle = base::kNullProcessHandle;
-
-
-#if defined(OS_MACOSX)
-task_t foobar(pid_t pid);
- MachBroker::instance()->RegisterPid(
- handle,
- MachBroker::MachInfo().SetTask(foobar(handle)));
-#endif
}
#endif