CacheOpChild.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef mozilla_dom_cache_CacheOpChild_h
  6. #define mozilla_dom_cache_CacheOpChild_h
  7. #include "mozilla/dom/cache/ActorChild.h"
  8. #include "mozilla/dom/cache/PCacheOpChild.h"
  9. #include "mozilla/dom/cache/TypeUtils.h"
  10. #include "mozilla/RefPtr.h"
  11. class nsIGlobalObject;
  12. namespace mozilla {
  13. namespace dom {
  14. class Promise;
  15. namespace cache {
  16. class CacheOpChild final : public PCacheOpChild
  17. , public ActorChild
  18. , public TypeUtils
  19. {
  20. friend class CacheChild;
  21. friend class CacheStorageChild;
  22. private:
  23. // This class must be constructed by CacheChild or CacheStorageChild using
  24. // their ExecuteOp() factory method.
  25. CacheOpChild(CacheWorkerHolder* aWorkerHolder, nsIGlobalObject* aGlobal,
  26. nsISupports* aParent, Promise* aPromise);
  27. ~CacheOpChild();
  28. // PCacheOpChild methods
  29. virtual void
  30. ActorDestroy(ActorDestroyReason aReason) override;
  31. virtual bool
  32. Recv__delete__(const ErrorResult& aRv, const CacheOpResult& aResult) override;
  33. // ActorChild methods
  34. virtual void
  35. StartDestroy() override;
  36. // TypeUtils methods
  37. virtual nsIGlobalObject*
  38. GetGlobalObject() const override;
  39. #ifdef DEBUG
  40. virtual void
  41. AssertOwningThread() const override;
  42. #endif
  43. virtual mozilla::ipc::PBackgroundChild*
  44. GetIPCManager() override;
  45. // Utility methods
  46. void
  47. HandleResponse(const CacheResponseOrVoid& aResponseOrVoid);
  48. void
  49. HandleResponseList(const nsTArray<CacheResponse>& aResponseList);
  50. void
  51. HandleRequestList(const nsTArray<CacheRequest>& aRequestList);
  52. nsCOMPtr<nsIGlobalObject> mGlobal;
  53. // Hold the parent Cache or CacheStorage object alive until this async
  54. // operation completes.
  55. nsCOMPtr<nsISupports> mParent;
  56. RefPtr<Promise> mPromise;
  57. NS_DECL_OWNINGTHREAD
  58. };
  59. } // namespace cache
  60. } // namespace dom
  61. } // namespace mozilla
  62. #endif // mozilla_dom_cache_CacheOpChild_h