no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / fetch / FetchParent.h
blobe373d93b73920a3d3796a3a9eebaed8e48059c67
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_fetchParent_h__
6 #define mozilla_dom_fetchParent_h__
8 #include "mozilla/Maybe.h"
9 #include "mozilla/MozPromise.h"
10 #include "mozilla/Mutex.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/dom/PFetchParent.h"
13 #include "mozilla/dom/SafeRefPtr.h"
14 #include "mozilla/ipc/PBackgroundSharedTypes.h"
15 #include "mozilla/net/NeckoChannelParams.h"
16 #include "nsCOMPtr.h"
17 #include "nsIContentSecurityPolicy.h"
18 #include "nsID.h"
19 #include "nsISerialEventTarget.h"
20 #include "nsString.h"
21 #include "nsTHashMap.h"
23 namespace mozilla::dom {
25 class ClientInfo;
26 class FetchServicePromises;
27 class InternalRequest;
28 class InternalResponse;
29 class ServiceWorkerDescriptor;
31 class FetchParent final : public PFetchParent {
32 friend class PFetchParent;
34 public:
35 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FetchParent, override);
37 mozilla::ipc::IPCResult RecvFetchOp(FetchOpArgs&& aArgs);
39 mozilla::ipc::IPCResult RecvAbortFetchOp();
41 FetchParent();
43 static RefPtr<FetchParent> GetActorByID(const nsID& aID);
45 void OnResponseAvailableInternal(SafeRefPtr<InternalResponse>&& aResponse);
47 void OnResponseEnd(const ResponseEndArgs& aArgs);
49 void OnDataAvailable();
51 void OnFlushConsoleReport(
52 const nsTArray<net::ConsoleReportCollected>& aReports);
54 class FetchParentCSPEventListener final : public nsICSPEventListener {
55 public:
56 NS_DECL_THREADSAFE_ISUPPORTS
57 NS_DECL_NSICSPEVENTLISTENER
59 FetchParentCSPEventListener(const nsID& aActorID,
60 nsCOMPtr<nsISerialEventTarget> aEventTarget);
62 private:
63 ~FetchParentCSPEventListener() = default;
65 nsID mActorID;
66 nsCOMPtr<nsISerialEventTarget> mEventTarget;
69 nsICSPEventListener* GetCSPEventListener();
71 void OnCSPViolationEvent(const nsAString& aJSON);
73 void OnReportPerformanceTiming(const ResponseTiming&& aTiming);
75 void OnNotifyNetworkMonitorAlternateStack(uint64_t aChannelID);
77 private:
78 ~FetchParent();
80 void ActorDestroy(ActorDestroyReason aReason) override;
82 // The map of FetchParent and ID. Should only access in background thread.
83 static nsTHashMap<nsIDHashKey, RefPtr<FetchParent>> sActorTable;
85 // The unique ID of the FetchParent
86 nsID mID;
87 SafeRefPtr<InternalRequest> mRequest;
88 RefPtr<FetchServicePromises> mResponsePromises;
89 RefPtr<GenericPromise::Private> mPromise;
90 PrincipalInfo mPrincipalInfo;
91 nsCString mWorkerScript;
92 Maybe<ClientInfo> mClientInfo;
93 Maybe<ServiceWorkerDescriptor> mController;
94 Maybe<CookieJarSettingsArgs> mCookieJarSettings;
95 nsCOMPtr<nsICSPEventListener> mCSPEventListener;
96 bool mNeedOnDataAvailable{false};
97 bool mHasCSPEventListener{false};
98 bool mExtendForCSPEventListener{false};
99 uint64_t mAssociatedBrowsingContextID{0};
101 Atomic<bool> mIsDone{false};
102 Atomic<bool> mActorDestroyed{false};
104 nsCOMPtr<nsISerialEventTarget> mBackgroundEventTarget;
107 } // namespace mozilla::dom
109 #endif