QuotaObject.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_quota_quotaobject_h__
  6. #define mozilla_dom_quota_quotaobject_h__
  7. #include "mozilla/dom/quota/QuotaCommon.h"
  8. #include "nsDataHashtable.h"
  9. #include "PersistenceType.h"
  10. BEGIN_QUOTA_NAMESPACE
  11. class OriginInfo;
  12. class QuotaManager;
  13. class QuotaObject
  14. {
  15. friend class OriginInfo;
  16. friend class QuotaManager;
  17. public:
  18. void
  19. AddRef();
  20. void
  21. Release();
  22. const nsAString&
  23. Path() const
  24. {
  25. return mPath;
  26. }
  27. bool
  28. MaybeUpdateSize(int64_t aSize, bool aTruncate);
  29. void
  30. DisableQuotaCheck();
  31. void
  32. EnableQuotaCheck();
  33. private:
  34. QuotaObject(OriginInfo* aOriginInfo, const nsAString& aPath, int64_t aSize)
  35. : mOriginInfo(aOriginInfo)
  36. , mPath(aPath)
  37. , mSize(aSize)
  38. , mQuotaCheckDisabled(false)
  39. {
  40. MOZ_COUNT_CTOR(QuotaObject);
  41. }
  42. ~QuotaObject()
  43. {
  44. MOZ_COUNT_DTOR(QuotaObject);
  45. }
  46. already_AddRefed<QuotaObject>
  47. LockedAddRef()
  48. {
  49. AssertCurrentThreadOwnsQuotaMutex();
  50. ++mRefCnt;
  51. RefPtr<QuotaObject> result = dont_AddRef(this);
  52. return result.forget();
  53. }
  54. mozilla::ThreadSafeAutoRefCnt mRefCnt;
  55. OriginInfo* mOriginInfo;
  56. nsString mPath;
  57. int64_t mSize;
  58. bool mQuotaCheckDisabled;
  59. };
  60. END_QUOTA_NAMESPACE
  61. #endif // mozilla_dom_quota_quotaobject_h__