Chromium Code Reviews| Index: base/shared_mutex_mac.cc |
| diff --git a/base/shared_mutex_mac.cc b/base/shared_mutex_mac.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d6a1a93d1783d51bc2b1a9b6f968d48375eb29e9 |
| --- /dev/null |
| +++ b/base/shared_mutex_mac.cc |
| @@ -0,0 +1,32 @@ |
| +// 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 "base/shared_mutex.h" |
| +#include "base/mac/scoped_cftyperef.h" |
|
Mark Mentovai
2010/11/09 17:43:14
Blank line before.
dmac
2010/11/11 21:47:59
Done.
|
| +#include "base/sys_string_conversions.h" |
| + |
| +namespace base { |
| + |
| +SharedMutex::SharedMutex(const std::string& name) : port_(NULL), name_(name) { |
| +} |
|
Mark Mentovai
2010/11/09 17:43:14
Blank line before, and } // namespace base.
dmac
2010/11/11 21:47:59
Sorry... what do you mean? A couple of us read you
|
| + |
| +bool SharedMutex::TryLock() { |
| + CFStringRef cf_name(base::SysUTF8ToCFStringRef(name_)); |
| + base::mac::ScopedCFTypeRef<CFStringRef> scoped_cf_name(cf_name); |
| + port_ = CFMessagePortCreateLocal(NULL, |
|
Mark Mentovai
2010/11/09 17:43:14
I’d have just thrown all of these on the same line
dmac
2010/11/11 21:47:59
Done.
|
| + cf_name, |
| + NULL, |
| + NULL, |
| + NULL); |
| + return port_ != NULL; |
| +} |
| + |
| +void SharedMutex::Unlock() { |
| + if (port_) { |
|
Mark Mentovai
2010/11/09 17:43:14
port_ could have just been a ScopedCFTypeRef.
dmac
2010/11/11 21:47:59
Done.
|
| + CFRelease(port_); |
| + port_ = NULL; |
| + } |
| +} |
| + |
| +} // namespace base |