1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_cache_CacheOpParent_h 8 #define mozilla_dom_cache_CacheOpParent_h 9 10 #include "mozilla/dom/cache/Manager.h" 11 #include "mozilla/dom/cache/PCacheOpParent.h" 12 #include "mozilla/dom/cache/PrincipalVerifier.h" 13 #include "nsTArray.h" 14 15 namespace mozilla { 16 namespace ipc { 17 class PBackgroundParent; 18 } // namespace ipc 19 namespace dom { 20 namespace cache { 21 22 class CacheOpParent final : public PCacheOpParent 23 , public PrincipalVerifier::Listener 24 , public Manager::Listener 25 { 26 // to allow use of convenience overrides 27 using Manager::Listener::OnOpComplete; 28 29 public: 30 CacheOpParent(mozilla::ipc::PBackgroundParent* aIpcManager, CacheId aCacheId, 31 const CacheOpArgs& aOpArgs); 32 CacheOpParent(mozilla::ipc::PBackgroundParent* aIpcManager, 33 Namespace aNamespace, const CacheOpArgs& aOpArgs); 34 ~CacheOpParent(); 35 36 void 37 Execute(ManagerId* aManagerId); 38 39 void 40 Execute(cache::Manager* aManager); 41 42 void 43 WaitForVerification(PrincipalVerifier* aVerifier); 44 45 private: 46 // PCacheOpParent methods 47 virtual void 48 ActorDestroy(ActorDestroyReason aReason) override; 49 50 // PrincipalVerifier::Listener methods 51 virtual void 52 OnPrincipalVerified(nsresult aRv, ManagerId* aManagerId) override; 53 54 // Manager::Listener methods 55 virtual void 56 OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult, 57 CacheId aOpenedCacheId, 58 const nsTArray<SavedResponse>& aSavedResponseList, 59 const nsTArray<SavedRequest>& aSavedRequestList, 60 StreamList* aStreamList) override; 61 62 // utility methods 63 already_AddRefed<nsIInputStream> 64 DeserializeCacheStream(const CacheReadStreamOrVoid& aStreamOrVoid); 65 66 mozilla::ipc::PBackgroundParent* mIpcManager; 67 const CacheId mCacheId; 68 const Namespace mNamespace; 69 const CacheOpArgs mOpArgs; 70 RefPtr<cache::Manager> mManager; 71 RefPtr<PrincipalVerifier> mVerifier; 72 73 NS_DECL_OWNINGTHREAD 74 }; 75 76 } // namespace cache 77 } // namespace dom 78 } // namespace mozilla 79 80 #endif // mozilla_dom_cache_CacheOpParent_h 81