1 // Copyright (c) 2011 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 // This file is used for debugging assertion support. The Lock class 6 // is functionally a wrapper around the LockImpl class, so the only 7 // real intelligence in the class is in the debugging logic. 8 9 #include "include/base/cef_lock.h" 10 #include "include/base/cef_logging.h" 11 12 #if DCHECK_IS_ON() 13 14 namespace base { 15 namespace cef_internal { 16 Lock()17Lock::Lock() : lock_() {} 18 ~Lock()19Lock::~Lock() { 20 DCHECK(owning_thread_ref_.is_null()); 21 } 22 AssertAcquired() const23void Lock::AssertAcquired() const { 24 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 25 } 26 CheckHeldAndUnmark()27void Lock::CheckHeldAndUnmark() { 28 DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 29 owning_thread_ref_ = PlatformThreadRef(); 30 } 31 CheckUnheldAndMark()32void Lock::CheckUnheldAndMark() { 33 // Hitting this DCHECK means that your code is trying to re-enter a lock that 34 // is already held. The Chromium Lock implementation is not reentrant. 35 // See "Why can the holder of a Lock not reacquire it?" at 36 // http://www.chromium.org/developers/lock-and-condition-variable for more 37 // information. 38 DCHECK(owning_thread_ref_.is_null()); 39 owning_thread_ref_ = PlatformThread::CurrentRef(); 40 } 41 42 } // namespace cef_internal 43 } // namespace base 44 45 #endif // DCHECK_IS_ON() 46