Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / cache / CacheOpParent.h
bloba1a6308243e2e6c57adb4f09aaa20a766761fdff
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/. */
7 #ifndef mozilla_dom_cache_CacheOpParent_h
8 #define mozilla_dom_cache_CacheOpParent_h
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"
15 namespace mozilla {
16 namespace ipc {
17 class PBackgroundParent;
18 } // namespace ipc
19 namespace dom::cache {
21 class CacheOpParent final : public PCacheOpParent,
22 public PrincipalVerifier::Listener,
23 public Manager::Listener {
24 // to allow use of convenience overrides
25 using Manager::Listener::OnOpComplete;
27 public:
28 CacheOpParent(mozilla::ipc::PBackgroundParent* aIpcManager, CacheId aCacheId,
29 const CacheOpArgs& aOpArgs);
30 CacheOpParent(mozilla::ipc::PBackgroundParent* aIpcManager,
31 Namespace aNamespace, const CacheOpArgs& aOpArgs);
33 void Execute(const SafeRefPtr<ManagerId>& aManagerId);
35 void Execute(SafeRefPtr<cache::Manager> aManager);
37 void WaitForVerification(PrincipalVerifier* aVerifier);
39 NS_INLINE_DECL_REFCOUNTING(CacheOpParent, override)
41 private:
42 ~CacheOpParent();
44 // PCacheOpParent methods
45 virtual void ActorDestroy(ActorDestroyReason aReason) override;
47 // PrincipalVerifier::Listener methods
48 virtual void OnPrincipalVerified(
49 nsresult aRv, const SafeRefPtr<ManagerId>& aManagerId) override;
51 // Manager::Listener methods
52 virtual void OnOpComplete(ErrorResult&& aRv, const CacheOpResult& aResult,
53 CacheId aOpenedCacheId,
54 const Maybe<StreamInfo>& aStreamInfo) override;
56 // utility methods
57 already_AddRefed<nsIInputStream> DeserializeCacheStream(
58 const Maybe<CacheReadStream>& aMaybeStream);
60 void ProcessCrossOriginResourcePolicyHeader(
61 ErrorResult& aRv, const nsTArray<SavedResponse>& aResponses);
63 mozilla::ipc::PBackgroundParent* mIpcManager;
64 const CacheId mCacheId;
65 const Namespace mNamespace;
66 const CacheOpArgs mOpArgs;
67 SafeRefPtr<cache::Manager> mManager;
68 RefPtr<PrincipalVerifier> mVerifier;
71 } // namespace dom::cache
72 } // namespace mozilla
74 #endif // mozilla_dom_cache_CacheOpParent_h