michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Local Includes michael@0: #include "nsSHTransaction.h" michael@0: #include "nsISHEntry.h" michael@0: michael@0: //***************************************************************************** michael@0: //*** nsSHTransaction: Object Management michael@0: //***************************************************************************** michael@0: michael@0: nsSHTransaction::nsSHTransaction() : mPersist(true), mPrev(nullptr) michael@0: { michael@0: } michael@0: michael@0: michael@0: nsSHTransaction::~nsSHTransaction() michael@0: { michael@0: } michael@0: michael@0: //***************************************************************************** michael@0: // nsSHTransaction: nsISupports michael@0: //***************************************************************************** michael@0: michael@0: NS_IMPL_ADDREF(nsSHTransaction) michael@0: NS_IMPL_RELEASE(nsSHTransaction) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN(nsSHTransaction) michael@0: NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction) michael@0: NS_INTERFACE_MAP_ENTRY(nsISHTransaction) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: //***************************************************************************** michael@0: // nsSHTransaction: nsISHTransaction michael@0: //***************************************************************************** michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::Create(nsISHEntry* aSHEntry, nsISHTransaction* aPrev) michael@0: { michael@0: SetSHEntry(aSHEntry); michael@0: if(aPrev) michael@0: aPrev->SetNext(this); michael@0: michael@0: SetPrev(aPrev); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::GetSHEntry(nsISHEntry ** aResult) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aResult); michael@0: *aResult = mSHEntry; michael@0: NS_IF_ADDREF(*aResult); michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::SetSHEntry(nsISHEntry * aSHEntry) michael@0: { michael@0: mSHEntry = aSHEntry; michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::GetNext(nsISHTransaction * * aResult) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aResult); michael@0: *aResult = mNext; michael@0: NS_IF_ADDREF(*aResult); michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::SetNext(nsISHTransaction * aNext) michael@0: { michael@0: if (aNext) { michael@0: NS_ENSURE_SUCCESS(aNext->SetPrev(this), NS_ERROR_FAILURE); michael@0: } michael@0: michael@0: mNext = aNext; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::SetPrev(nsISHTransaction * aPrev) michael@0: { michael@0: /* This is weak reference to parent. Do not Addref it */ michael@0: mPrev = aPrev; michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: nsSHTransaction::GetPrev(nsISHTransaction ** aResult) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aResult); michael@0: *aResult = mPrev; michael@0: NS_IF_ADDREF(*aResult); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::SetPersist(bool aPersist) michael@0: { michael@0: mPersist = aPersist; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsSHTransaction::GetPersist(bool* aPersist) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aPersist); michael@0: michael@0: *aPersist = mPersist; michael@0: return NS_OK; michael@0: }