1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker // This file is used for debugging assertion support. The Lock class 6*635a8641SAndroid Build Coastguard Worker // is functionally a wrapper around the LockImpl class, so the only 7*635a8641SAndroid Build Coastguard Worker // real intelligence in the class is in the debugging logic. 8*635a8641SAndroid Build Coastguard Worker 9*635a8641SAndroid Build Coastguard Worker #include "base/synchronization/lock.h" 10*635a8641SAndroid Build Coastguard Worker 11*635a8641SAndroid Build Coastguard Worker #if DCHECK_IS_ON() 12*635a8641SAndroid Build Coastguard Worker 13*635a8641SAndroid Build Coastguard Worker namespace base { 14*635a8641SAndroid Build Coastguard Worker Lock()15*635a8641SAndroid Build Coastguard WorkerLock::Lock() : lock_() { 16*635a8641SAndroid Build Coastguard Worker } 17*635a8641SAndroid Build Coastguard Worker ~Lock()18*635a8641SAndroid Build Coastguard WorkerLock::~Lock() { 19*635a8641SAndroid Build Coastguard Worker DCHECK(owning_thread_ref_.is_null()); 20*635a8641SAndroid Build Coastguard Worker } 21*635a8641SAndroid Build Coastguard Worker AssertAcquired() const22*635a8641SAndroid Build Coastguard Workervoid Lock::AssertAcquired() const { 23*635a8641SAndroid Build Coastguard Worker DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 24*635a8641SAndroid Build Coastguard Worker } 25*635a8641SAndroid Build Coastguard Worker CheckHeldAndUnmark()26*635a8641SAndroid Build Coastguard Workervoid Lock::CheckHeldAndUnmark() { 27*635a8641SAndroid Build Coastguard Worker DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 28*635a8641SAndroid Build Coastguard Worker owning_thread_ref_ = PlatformThreadRef(); 29*635a8641SAndroid Build Coastguard Worker } 30*635a8641SAndroid Build Coastguard Worker CheckUnheldAndMark()31*635a8641SAndroid Build Coastguard Workervoid Lock::CheckUnheldAndMark() { 32*635a8641SAndroid Build Coastguard Worker DCHECK(owning_thread_ref_.is_null()); 33*635a8641SAndroid Build Coastguard Worker owning_thread_ref_ = PlatformThread::CurrentRef(); 34*635a8641SAndroid Build Coastguard Worker } 35*635a8641SAndroid Build Coastguard Worker 36*635a8641SAndroid Build Coastguard Worker } // namespace base 37*635a8641SAndroid Build Coastguard Worker 38*635a8641SAndroid Build Coastguard Worker #endif // DCHECK_IS_ON() 39