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

Unified Diff: chrome/app/chrome_dll_main.cc

Issue 3443002: [Mac] Replace the existing browser-child mach ipc with a long-lived listener ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | « base/process_util_posix.cc ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_dll_main.cc
===================================================================
--- chrome/app/chrome_dll_main.cc (revision 59759)
+++ chrome/app/chrome_dll_main.cc (working copy)
@@ -80,8 +80,10 @@
#if defined(OS_MACOSX)
#include "app/l10n_util_mac.h"
#include "base/mac_util.h"
+#include "base/mach_ipc_mac.h"
+#include "chrome/app/breakpad_mac.h"
+#include "chrome/browser/mach_broker_mac.h"
#include "chrome/common/chrome_paths_internal.h"
-#include "chrome/app/breakpad_mac.h"
#include "grit/chromium_strings.h"
#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
#endif
@@ -409,6 +411,29 @@
mac_util::SetProcessName(reinterpret_cast<CFStringRef>(app_name));
}
}
+
+// Completes the Mach IPC handshake by sending this process' task port to the
+// parent process. The parent is listening on the Mach port given by
+// |GetMachPortName()|. The task port is used by the parent to get CPU/memory
+// stats to display in the task manager.
+void SendTaskPortToParentProcess() {
+ const mach_msg_timeout_t kTimeoutMs = 100;
+ const int32_t kMessageId = 0;
+ std::string mach_port_name = MachBroker::GetMachPortName();
+
+ base::MachSendMessage child_message(kMessageId);
+ if (!child_message.AddDescriptor(mach_task_self())) {
+ LOG(ERROR) << "child AddDescriptor(mach_task_self()) failed.";
+ return;
+ }
+
+ base::MachPortSender child_sender(mach_port_name.c_str());
+ kern_return_t err = child_sender.SendMessage(child_message, kTimeoutMs);
+ if (err != KERN_SUCCESS) {
+ LOG(ERROR) << StringPrintf("child SendMessage() failed: 0x%x %s", err,
+ mach_error_string(err));
+ }
+}
#endif // defined(OS_MACOSX)
void InitializeStatsTable(base::ProcessId browser_pid,
@@ -588,6 +613,7 @@
DCHECK_NE(browser_pid, 0u);
#elif defined(OS_MACOSX)
browser_pid = base::GetCurrentProcId();
+ SendTaskPortToParentProcess();
#elif defined(OS_POSIX)
// On linux, we're in the zygote here; so we need the parent process' id.
browser_pid = base::GetParentProcessId(base::GetCurrentProcId());
« no previous file with comments | « base/process_util_posix.cc ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698