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.
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.
9 #include "base/synchronization/lock.h"
15 Lock::Lock() : lock_() {
19 DCHECK(owning_thread_ref_
.is_null());
22 void Lock::AssertAcquired() const {
23 DCHECK(owning_thread_ref_
== PlatformThread::CurrentRef());
26 void Lock::CheckHeldAndUnmark() {
27 DCHECK(owning_thread_ref_
== PlatformThread::CurrentRef());
28 owning_thread_ref_
= PlatformThreadRef();
31 void Lock::CheckUnheldAndMark() {
32 DCHECK(owning_thread_ref_
.is_null());
33 owning_thread_ref_
= PlatformThread::CurrentRef();
38 #endif // DCHECK_IS_ON()