CacheOpParent.h (2512B)
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/InitializedOnce.h" 11 #include "mozilla/dom/cache/Manager.h" 12 #include "mozilla/dom/cache/PCacheOpParent.h" 13 #include "mozilla/dom/cache/PrincipalVerifier.h" 14 #include "nsTArray.h" 15 16 namespace mozilla { 17 namespace ipc { 18 class PBackgroundParent; 19 } // namespace ipc 20 namespace dom::cache { 21 22 class CacheOpParent final : public PCacheOpParent, 23 public PrincipalVerifier::Listener, 24 public Manager::Listener { 25 // to allow use of convenience overrides 26 using Manager::Listener::OnOpComplete; 27 28 public: 29 CacheOpParent(const WeakRefParentType& aIpcManager, 30 const CacheOpArgs& aOpArgs, CacheId aCacheId = INVALID_CACHE_ID, 31 Namespace aNamespace = INVALID_NAMESPACE); 32 33 void Execute(const SafeRefPtr<ManagerId>& aManagerId); 34 35 void Execute(SafeRefPtr<cache::Manager> aManager); 36 37 void WaitForVerification(PrincipalVerifier* aVerifier); 38 39 NS_INLINE_DECL_REFCOUNTING(CacheOpParent, override) 40 41 private: 42 ~CacheOpParent(); 43 44 // PCacheOpParent methods 45 virtual void ActorDestroy(ActorDestroyReason aReason) override; 46 47 // PrincipalVerifier::Listener methods 48 virtual void OnPrincipalVerified( 49 nsresult aRv, const SafeRefPtr<ManagerId>& aManagerId) override; 50 51 // Manager::Listener methods 52 virtual void OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult, 53 CacheId aOpenedCacheId, 54 const Maybe<StreamInfo>& aStreamInfo) override; 55 56 // utility methods 57 already_AddRefed<nsIInputStream> DeserializeCacheStream( 58 const Maybe<CacheReadStream>& aMaybeStream); 59 60 void ProcessCrossOriginResourcePolicyHeader( 61 ErrorResult& aRv, const nsTArray<SavedResponse>& aResponses); 62 63 mozilla::LazyInitializedOnceEarlyDestructible<const WeakRefParentType> 64 mIpcManager; 65 const CacheId mCacheId; 66 const Namespace mNamespace; 67 const CacheOpArgs mOpArgs; 68 SafeRefPtr<cache::Manager> mManager; 69 RefPtr<PrincipalVerifier> mVerifier; 70 }; 71 72 } // namespace dom::cache 73 } // namespace mozilla 74 75 #endif // mozilla_dom_cache_CacheOpParent_h