Index: chrome/common/multi_process_lock_mac.cc |
diff --git a/chrome/common/multi_process_lock_mac.cc b/chrome/common/multi_process_lock_mac.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..896e750fdcf693f7e6d4ec0e13f11d1750835b8e |
--- /dev/null |
+++ b/chrome/common/multi_process_lock_mac.cc |
@@ -0,0 +1,35 @@ |
+// Copyright (c) 2010 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/common/multi_process_lock.h" |
+ |
+#include "base/mac/scoped_cftyperef.h" |
+#include "base/sys_string_conversions.h" |
+ |
+class MultiProcessLockMac : public MultiProcessLock { |
+ public: |
+ explicit MultiProcessLockMac(const std::string& name) |
+ : MultiProcessLock(name) { } |
+ |
+ virtual ~MultiProcessLockMac() { Unlock(); } |
+ |
+ virtual bool TryLock() { |
+ CFStringRef cf_name(base::SysUTF8ToCFStringRef(name_)); |
+ base::mac::ScopedCFTypeRef<CFStringRef> scoped_cf_name(cf_name); |
+ port_.reset(CFMessagePortCreateLocal(NULL, cf_name, NULL, NULL, NULL)); |
+ return port_ != NULL; |
+ } |
+ |
+ virtual void Unlock() { |
+ port_.reset(); |
+ } |
+ |
+ private: |
+ base::mac::ScopedCFTypeRef<CFMessagePortRef> port_; |
+ DISALLOW_COPY_AND_ASSIGN(MultiProcessLockMac); |
+}; |
+ |
+MultiProcessLock* MultiProcessLock::Create(const std::string &name) { |
+ return new MultiProcessLockMac(name); |
+} |