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

Unified Diff: chrome/renderer/renderer_main.cc

Issue 437048: Mac: Proof of concept of IPCing renderer mach_port_ts. (Closed)
Patch Set: add memory stats Created 11 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 | « chrome/common/mach_ipc_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/renderer_main.cc
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index 1531c40926afe4b5315f43e1b509865c975cf1ea..cafab7086a2b0cb982d87154f00fe3afdcf3ab4b 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -27,6 +27,9 @@
#include "grit/generated_resources.h"
#include "net/base/net_module.h"
+
+#include "chrome/common/mach_ipc_mac.h"
+
#if defined(USE_LINUX_BREAKPAD)
#include "chrome/app/breakpad_linux.h"
#endif
@@ -55,6 +58,27 @@ int RendererMain(const MainFunctionParams& parameters) {
const CommandLine& parsed_command_line = parameters.command_line_;
base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_;
+ mach_port_t host_port = mach_host_self();
+ fprintf(stderr, "host port: %lu\n", (unsigned long)host_port);
+
+ // send to already named port
+ MachPortSender sender("com.Google.MyService");
+ MachSendMessage message(57); // our message ID is 57
+
+ // add some ports to be translated for us
+ message.AddDescriptor(mach_task_self()); // our task
+ message.AddDescriptor(mach_thread_self()); // this thread
+ message.AddDescriptor(host_port); // uhh...not sure. but certainly important.
+
+ char messageString[] = "Hello server!\n";
+ message.SetData(messageString, strlen(messageString)+1);
+ // timeout 1000ms
+ kern_return_t result = sender.SendMessage(message, 1000);
+ fprintf(stderr, "send result: %lu\n", (unsigned long)result);
+ if (result != KERN_SUCCESS)
+ fprintf(stderr, "(Failed :-( )\n");
+
+
#if defined(USE_LINUX_BREAKPAD)
// Needs to be called after we have chrome::DIR_USER_DATA.
InitCrashReporter();
« no previous file with comments | « chrome/common/mach_ipc_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698