dom/camera/AutoRwLock.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef RWLOCK_AUTO_ENTER_H
     6 #define RWLOCK_AUTO_ENTER_H
     8 #include "prrwlock.h"
     9 #include "mozilla/Assertions.h"
    11 class RwLockAutoEnterRead
    12 {
    13 public:
    14   RwLockAutoEnterRead(PRRWLock* aRwLock)
    15     : mRwLock(aRwLock)
    16   {
    17     MOZ_ASSERT(mRwLock);
    18     PR_RWLock_Rlock(mRwLock);
    19   }
    21   ~RwLockAutoEnterRead()
    22   {
    23     PR_RWLock_Unlock(mRwLock);
    24   }
    26 protected:
    27   PRRWLock* mRwLock;
    28 };
    30 class RwLockAutoEnterWrite
    31 {
    32 public:
    33   RwLockAutoEnterWrite(PRRWLock* aRwLock)
    34     : mRwLock(aRwLock)
    35   {
    36     MOZ_ASSERT(mRwLock);
    37     PR_RWLock_Wlock(mRwLock);
    38   }
    40   ~RwLockAutoEnterWrite()
    41   {
    42     PR_RWLock_Unlock(mRwLock);
    43   }
    45 protected:
    46   PRRWLock* mRwLock;
    47 };
    49 #endif // RWLOCK_AUTO_ENTER_H

mercurial