security/sandbox/chromium/base/synchronization/lock.cc

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 // This file is used for debugging assertion support. The Lock class
michael@0 6 // is functionally a wrapper around the LockImpl class, so the only
michael@0 7 // real intelligence in the class is in the debugging logic.
michael@0 8
michael@0 9 #if !defined(NDEBUG)
michael@0 10
michael@0 11 #include "base/synchronization/lock.h"
michael@0 12 #include "base/logging.h"
michael@0 13
michael@0 14 namespace base {
michael@0 15
michael@0 16 const PlatformThreadId kNoThreadId = static_cast<PlatformThreadId>(0);
michael@0 17
michael@0 18 Lock::Lock() : lock_() {
michael@0 19 owned_by_thread_ = false;
michael@0 20 owning_thread_id_ = kNoThreadId;
michael@0 21 }
michael@0 22
michael@0 23 Lock::~Lock() {
michael@0 24 DCHECK(!owned_by_thread_);
michael@0 25 DCHECK_EQ(kNoThreadId, owning_thread_id_);
michael@0 26 }
michael@0 27
michael@0 28 void Lock::AssertAcquired() const {
michael@0 29 DCHECK(owned_by_thread_);
michael@0 30 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
michael@0 31 }
michael@0 32
michael@0 33 void Lock::CheckHeldAndUnmark() {
michael@0 34 DCHECK(owned_by_thread_);
michael@0 35 DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
michael@0 36 owned_by_thread_ = false;
michael@0 37 owning_thread_id_ = kNoThreadId;
michael@0 38 }
michael@0 39
michael@0 40 void Lock::CheckUnheldAndMark() {
michael@0 41 DCHECK(!owned_by_thread_);
michael@0 42 owned_by_thread_ = true;
michael@0 43 owning_thread_id_ = PlatformThread::CurrentId();
michael@0 44 }
michael@0 45
michael@0 46 } // namespace base
michael@0 47
michael@0 48 #endif // NDEBUG

mercurial