| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/mach_broker_mac.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 // Returns the global MachBroker. |
| 10 MachBroker* MachBroker::instance() { |
| 11 return Singleton<MachBroker>::get(); |
| 12 } |
| 13 |
| 14 // Adds mach info for a given pid. |
| 15 void MachBroker::RegisterPid( |
| 16 base::ProcessHandle pid, const MachInfo& mach_info) { |
| 17 AutoLock lock(lock_); |
| 18 DCHECK_EQ(0u, mach_map_.count(pid)); |
| 19 mach_map_[pid] = mach_info; |
| 20 } |
| 21 |
| 22 // Removes all mappings belonging to |pid| from the broker. |
| 23 void MachBroker::Invalidate(base::ProcessHandle pid) { |
| 24 AutoLock lock(lock_); |
| 25 mach_map_.erase(pid); |
| 26 } |
| 27 |
| 28 // Returns the mach task belonging to |pid|. |
| 29 mach_port_t MachBroker::TaskForPid(base::ProcessHandle pid) const { |
| 30 AutoLock lock(lock_); |
| 31 MachBroker::MachMap::const_iterator it = mach_map_.find(pid); |
| 32 if (it == mach_map_.end()) |
| 33 return MACH_PORT_NULL; |
| 34 return it->second.mach_task_; |
| 35 } |
| OLD | NEW |