From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- netwerk/ipc/SocketProcessChild.h | 172 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 netwerk/ipc/SocketProcessChild.h (limited to 'netwerk/ipc/SocketProcessChild.h') diff --git a/netwerk/ipc/SocketProcessChild.h b/netwerk/ipc/SocketProcessChild.h new file mode 100644 index 0000000000..2f01ae47ac --- /dev/null +++ b/netwerk/ipc/SocketProcessChild.h @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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_net_SocketProcessChild_h +#define mozilla_net_SocketProcessChild_h + +#include "mozilla/net/PSocketProcessChild.h" +#include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/Mutex.h" +#include "nsRefPtrHashtable.h" +#include "nsTHashMap.h" + +namespace mozilla { +class ChildProfilerController; +} + +namespace mozilla { +namespace net { + +class ProxyAutoConfigChild; +class SocketProcessBridgeParent; +class BackgroundDataBridgeParent; + +// The IPC actor implements PSocketProcessChild in child process. +// This is allocated and kept alive by SocketProcessImpl. +class SocketProcessChild final : public PSocketProcessChild { + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SocketProcessChild) + + SocketProcessChild(); + + static SocketProcessChild* GetSingleton(); + + bool Init(mozilla::ipc::UntypedEndpoint&& aEndpoint, + const char* aParentBuildID); + + void ActorDestroy(ActorDestroyReason aWhy) override; + + mozilla::ipc::IPCResult RecvInit( + const SocketPorcessInitAttributes& aAttributes); + mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& aPref); + mozilla::ipc::IPCResult RecvRequestMemoryReport( + const uint32_t& generation, const bool& anonymize, + const bool& minimizeMemoryUsage, + const Maybe& DMDFile, + const RequestMemoryReportResolver& aResolver); + mozilla::ipc::IPCResult RecvSetOffline(const bool& aOffline); + mozilla::ipc::IPCResult RecvSetConnectivity(const bool& aConnectivity); + mozilla::ipc::IPCResult RecvInitLinuxSandbox( + const Maybe& aBrokerFd); + mozilla::ipc::IPCResult RecvInitSocketProcessBridgeParent( + const ProcessId& aContentProcessId, + Endpoint&& aEndpoint); + mozilla::ipc::IPCResult RecvInitProfiler( + Endpoint&& aEndpoint); +#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS) + mozilla::ipc::IPCResult RecvInitSandboxTesting( + Endpoint&& aEndpoint); +#endif + mozilla::ipc::IPCResult RecvSocketProcessTelemetryPing(); + + PWebrtcTCPSocketChild* AllocPWebrtcTCPSocketChild(const Maybe& tabId); + bool DeallocPWebrtcTCPSocketChild(PWebrtcTCPSocketChild* aActor); + + already_AddRefed AllocPHttpTransactionChild(); + + void CleanUp(); + void DestroySocketProcessBridgeParent(ProcessId aId); + + already_AddRefed AllocPHttpConnectionMgrChild( + const HttpHandlerInitArgs& aArgs); + mozilla::ipc::IPCResult RecvUpdateDeviceModelId(const nsACString& aModelId); + mozilla::ipc::IPCResult RecvOnHttpActivityDistributorActivated( + const bool& aIsActivated); + mozilla::ipc::IPCResult RecvOnHttpActivityDistributorObserveProxyResponse( + const bool& aIsEnabled); + mozilla::ipc::IPCResult RecvOnHttpActivityDistributorObserveConnection( + const bool& aIsEnabled); + + already_AddRefed + AllocPInputChannelThrottleQueueChild(const uint32_t& aMeanBytesPerSecond, + const uint32_t& aMaxBytesPerSecond); + + already_AddRefed AllocPAltSvcTransactionChild( + const HttpConnectionInfoCloneArgs& aConnInfo, const uint32_t& aCaps); + + bool IsShuttingDown() { return mShuttingDown; } + + already_AddRefed AllocPDNSRequestChild( + const nsACString& aHost, const nsACString& aTrrServer, + const int32_t& aPort, const uint16_t& aType, + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags); + mozilla::ipc::IPCResult RecvPDNSRequestConstructor( + PDNSRequestChild* aActor, const nsACString& aHost, + const nsACString& aTrrServer, const int32_t& aPort, const uint16_t& aType, + const OriginAttributes& aOriginAttributes, + const nsIDNSService::DNSFlags& aFlags) override; + + void AddDataBridgeToMap(uint64_t aChannelId, + BackgroundDataBridgeParent* aActor); + void RemoveDataBridgeFromMap(uint64_t aChannelId); + Maybe> GetAndRemoveDataBridge( + uint64_t aChannelId); + + mozilla::ipc::IPCResult RecvClearSessionCache( + ClearSessionCacheResolver&& aResolve); + + already_AddRefed AllocPTRRServiceChild( + const bool& aCaptiveIsPassed, const bool& aParentalControlEnabled, + const nsTArray& aDNSSuffixList); + mozilla::ipc::IPCResult RecvPTRRServiceConstructor( + PTRRServiceChild* aActor, const bool& aCaptiveIsPassed, + const bool& aParentalControlEnabled, + nsTArray&& aDNSSuffixList) override; + + already_AddRefed + AllocPNativeDNSResolverOverrideChild(); + mozilla::ipc::IPCResult RecvPNativeDNSResolverOverrideConstructor( + PNativeDNSResolverOverrideChild* aActor) override; + + mozilla::ipc::IPCResult RecvNotifyObserver(const nsACString& aTopic, + const nsAString& aData); + + mozilla::ipc::IPCResult RecvGetSocketData(GetSocketDataResolver&& aResolve); + mozilla::ipc::IPCResult RecvGetDNSCacheEntries( + GetDNSCacheEntriesResolver&& aResolve); + mozilla::ipc::IPCResult RecvGetHttpConnectionData( + GetHttpConnectionDataResolver&& aResolve); + + mozilla::ipc::IPCResult RecvInitProxyAutoConfigChild( + Endpoint&& aEndpoint); + + mozilla::ipc::IPCResult RecvRecheckIPConnectivity(); + mozilla::ipc::IPCResult RecvRecheckDNS(); + + mozilla::ipc::IPCResult RecvFlushFOGData(FlushFOGDataResolver&& aResolver); + + mozilla::ipc::IPCResult RecvTestTriggerMetrics( + TestTriggerMetricsResolver&& aResolve); + +#if defined(XP_WIN) + mozilla::ipc::IPCResult RecvGetUntrustedModulesData( + GetUntrustedModulesDataResolver&& aResolver); + mozilla::ipc::IPCResult RecvUnblockUntrustedModulesThread(); +#endif // defined(XP_WIN) + + protected: + friend class SocketProcessImpl; + ~SocketProcessChild(); + + private: + // Mapping of content process id and the SocketProcessBridgeParent. + // This table keeps SocketProcessBridgeParent alive in socket process. + nsRefPtrHashtable + mSocketProcessBridgeParentMap; + + RefPtr mProfilerController; + + bool mShuttingDown{false}; + // Protect the table below. + Mutex mMutex MOZ_UNANNOTATED{"SocketProcessChild::mMutex"}; + nsTHashMap> + mBackgroundDataBridgeMap; +}; + +} // namespace net +} // namespace mozilla + +#endif // mozilla_net_SocketProcessChild_h -- cgit v1.2.3