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_fetcheventopparent_h__
8 #define mozilla_dom_fetcheventopparent_h__
10 #include "nsISupports.h"
12 #include "mozilla/dom/FetchEventOpProxyParent.h"
13 #include "mozilla/dom/PFetchEventOpParent.h"
15 namespace mozilla::dom
{
17 class FetchEventOpParent final
: public PFetchEventOpParent
{
18 friend class PFetchEventOpParent
;
21 NS_INLINE_DECL_REFCOUNTING(FetchEventOpParent
)
23 FetchEventOpParent() = default;
25 // Transition from the Pending state to the Started state. Returns the preload
26 // response and response end args, if it has already arrived.
27 std::tuple
<Maybe
<ParentToParentInternalResponse
>, Maybe
<ResponseEndArgs
>>
29 MovingNotNull
<RefPtr
<FetchEventOpProxyParent
>> aFetchEventOpProxyParent
);
31 // Transition from the Started state to the Finished state.
35 ~FetchEventOpParent() = default;
39 mozilla::ipc::IPCResult
RecvPreloadResponse(
40 ParentToParentInternalResponse
&& aResponse
);
42 mozilla::ipc::IPCResult
RecvPreloadResponseTiming(ResponseTiming
&& aTiming
);
44 mozilla::ipc::IPCResult
RecvPreloadResponseEnd(ResponseEndArgs
&& aArgs
);
46 void ActorDestroy(ActorDestroyReason
) override
;
49 Maybe
<ParentToParentInternalResponse
> mPreloadResponse
;
50 Maybe
<ResponseTiming
> mTiming
;
51 Maybe
<ResponseEndArgs
> mEndArgs
;
55 NotNull
<RefPtr
<FetchEventOpProxyParent
>> mFetchEventOpProxyParent
;
60 using State
= Variant
<Pending
, Started
, Finished
>;
62 // Tracks the state of the fetch event.
64 // Pending: the fetch event is waiting in RemoteWorkerController::mPendingOps
65 // and if the preload response arrives, we have to save it.
66 // Started: the FetchEventOpProxyParent has been created, and if the preload
67 // response arrives then we should forward it.
68 // Finished: the response has been propagated to the parent process, if the
69 // preload response arrives now then we simply drop it.
70 State mState
= AsVariant(Pending());
73 } // namespace mozilla::dom
75 #endif // mozilla_dom_fetcheventopparent_h__