nsSHTransaction.cpp 2.0 KB

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