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

Unified Diff: chrome/browser/mach_broker_mac.cc

Issue 501138: Mac: Create a pid->task_t mapping in the browser process. (Closed)
Patch Set: trunglify Created 11 years 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
Index: chrome/browser/mach_broker_mac.cc
diff --git a/chrome/browser/mach_broker_mac.cc b/chrome/browser/mach_broker_mac.cc
new file mode 100644
index 0000000000000000000000000000000000000000..59f77282234969846948cac52df23c0b7a8b449b
--- /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_;
+}

Powered by Google App Engine
This is Rietveld 408576698