From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- dom/fetch/FetchParent.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 dom/fetch/FetchParent.h (limited to 'dom/fetch/FetchParent.h') diff --git a/dom/fetch/FetchParent.h b/dom/fetch/FetchParent.h new file mode 100644 index 0000000000..e373d93b73 --- /dev/null +++ b/dom/fetch/FetchParent.h @@ -0,0 +1,109 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_fetchParent_h__ +#define mozilla_dom_fetchParent_h__ + +#include "mozilla/Maybe.h" +#include "mozilla/MozPromise.h" +#include "mozilla/Mutex.h" +#include "mozilla/RefPtr.h" +#include "mozilla/dom/PFetchParent.h" +#include "mozilla/dom/SafeRefPtr.h" +#include "mozilla/ipc/PBackgroundSharedTypes.h" +#include "mozilla/net/NeckoChannelParams.h" +#include "nsCOMPtr.h" +#include "nsIContentSecurityPolicy.h" +#include "nsID.h" +#include "nsISerialEventTarget.h" +#include "nsString.h" +#include "nsTHashMap.h" + +namespace mozilla::dom { + +class ClientInfo; +class FetchServicePromises; +class InternalRequest; +class InternalResponse; +class ServiceWorkerDescriptor; + +class FetchParent final : public PFetchParent { + friend class PFetchParent; + + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FetchParent, override); + + mozilla::ipc::IPCResult RecvFetchOp(FetchOpArgs&& aArgs); + + mozilla::ipc::IPCResult RecvAbortFetchOp(); + + FetchParent(); + + static RefPtr GetActorByID(const nsID& aID); + + void OnResponseAvailableInternal(SafeRefPtr&& aResponse); + + void OnResponseEnd(const ResponseEndArgs& aArgs); + + void OnDataAvailable(); + + void OnFlushConsoleReport( + const nsTArray& aReports); + + class FetchParentCSPEventListener final : public nsICSPEventListener { + public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSICSPEVENTLISTENER + + FetchParentCSPEventListener(const nsID& aActorID, + nsCOMPtr aEventTarget); + + private: + ~FetchParentCSPEventListener() = default; + + nsID mActorID; + nsCOMPtr mEventTarget; + }; + + nsICSPEventListener* GetCSPEventListener(); + + void OnCSPViolationEvent(const nsAString& aJSON); + + void OnReportPerformanceTiming(const ResponseTiming&& aTiming); + + void OnNotifyNetworkMonitorAlternateStack(uint64_t aChannelID); + + private: + ~FetchParent(); + + void ActorDestroy(ActorDestroyReason aReason) override; + + // The map of FetchParent and ID. Should only access in background thread. + static nsTHashMap> sActorTable; + + // The unique ID of the FetchParent + nsID mID; + SafeRefPtr mRequest; + RefPtr mResponsePromises; + RefPtr mPromise; + PrincipalInfo mPrincipalInfo; + nsCString mWorkerScript; + Maybe mClientInfo; + Maybe mController; + Maybe mCookieJarSettings; + nsCOMPtr mCSPEventListener; + bool mNeedOnDataAvailable{false}; + bool mHasCSPEventListener{false}; + bool mExtendForCSPEventListener{false}; + uint64_t mAssociatedBrowsingContextID{0}; + + Atomic mIsDone{false}; + Atomic mActorDestroyed{false}; + + nsCOMPtr mBackgroundEventTarget; +}; + +} // namespace mozilla::dom + +#endif -- cgit v1.2.3