CacheOpParent.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_CacheOpParent_h
  6. #define mozilla_dom_cache_CacheOpParent_h
  7. #include "mozilla/dom/cache/Manager.h"
  8. #include "mozilla/dom/cache/PCacheOpParent.h"
  9. #include "mozilla/dom/cache/PrincipalVerifier.h"
  10. #include "nsTArray.h"
  11. namespace mozilla {
  12. namespace ipc {
  13. class PBackgroundParent;
  14. } // namespace ipc
  15. namespace dom {
  16. namespace cache {
  17. class CacheOpParent final : public PCacheOpParent
  18. , public PrincipalVerifier::Listener
  19. , public Manager::Listener
  20. {
  21. // to allow use of convenience overrides
  22. using Manager::Listener::OnOpComplete;
  23. public:
  24. CacheOpParent(mozilla::ipc::PBackgroundParent* aIpcManager, CacheId aCacheId,
  25. const CacheOpArgs& aOpArgs);
  26. CacheOpParent(mozilla::ipc::PBackgroundParent* aIpcManager,
  27. Namespace aNamespace, const CacheOpArgs& aOpArgs);
  28. ~CacheOpParent();
  29. void
  30. Execute(ManagerId* aManagerId);
  31. void
  32. Execute(cache::Manager* aManager);
  33. void
  34. WaitForVerification(PrincipalVerifier* aVerifier);
  35. private:
  36. // PCacheOpParent methods
  37. virtual void
  38. ActorDestroy(ActorDestroyReason aReason) override;
  39. // PrincipalVerifier::Listener methods
  40. virtual void
  41. OnPrincipalVerified(nsresult aRv, ManagerId* aManagerId) override;
  42. // Manager::Listener methods
  43. virtual void
  44. OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult,
  45. CacheId aOpenedCacheId,
  46. const nsTArray<SavedResponse>& aSavedResponseList,
  47. const nsTArray<SavedRequest>& aSavedRequestList,
  48. StreamList* aStreamList) override;
  49. // utility methods
  50. already_AddRefed<nsIInputStream>
  51. DeserializeCacheStream(const CacheReadStreamOrVoid& aStreamOrVoid);
  52. mozilla::ipc::PBackgroundParent* mIpcManager;
  53. const CacheId mCacheId;
  54. const Namespace mNamespace;
  55. const CacheOpArgs mOpArgs;
  56. RefPtr<cache::Manager> mManager;
  57. RefPtr<PrincipalVerifier> mVerifier;
  58. NS_DECL_OWNINGTHREAD
  59. };
  60. } // namespace cache
  61. } // namespace dom
  62. } // namespace mozilla
  63. #endif // mozilla_dom_cache_CacheOpParent_h