| 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());
|
|
|