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"
17 class PBackgroundParent
;
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
;
29 CacheOpParent(mozilla::ipc::PBackgroundParent
* aIpcManager
, CacheId aCacheId
,
30 const CacheOpArgs
& aOpArgs
);
31 CacheOpParent(mozilla::ipc::PBackgroundParent
* aIpcManager
,
32 Namespace aNamespace
, const CacheOpArgs
& aOpArgs
);
35 void Execute(const SafeRefPtr
<ManagerId
>& aManagerId
);
37 void Execute(SafeRefPtr
<cache::Manager
> aManager
);
39 void WaitForVerification(PrincipalVerifier
* aVerifier
);
42 // PCacheOpParent methods
43 virtual void ActorDestroy(ActorDestroyReason aReason
) override
;
45 // PrincipalVerifier::Listener methods
46 virtual void OnPrincipalVerified(
47 nsresult aRv
, const SafeRefPtr
<ManagerId
>& aManagerId
) override
;
49 // Manager::Listener methods
50 virtual void OnOpComplete(ErrorResult
&& aRv
, const CacheOpResult
& aResult
,
51 CacheId aOpenedCacheId
,
52 const Maybe
<StreamInfo
>& aStreamInfo
) override
;
55 already_AddRefed
<nsIInputStream
> DeserializeCacheStream(
56 const Maybe
<CacheReadStream
>& aMaybeStream
);
58 void ProcessCrossOriginResourcePolicyHeader(
59 ErrorResult
& aRv
, const nsTArray
<SavedResponse
>& aResponses
);
61 mozilla::ipc::PBackgroundParent
* mIpcManager
;
62 const CacheId mCacheId
;
63 const Namespace mNamespace
;
64 const CacheOpArgs mOpArgs
;
65 SafeRefPtr
<cache::Manager
> mManager
;
66 RefPtr
<PrincipalVerifier
> mVerifier
;
73 } // namespace mozilla
75 #endif // mozilla_dom_cache_CacheOpParent_h