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.

     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 #if !defined(NDEBUG)
    11 #include "base/synchronization/lock.h"
    12 #include "base/logging.h"
    14 namespace base {
    16 const PlatformThreadId kNoThreadId = static_cast<PlatformThreadId>(0);
    18 Lock::Lock() : lock_() {
    19   owned_by_thread_ = false;
    20   owning_thread_id_ = kNoThreadId;
    21 }
    23 Lock::~Lock() {
    24   DCHECK(!owned_by_thread_);
    25   DCHECK_EQ(kNoThreadId, owning_thread_id_);
    26 }
    28 void Lock::AssertAcquired() const {
    29   DCHECK(owned_by_thread_);
    30   DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
    31 }
    33 void Lock::CheckHeldAndUnmark() {
    34   DCHECK(owned_by_thread_);
    35   DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
    36   owned_by_thread_ = false;
    37   owning_thread_id_ = kNoThreadId;
    38 }
    40 void Lock::CheckUnheldAndMark() {
    41   DCHECK(!owned_by_thread_);
    42   owned_by_thread_ = true;
    43   owning_thread_id_ = PlatformThread::CurrentId();
    44 }
    46 }  // namespace base
    48 #endif  // NDEBUG

mercurial