summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-09 07:54:32 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-09 07:54:32 +0000
commit2191d2082e2bf1f937ec4592b4f8c185f04f3fd6 (patch)
tree72193cc3ae1951e91924353de58a1f2ed7c8af23 /chrome/renderer
parent04df4f1ea242136c0829b8d922c3aefdbb4ebd85 (diff)
downloadchromium_src-2191d2082e2bf1f937ec4592b4f8c185f04f3fd6.zip
chromium_src-2191d2082e2bf1f937ec4592b4f8c185f04f3fd6.tar.gz
chromium_src-2191d2082e2bf1f937ec4592b4f8c185f04f3fd6.tar.bz2
A place to store the pid->mach_port_t mapping.
Not yet for review. Landing to measure perf impact, will revert immediately. BUG=13156 TEST=unittests Review URL: http://codereview.chromium.org/460126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/renderer_main.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index c8f89c9..ebacbbf 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -32,6 +32,12 @@
#include "chrome/app/breakpad_linux.h"
#endif
+#if defined(OS_MACOSX)
+#include "ipc/ipc_switches.h"
+#include "base/thread.h"
+#include "chrome/common/mach_ipc_mac.h"
+#endif
+
// This function provides some ways to test crash and assertion handling
// behavior of the renderer.
static void HandleRendererErrorTestParameters(const CommandLine& command_line) {
@@ -51,6 +57,54 @@ static void HandleRendererErrorTestParameters(const CommandLine& command_line) {
}
}
+#if defined(OS_MACOSX)
+class MachSendTask : public Task {
+ public:
+ MachSendTask(const std::string& channel_name) : channel_name_(channel_name) {}
+
+ virtual void Run() {
+ // TODO(thakis): Put these somewhere central.
+ const int kMachPortMessageID = 57;
+ const std::string kMachChannelPrefix = "com.Google.Chrome";
+
+ const int kMachPortMessageSendWaitMs = 5000;
+ std::string channel_name = kMachChannelPrefix + channel_name_;
+printf("Creating send port %s\n", channel_name.c_str());
+ MachPortSender sender(channel_name.c_str());
+ MachSendMessage message(kMachPortMessageID);
+
+ // add some ports to be translated for us
+ message.AddDescriptor(mach_task_self());
+ message.AddDescriptor(mach_host_self());
+
+ kern_return_t result = sender.SendMessage(message,
+ kMachPortMessageSendWaitMs);
+
+ // TODO(thakis): Log error somewhere? (don't printf in any case :-P)
+ fprintf(stderr, "send result: %lu\n", (unsigned long)result);
+ if (result != KERN_SUCCESS)
+ fprintf(stderr, "(Failed :-( )\n");
+ }
+ private:
+ std::string channel_name_;
+};
+
+class MachSendThread : public base::Thread {
+ public:
+ MachSendThread() : base::Thread("MachSendThread") {}
+
+ void DoIt() {
+ DCHECK(message_loop());
+ std::string name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessChannelID);
+printf("main thread: %s\n", name.c_str());
+ message_loop()->PostTask(
+ FROM_HERE,
+ new MachSendTask(name));
+ }
+};
+#endif
+
// mainline routine for running as the Renderer process
int RendererMain(const MainFunctionParams& parameters) {
const CommandLine& parsed_command_line = parameters.command_line_;
@@ -76,6 +130,14 @@ int RendererMain(const MainFunctionParams& parameters) {
startup_timer(chrome::Counters::renderer_main());
#if defined(OS_MACOSX)
+ {
+ MachSendThread mach_thread;
+ CHECK(mach_thread.Start());
+ mach_thread.DoIt();
+ }
+#endif
+
+#if defined(OS_MACOSX)
// As long as we use Cocoa in the renderer (for the forseeable future as of
// now; see http://crbug.com/13890 for info) we need to have a UI loop.
MessageLoop main_message_loop(MessageLoop::TYPE_UI);