summaryrefslogtreecommitdiffstats
path: root/chrome/browser/mach_broker_mac.h
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-12 00:39:15 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-12 00:39:15 +0000
commitc002879632b0e46b11e91e5595a83652f7cafd3c (patch)
tree87477d9e6b972292fbb98484ec3721f084ab41c4 /chrome/browser/mach_broker_mac.h
parent62ed4d36e4357deaf863711bdfd1f00b367c426a (diff)
downloadchromium_src-c002879632b0e46b11e91e5595a83652f7cafd3c.zip
chromium_src-c002879632b0e46b11e91e5595a83652f7cafd3c.tar.gz
chromium_src-c002879632b0e46b11e91e5595a83652f7cafd3c.tar.bz2
Mac: Other approach for IPCing child task_ts.
Also move mach_ipc_mac to base, where it's now used. Based on http://www.foldr.org/~michaelw/log/2009/03/13/ , but uses a named connection instead. Do the IPC right after fork-time, so that the sandbox is not yet in effect. See the codereview comments for a benchmark that proves that this shouldn't be expensive, and for pros and cons for using a named connection vs temporarily switching out the bootstrap port. Works for worker processes too and seems more reliable in general. Measured perf impact in http://src.chromium.org/viewvc/chrome?view=rev&revision=35888 , it's negligible. BUG=13156 TEST=(requires that one enables the task manager in browser.cc) 1.) Open one tab that plays a youtube video 2.) Open a second and visit http://www.whatwg.org/demos/workers/primes/page.html 3.) Install e.g. the gmail checker extension 4.) Open the task manager It should report metrics for * one browser process * two renderer processes * one plugin process * one worker process * one extension process Check that %cpu etc more or less match what Activity Monitor displays if you filter for "Chromium". Also choose "Open all bookmarks" on the bookmarks bar with the task manager open and check that metrics for all tabs appear immediately. Review URL: http://codereview.chromium.org/549002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mach_broker_mac.h')
-rw-r--r--chrome/browser/mach_broker_mac.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome/browser/mach_broker_mac.h b/chrome/browser/mach_broker_mac.h
index 67f4fec..1827fc9 100644
--- a/chrome/browser/mach_broker_mac.h
+++ b/chrome/browser/mach_broker_mac.h
@@ -13,6 +13,7 @@
#include "base/process.h"
#include "base/process_util.h"
#include "base/singleton.h"
+#include "chrome/common/notification_registrar.h"
// On OS X, the mach_port_t of a process is required to collect metrics about
// the process. Running |task_for_pid()| is only allowed for privileged code.
@@ -28,7 +29,8 @@
//
// Since this data arrives over a separate channel, it is not available
// immediately after a child process has been started.
-class MachBroker : public base::ProcessMetrics::PortProvider {
+class MachBroker : public base::ProcessMetrics::PortProvider,
+ public NotificationObserver {
public:
// Returns the global MachBroker.
static MachBroker* instance();
@@ -53,9 +55,18 @@ class MachBroker : public base::ProcessMetrics::PortProvider {
// Implement |ProcessMetrics::PortProvider|.
virtual mach_port_t TaskForPid(base::ProcessHandle process) const;
+ // Implement |NotificationObserver|.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
private:
// Private constructor.
- MachBroker() {}
+ MachBroker();
+
+ // Used to register for notifications received by NotificationObserver.
+ // Accessed only on the UI thread.
+ NotificationRegistrar registrar_;
+
friend struct DefaultSingletonTraits<MachBroker>;
friend class MachBrokerTest;
@@ -66,6 +77,7 @@ class MachBroker : public base::ProcessMetrics::PortProvider {
// Mutex that guards |mach_map_|.
mutable Lock lock_;
+ friend class RegisterNotificationTask;
DISALLOW_COPY_AND_ASSIGN(MachBroker);
};