summaryrefslogtreecommitdiffstats
path: root/chrome/browser/mach_broker_mac.cc
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-21 17:44:20 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-21 17:44:20 +0000
commitb2e8e08818f3542c9043aececfbc913499226183 (patch)
tree84f4bcf67581c8239424420ba831aa8031db382f /chrome/browser/mach_broker_mac.cc
parent6b4a530327976d8717dd007cf1403ee453148856 (diff)
downloadchromium_src-b2e8e08818f3542c9043aececfbc913499226183.zip
chromium_src-b2e8e08818f3542c9043aececfbc913499226183.tar.gz
chromium_src-b2e8e08818f3542c9043aececfbc913499226183.tar.bz2
Mac: Create a pid->task_t mapping in the browser process.
Since nothing writes to this map in the browser atm, this does not have any visible effect. BUG=13156,25454 TEST=unittest Review URL: http://codereview.chromium.org/501138 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mach_broker_mac.cc')
-rw-r--r--chrome/browser/mach_broker_mac.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/chrome/browser/mach_broker_mac.cc b/chrome/browser/mach_broker_mac.cc
new file mode 100644
index 0000000..59f7728
--- /dev/null
+++ b/chrome/browser/mach_broker_mac.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/mach_broker_mac.h"
+
+#include "base/logging.h"
+
+// Returns the global MachBroker.
+MachBroker* MachBroker::instance() {
+ return Singleton<MachBroker>::get();
+}
+
+// Adds mach info for a given pid.
+void MachBroker::RegisterPid(
+ base::ProcessHandle pid, const MachInfo& mach_info) {
+ AutoLock lock(lock_);
+ DCHECK_EQ(0u, mach_map_.count(pid));
+ mach_map_[pid] = mach_info;
+}
+
+// Removes all mappings belonging to |pid| from the broker.
+void MachBroker::Invalidate(base::ProcessHandle pid) {
+ AutoLock lock(lock_);
+ mach_map_.erase(pid);
+}
+
+// Returns the mach task belonging to |pid|.
+mach_port_t MachBroker::TaskForPid(base::ProcessHandle pid) const {
+ AutoLock lock(lock_);
+ MachBroker::MachMap::const_iterator it = mach_map_.find(pid);
+ if (it == mach_map_.end())
+ return MACH_PORT_NULL;
+ return it->second.mach_task_;
+}