Tue, 06 Jan 2015 21:39:09 +0100
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.
| michael@0 | 1 | #include "precompiled.h" |
| michael@0 | 2 | // |
| michael@0 | 3 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| michael@0 | 4 | // Use of this source code is governed by a BSD-style license that can be |
| michael@0 | 5 | // found in the LICENSE file. |
| michael@0 | 6 | // |
| michael@0 | 7 | |
| michael@0 | 8 | // RefCountObject.cpp: Defines the gl::RefCountObject base class that provides |
| michael@0 | 9 | // lifecycle support for GL objects using the traditional BindObject scheme, but |
| michael@0 | 10 | // that need to be reference counted for correct cross-context deletion. |
| michael@0 | 11 | // (Concretely, textures, buffers and renderbuffers.) |
| michael@0 | 12 | |
| michael@0 | 13 | #include "RefCountObject.h" |
| michael@0 | 14 | |
| michael@0 | 15 | RefCountObject::RefCountObject(GLuint id) |
| michael@0 | 16 | { |
| michael@0 | 17 | mId = id; |
| michael@0 | 18 | mRefCount = 0; |
| michael@0 | 19 | } |
| michael@0 | 20 | |
| michael@0 | 21 | RefCountObject::~RefCountObject() |
| michael@0 | 22 | { |
| michael@0 | 23 | ASSERT(mRefCount == 0); |
| michael@0 | 24 | } |
| michael@0 | 25 | |
| michael@0 | 26 | void RefCountObject::addRef() const |
| michael@0 | 27 | { |
| michael@0 | 28 | mRefCount++; |
| michael@0 | 29 | } |
| michael@0 | 30 | |
| michael@0 | 31 | void RefCountObject::release() const |
| michael@0 | 32 | { |
| michael@0 | 33 | ASSERT(mRefCount > 0); |
| michael@0 | 34 | |
| michael@0 | 35 | if (--mRefCount == 0) |
| michael@0 | 36 | { |
| michael@0 | 37 | delete this; |
| michael@0 | 38 | } |
| michael@0 | 39 | } |
| michael@0 | 40 | |
| michael@0 | 41 | void RefCountObjectBindingPointer::set(RefCountObject *newObject) |
| michael@0 | 42 | { |
| michael@0 | 43 | // addRef first in case newObject == mObject and this is the last reference to it. |
| michael@0 | 44 | if (newObject != NULL) newObject->addRef(); |
| michael@0 | 45 | if (mObject != NULL) mObject->release(); |
| michael@0 | 46 | |
| michael@0 | 47 | mObject = newObject; |
| michael@0 | 48 | } |