1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_fetchChild_h__
6 #define mozilla_dom_fetchChild_h__
8 #include "mozilla/dom/AbortSignal.h"
9 #include "mozilla/dom/AbortFollower.h"
10 #include "mozilla/dom/FlippedOnce.h"
11 #include "mozilla/dom/PFetchChild.h"
12 #include "mozilla/dom/SerializedStackHolder.h"
13 #include "nsIConsoleReportCollector.h"
14 #include "nsIContentSecurityPolicy.h"
15 #include "nsISupports.h"
16 #include "nsIWorkerChannelInfo.h"
18 namespace mozilla::dom
{
21 class ThreadSafeWorkerRef
;
25 class FetchChild final
: public PFetchChild
, public AbortFollower
{
26 friend class PFetchChild
;
29 NS_DECL_THREADSAFE_ISUPPORTS
31 mozilla::ipc::IPCResult
Recv__delete__(const nsresult
&& aResult
);
33 mozilla::ipc::IPCResult
RecvOnResponseAvailableInternal(
34 ParentToChildInternalResponse
&& aResponse
);
36 mozilla::ipc::IPCResult
RecvOnResponseEnd(ResponseEndArgs
&& aArgs
);
38 mozilla::ipc::IPCResult
RecvOnDataAvailable();
40 mozilla::ipc::IPCResult
RecvOnFlushConsoleReport(
41 nsTArray
<net::ConsoleReportCollected
>&& aReports
);
43 mozilla::ipc::IPCResult
RecvOnCSPViolationEvent(const nsAString
& aJSon
);
45 mozilla::ipc::IPCResult
RecvOnReportPerformanceTiming(
46 ResponseTiming
&& aTiming
);
48 mozilla::ipc::IPCResult
RecvOnNotifyNetworkMonitorAlternateStack(
51 void SetCSPEventListener(nsICSPEventListener
* aListener
);
53 static RefPtr
<FetchChild
> Create(WorkerPrivate
* aWorkerPrivate
,
54 RefPtr
<Promise
> aPromise
,
55 RefPtr
<AbortSignalImpl
> aSignalImpl
,
56 RefPtr
<FetchObserver
> aObserver
);
58 FetchChild(RefPtr
<Promise
>&& aPromise
, RefPtr
<AbortSignalImpl
>&& aSignalImpl
,
59 RefPtr
<FetchObserver
>&& aObserver
);
62 void RunAbortAlgorithm() override
;
64 void DoFetchOp(const FetchOpArgs
& aArgs
);
66 void SetOriginStack(UniquePtr
<SerializedStackHolder
>&& aStack
) {
67 MOZ_ASSERT(!mOriginStack
);
68 mOriginStack
= std::move(aStack
);
72 ~FetchChild() = default;
74 // WorkerPrivate shutdown callback.
76 void ActorDestroy(ActorDestroyReason aReason
) override
;
78 RefPtr
<ThreadSafeWorkerRef
> mWorkerRef
;
79 RefPtr
<Promise
> mPromise
;
80 RefPtr
<AbortSignalImpl
> mSignalImpl
;
81 RefPtr
<FetchObserver
> mFetchObserver
;
82 UniquePtr
<SerializedStackHolder
> mOriginStack
;
83 nsCOMPtr
<nsICSPEventListener
> mCSPEventListener
;
84 nsCOMPtr
<nsIConsoleReportCollector
> mReporter
;
85 FlippedOnce
<false> mIsShutdown
;
86 nsCOMPtr
<nsIWorkerChannelInfo
> mWorkerChannelInfo
;
89 } // namespace mozilla::dom