Port PluginObject fix downstream. See http://trac.webkit.org/changeset/61415/ for...
[chromium-blink-merge.git] / base / lock.cc
blobc73a458c3df395ebd77576b6bd3b9d5977af899e
1 // Copyright (c) 2010 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 #if !defined(NDEBUG)
11 #include "base/lock.h"
12 #include "base/logging.h"
14 Lock::Lock() : lock_() {
15 owned_by_thread_ = false;
16 owning_thread_id_ = static_cast<PlatformThreadId>(0);
19 void Lock::AssertAcquired() const {
20 DCHECK(owned_by_thread_);
21 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
24 void Lock::CheckHeldAndUnmark() {
25 DCHECK(owned_by_thread_);
26 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
27 owned_by_thread_ = false;
28 owning_thread_id_ = static_cast<PlatformThreadId>(0);
31 void Lock::CheckUnheldAndMark() {
32 DCHECK(!owned_by_thread_);
33 owned_by_thread_ = true;
34 owning_thread_id_ = PlatformThread::CurrentId();
37 #endif // NDEBUG