ActorChild.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 "mozilla/dom/cache/ActorChild.h"
  6. #include "mozilla/dom/cache/CacheWorkerHolder.h"
  7. #include "nsThreadUtils.h"
  8. namespace mozilla {
  9. namespace dom {
  10. namespace cache {
  11. void
  12. ActorChild::SetWorkerHolder(CacheWorkerHolder* aWorkerHolder)
  13. {
  14. // Some of the Cache actors can have multiple DOM objects associated with
  15. // them. In this case the workerHolder will be added multiple times. This is
  16. // permitted, but the workerHolder should be the same each time.
  17. if (mWorkerHolder) {
  18. MOZ_DIAGNOSTIC_ASSERT(mWorkerHolder == aWorkerHolder);
  19. return;
  20. }
  21. mWorkerHolder = aWorkerHolder;
  22. if (mWorkerHolder) {
  23. mWorkerHolder->AddActor(this);
  24. }
  25. }
  26. void
  27. ActorChild::RemoveWorkerHolder()
  28. {
  29. MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
  30. if (mWorkerHolder) {
  31. mWorkerHolder->RemoveActor(this);
  32. mWorkerHolder = nullptr;
  33. }
  34. }
  35. CacheWorkerHolder*
  36. ActorChild::GetWorkerHolder() const
  37. {
  38. return mWorkerHolder;
  39. }
  40. bool
  41. ActorChild::WorkerHolderNotified() const
  42. {
  43. return mWorkerHolder && mWorkerHolder->Notified();
  44. }
  45. ActorChild::ActorChild()
  46. {
  47. }
  48. ActorChild::~ActorChild()
  49. {
  50. MOZ_DIAGNOSTIC_ASSERT(!mWorkerHolder);
  51. }
  52. } // namespace cache
  53. } // namespace dom
  54. } // namespace mozilla