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 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | // Local Includes |
michael@0 | 8 | #include "nsSHTransaction.h" |
michael@0 | 9 | #include "nsISHEntry.h" |
michael@0 | 10 | |
michael@0 | 11 | //***************************************************************************** |
michael@0 | 12 | //*** nsSHTransaction: Object Management |
michael@0 | 13 | //***************************************************************************** |
michael@0 | 14 | |
michael@0 | 15 | nsSHTransaction::nsSHTransaction() : mPersist(true), mPrev(nullptr) |
michael@0 | 16 | { |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | nsSHTransaction::~nsSHTransaction() |
michael@0 | 21 | { |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | //***************************************************************************** |
michael@0 | 25 | // nsSHTransaction: nsISupports |
michael@0 | 26 | //***************************************************************************** |
michael@0 | 27 | |
michael@0 | 28 | NS_IMPL_ADDREF(nsSHTransaction) |
michael@0 | 29 | NS_IMPL_RELEASE(nsSHTransaction) |
michael@0 | 30 | |
michael@0 | 31 | NS_INTERFACE_MAP_BEGIN(nsSHTransaction) |
michael@0 | 32 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction) |
michael@0 | 33 | NS_INTERFACE_MAP_ENTRY(nsISHTransaction) |
michael@0 | 34 | NS_INTERFACE_MAP_END |
michael@0 | 35 | |
michael@0 | 36 | //***************************************************************************** |
michael@0 | 37 | // nsSHTransaction: nsISHTransaction |
michael@0 | 38 | //***************************************************************************** |
michael@0 | 39 | |
michael@0 | 40 | NS_IMETHODIMP |
michael@0 | 41 | nsSHTransaction::Create(nsISHEntry* aSHEntry, nsISHTransaction* aPrev) |
michael@0 | 42 | { |
michael@0 | 43 | SetSHEntry(aSHEntry); |
michael@0 | 44 | if(aPrev) |
michael@0 | 45 | aPrev->SetNext(this); |
michael@0 | 46 | |
michael@0 | 47 | SetPrev(aPrev); |
michael@0 | 48 | return NS_OK; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | NS_IMETHODIMP |
michael@0 | 52 | nsSHTransaction::GetSHEntry(nsISHEntry ** aResult) |
michael@0 | 53 | { |
michael@0 | 54 | NS_ENSURE_ARG_POINTER(aResult); |
michael@0 | 55 | *aResult = mSHEntry; |
michael@0 | 56 | NS_IF_ADDREF(*aResult); |
michael@0 | 57 | return NS_OK; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | NS_IMETHODIMP |
michael@0 | 62 | nsSHTransaction::SetSHEntry(nsISHEntry * aSHEntry) |
michael@0 | 63 | { |
michael@0 | 64 | mSHEntry = aSHEntry; |
michael@0 | 65 | return NS_OK; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | |
michael@0 | 69 | NS_IMETHODIMP |
michael@0 | 70 | nsSHTransaction::GetNext(nsISHTransaction * * aResult) |
michael@0 | 71 | { |
michael@0 | 72 | NS_ENSURE_ARG_POINTER(aResult); |
michael@0 | 73 | *aResult = mNext; |
michael@0 | 74 | NS_IF_ADDREF(*aResult); |
michael@0 | 75 | return NS_OK; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | |
michael@0 | 79 | NS_IMETHODIMP |
michael@0 | 80 | nsSHTransaction::SetNext(nsISHTransaction * aNext) |
michael@0 | 81 | { |
michael@0 | 82 | if (aNext) { |
michael@0 | 83 | NS_ENSURE_SUCCESS(aNext->SetPrev(this), NS_ERROR_FAILURE); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | mNext = aNext; |
michael@0 | 87 | return NS_OK; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | NS_IMETHODIMP |
michael@0 | 91 | nsSHTransaction::SetPrev(nsISHTransaction * aPrev) |
michael@0 | 92 | { |
michael@0 | 93 | /* This is weak reference to parent. Do not Addref it */ |
michael@0 | 94 | mPrev = aPrev; |
michael@0 | 95 | return NS_OK; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | nsresult |
michael@0 | 99 | nsSHTransaction::GetPrev(nsISHTransaction ** aResult) |
michael@0 | 100 | { |
michael@0 | 101 | NS_ENSURE_ARG_POINTER(aResult); |
michael@0 | 102 | *aResult = mPrev; |
michael@0 | 103 | NS_IF_ADDREF(*aResult); |
michael@0 | 104 | return NS_OK; |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | NS_IMETHODIMP |
michael@0 | 108 | nsSHTransaction::SetPersist(bool aPersist) |
michael@0 | 109 | { |
michael@0 | 110 | mPersist = aPersist; |
michael@0 | 111 | return NS_OK; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | NS_IMETHODIMP |
michael@0 | 115 | nsSHTransaction::GetPersist(bool* aPersist) |
michael@0 | 116 | { |
michael@0 | 117 | NS_ENSURE_ARG_POINTER(aPersist); |
michael@0 | 118 | |
michael@0 | 119 | *aPersist = mPersist; |
michael@0 | 120 | return NS_OK; |
michael@0 | 121 | } |