Bug 1758155 - PBackground clenup, r=nika

Differential Revision: https://phabricator.services.mozilla.com/D185032
This commit is contained in:
Kershaw Chang 2023-08-16 13:13:31 +00:00
parent 37b27a28d1
commit e247e6006d
9 changed files with 82 additions and 171 deletions

View File

@ -21,13 +21,6 @@ class ContentProcess;
} // namespace dom
namespace net {
class SocketProcessChild;
class SocketProcessBridgeChild;
} // namespace net
namespace ipc {
class PBackgroundChild;
@ -52,13 +45,12 @@ class PBackgroundStarterChild;
// The PBackgroundChild actor and all its sub-protocol actors will be
// automatically destroyed when its designated thread completes.
//
// Init{Content,Socket}Starter must be called on the main thread
// InitContentStarter must be called on the main thread
// with an actor bridging to the relevant target process type before these
// methods can be used.
class BackgroundChild final {
friend class mozilla::dom::ContentParent;
friend class mozilla::dom::ContentProcess;
friend class mozilla::net::SocketProcessChild;
public:
// See above.
@ -67,18 +59,12 @@ class BackgroundChild final {
// See above.
static PBackgroundChild* GetOrCreateForCurrentThread();
// See above.
static PBackgroundChild* GetOrCreateForSocketParentBridgeForCurrentThread();
// See above.
static void CloseForCurrentThread();
// See above.
static void InitContentStarter(mozilla::dom::ContentChild* aContent);
// See above.
static void InitSocketStarter(mozilla::net::SocketProcessChild* aSocket);
private:
// Only called by this class's friends.
static void Startup();

View File

@ -34,8 +34,6 @@
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/PBackgroundStarter.h"
#include "mozilla/ipc/ProtocolTypes.h"
#include "mozilla/net/SocketProcessChild.h"
#include "mozilla/net/SocketProcessBridgeChild.h"
#include "nsCOMPtr.h"
#include "nsIEventTarget.h"
#include "nsIObserver.h"
@ -81,10 +79,6 @@ class ChildImpl;
// Utility Functions
// -----------------------------------------------------------------------------
void AssertIsInMainOrSocketProcess() {
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsSocketProcess());
}
void AssertIsOnMainThread() { THREADSAFETY_ASSERT(NS_IsMainThread()); }
// -----------------------------------------------------------------------------
@ -106,7 +100,7 @@ class ParentImpl final : public BackgroundParentImpl {
TimerCallbackClosure(nsIThread* aThread,
nsTArray<IToplevelProtocol*>* aLiveActors)
: mThread(aThread), mLiveActors(aLiveActors) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT(aThread);
MOZ_ASSERT(aLiveActors);
@ -146,7 +140,7 @@ class ParentImpl final : public BackgroundParentImpl {
// create the background thread after application shutdown has started.
static bool sShutdownHasStarted;
// null if this is a same-process or socket process actor.
// null if this is a same-process actor.
const RefPtr<ThreadsafeContentParentHandle> mContent;
// Set when the actor is opened successfully and used to handle shutdown
@ -201,31 +195,29 @@ class ParentImpl final : public BackgroundParentImpl {
static void ShutdownTimerCallback(nsITimer* aTimer, void* aClosure);
// NOTE: ParentImpl could be used in 4 cases below.
// NOTE: ParentImpl could be used in 2 cases below.
// 1. Within the parent process.
// 2. Between parent process and content process.
// 3. Between socket process and content process.
// 4. Between parent process and socket process.
// |aContent| should be not null for case 2. For cases 1, 3 and 4, it's null.
// |aContent| should be not null for case 2. For cases 1, it's null.
explicit ParentImpl(ThreadsafeContentParentHandle* aContent,
bool aIsOtherProcessActor)
: mContent(aContent),
mLiveActorArray(nullptr),
mIsOtherProcessActor(aIsOtherProcessActor),
mActorDestroyed(false) {
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsSocketProcess());
AssertIsInMainProcess();
MOZ_ASSERT_IF(!aIsOtherProcessActor, XRE_IsParentProcess());
}
~ParentImpl() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
}
void MainThreadActorDestroy();
void SetLiveActorArray(nsTArray<IToplevelProtocol*>* aLiveActorArray) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aLiveActorArray);
MOZ_ASSERT(!aLiveActorArray->Contains(this));
@ -509,9 +501,6 @@ class ChildImpl final : public BackgroundChildImpl {
// For PBackground between parent and content process.
static ThreadInfoWrapper sParentAndContentProcessThreadInfo;
// For PBackground between socket and parent process.
static ThreadInfoWrapper sSocketAndParentProcessThreadInfo;
// This is only modified on the main thread. It prevents us from trying to
// create the background thread after application shutdown has started.
static bool sShutdownHasStarted;
@ -580,12 +569,6 @@ class ChildImpl final : public BackgroundChildImpl {
// Forwarded from BackgroundChild.
static PBackgroundChild* GetOrCreateForCurrentThread();
// Forwarded from BackgroundChild.
static PBackgroundChild* GetOrCreateSocketActorForCurrentThread();
// Forwarded from BackgroundChild.
static PBackgroundChild* GetOrCreateForSocketParentBridgeForCurrentThread();
static void CloseForCurrentThread();
// Forwarded from BackgroundChildImpl.
@ -594,13 +577,6 @@ class ChildImpl final : public BackgroundChildImpl {
// Forwarded from BackgroundChild.
static void InitContentStarter(mozilla::dom::ContentChild* aContent);
// Forwarded from BackgroundChild.
static void InitSocketStarter(mozilla::net::SocketProcessChild* aSocket);
// Forwarded from BackgroundChild.
static void InitSocketBridgeStarter(
mozilla::net::SocketProcessBridgeChild* aSocketBridge);
static void ThreadLocalDestructor(void* aThreadLocal);
// This class is reference counted.
@ -700,12 +676,6 @@ PBackgroundChild* BackgroundChild::GetOrCreateForCurrentThread() {
return ChildImpl::GetOrCreateForCurrentThread();
}
// static
PBackgroundChild*
BackgroundChild::GetOrCreateForSocketParentBridgeForCurrentThread() {
return ChildImpl::GetOrCreateForSocketParentBridgeForCurrentThread();
}
// static
void BackgroundChild::CloseForCurrentThread() {
ChildImpl::CloseForCurrentThread();
@ -716,11 +686,6 @@ void BackgroundChild::InitContentStarter(ContentChild* aContent) {
ChildImpl::InitContentStarter(aContent);
}
// static
void BackgroundChild::InitSocketStarter(net::SocketProcessChild* aSocket) {
ChildImpl::InitSocketStarter(aSocket);
}
// -----------------------------------------------------------------------------
// BackgroundChildImpl Public Methods
// -----------------------------------------------------------------------------
@ -755,8 +720,6 @@ bool ParentImpl::sShutdownHasStarted = false;
ChildImpl::ThreadInfoWrapper ChildImpl::sParentAndContentProcessThreadInfo;
ChildImpl::ThreadInfoWrapper ChildImpl::sSocketAndParentProcessThreadInfo;
bool ChildImpl::sShutdownHasStarted = false;
// -----------------------------------------------------------------------------
@ -797,7 +760,7 @@ uint64_t ParentImpl::GetChildID(PBackgroundParent* aBackgroundActor) {
bool ParentImpl::AllocStarter(ContentParent* aContent,
Endpoint<PBackgroundStarterParent>&& aEndpoint,
bool aCrossProcess) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT(aEndpoint.IsValid());
@ -831,7 +794,7 @@ bool ParentImpl::AllocStarter(ContentParent* aContent,
// static
bool ParentImpl::CreateBackgroundThread() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT(!sBackgroundThread);
MOZ_ASSERT(!sLiveActorsForBackgroundThread);
@ -898,7 +861,7 @@ bool ParentImpl::CreateBackgroundThread() {
// static
void ParentImpl::ShutdownBackgroundThread() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT(sShutdownHasStarted);
MOZ_ASSERT_IF(!sBackgroundThread, !sLiveActorCount);
@ -950,7 +913,7 @@ void ParentImpl::ShutdownBackgroundThread() {
// static
void ParentImpl::ShutdownTimerCallback(nsITimer* aTimer, void* aClosure) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT(sShutdownHasStarted);
MOZ_ASSERT(sLiveActorCount);
@ -986,7 +949,7 @@ void ParentImpl::ShutdownTimerCallback(nsITimer* aTimer, void* aClosure) {
void ParentImpl::Destroy() {
// May be called on any thread!
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(
NewNonOwningRunnableMethod("ParentImpl::MainThreadActorDestroy", this,
@ -994,7 +957,7 @@ void ParentImpl::Destroy() {
}
void ParentImpl::MainThreadActorDestroy() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT_IF(!mIsOtherProcessActor, !mContent);
@ -1006,7 +969,7 @@ void ParentImpl::MainThreadActorDestroy() {
}
void ParentImpl::ActorDestroy(ActorDestroyReason aWhy) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(!mActorDestroyed);
MOZ_ASSERT_IF(mIsOtherProcessActor, mLiveActorArray);
@ -1037,7 +1000,7 @@ NS_IMPL_ISUPPORTS(ParentImpl::ShutdownObserver, nsIObserver)
NS_IMETHODIMP
ParentImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_ASSERT(!sShutdownHasStarted);
MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID));
@ -1057,14 +1020,14 @@ BackgroundStarterParent::BackgroundStarterParent(
ThreadsafeContentParentHandle* aContent, bool aCrossProcess)
: mCrossProcess(aCrossProcess), mContent(aContent) {
AssertIsOnMainThread();
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
MOZ_ASSERT_IF(!mCrossProcess, !mContent);
MOZ_ASSERT_IF(!mCrossProcess, XRE_IsParentProcess());
}
void BackgroundStarterParent::SetLiveActorArray(
nsTArray<IToplevelProtocol*>* aLiveActorArray) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aLiveActorArray);
MOZ_ASSERT(!aLiveActorArray->Contains(this));
@ -1127,7 +1090,6 @@ void ChildImpl::Startup() {
// assert that we're being called on the main thread here.
sParentAndContentProcessThreadInfo.Startup();
sSocketAndParentProcessThreadInfo.Startup();
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
MOZ_RELEASE_ASSERT(observerService);
@ -1157,7 +1119,6 @@ void ChildImpl::Shutdown() {
AssertIsOnMainThread();
sParentAndContentProcessThreadInfo.Shutdown();
sSocketAndParentProcessThreadInfo.Shutdown();
sShutdownHasStarted = true;
}
@ -1185,12 +1146,6 @@ PBackgroundChild* ChildImpl::GetOrCreateForCurrentThread() {
return sParentAndContentProcessThreadInfo.GetOrCreateForCurrentThread();
}
/* static */
PBackgroundChild*
ChildImpl::GetOrCreateForSocketParentBridgeForCurrentThread() {
return sSocketAndParentProcessThreadInfo.GetOrCreateForCurrentThread();
}
// static
void ChildImpl::CloseForCurrentThread() {
MOZ_ASSERT(!NS_IsMainThread(),
@ -1198,7 +1153,6 @@ void ChildImpl::CloseForCurrentThread() {
"ChildImpl::Shutdown().");
sParentAndContentProcessThreadInfo.CloseForCurrentThread();
sSocketAndParentProcessThreadInfo.CloseForCurrentThread();
}
// static
@ -1230,11 +1184,6 @@ void ChildImpl::InitContentStarter(mozilla::dom::ContentChild* aContent) {
sParentAndContentProcessThreadInfo.InitStarter(aContent);
}
// static
void ChildImpl::InitSocketStarter(mozilla::net::SocketProcessChild* aSocket) {
sSocketAndParentProcessThreadInfo.InitStarter(aSocket);
}
// static
void ChildImpl::ThreadLocalDestructor(void* aThreadLocal) {
auto threadLocalInfo = static_cast<ThreadLocalInfo*>(aThreadLocal);

View File

@ -103,10 +103,6 @@ inline void AssertIsOnBackgroundThread() {}
inline void AssertIsInMainProcess() { MOZ_ASSERT(XRE_IsParentProcess()); }
inline void AssertIsInMainOrSocketProcess() {
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsSocketProcess());
}
} // namespace ipc
} // namespace mozilla

View File

@ -114,26 +114,26 @@ using mozilla::dom::ContentParent;
using mozilla::dom::ThreadsafeContentParentHandle;
BackgroundParentImpl::BackgroundParentImpl() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl);
}
BackgroundParentImpl::~BackgroundParentImpl() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnMainThread();
MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl);
}
void BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
}
BackgroundParentImpl::PBackgroundTestParent*
BackgroundParentImpl::AllocPBackgroundTestParent(const nsACString& aTestArg) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return new TestParent();
@ -141,7 +141,7 @@ BackgroundParentImpl::AllocPBackgroundTestParent(const nsACString& aTestArg) {
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundTestConstructor(
PBackgroundTestParent* aActor, const nsACString& aTestArg) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -153,7 +153,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundTestConstructor(
bool BackgroundParentImpl::DeallocPBackgroundTestParent(
PBackgroundTestParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -166,7 +166,7 @@ auto BackgroundParentImpl::AllocPBackgroundIDBFactoryParent(
-> already_AddRefed<PBackgroundIDBFactoryParent> {
using mozilla::dom::indexedDB::AllocPBackgroundIDBFactoryParent;
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return AllocPBackgroundIDBFactoryParent(aLoggingInfo);
@ -177,7 +177,7 @@ BackgroundParentImpl::RecvPBackgroundIDBFactoryConstructor(
PBackgroundIDBFactoryParent* aActor, const LoggingInfo& aLoggingInfo) {
using mozilla::dom::indexedDB::RecvPBackgroundIDBFactoryConstructor;
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -189,7 +189,7 @@ BackgroundParentImpl::RecvPBackgroundIDBFactoryConstructor(
auto BackgroundParentImpl::AllocPBackgroundIndexedDBUtilsParent()
-> PBackgroundIndexedDBUtilsParent* {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::indexedDB::AllocPBackgroundIndexedDBUtilsParent();
@ -197,7 +197,7 @@ auto BackgroundParentImpl::AllocPBackgroundIndexedDBUtilsParent()
bool BackgroundParentImpl::DeallocPBackgroundIndexedDBUtilsParent(
PBackgroundIndexedDBUtilsParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -206,7 +206,7 @@ bool BackgroundParentImpl::DeallocPBackgroundIndexedDBUtilsParent(
}
mozilla::ipc::IPCResult BackgroundParentImpl::RecvFlushPendingFileDeletions() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (!mozilla::dom::indexedDB::RecvFlushPendingFileDeletions()) {
@ -219,7 +219,7 @@ BackgroundParentImpl::PBackgroundSDBConnectionParent*
BackgroundParentImpl::AllocPBackgroundSDBConnectionParent(
const PersistenceType& aPersistenceType,
const PrincipalInfo& aPrincipalInfo) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundSDBConnectionParent(aPersistenceType,
@ -231,7 +231,7 @@ BackgroundParentImpl::RecvPBackgroundSDBConnectionConstructor(
PBackgroundSDBConnectionParent* aActor,
const PersistenceType& aPersistenceType,
const PrincipalInfo& aPrincipalInfo) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -244,7 +244,7 @@ BackgroundParentImpl::RecvPBackgroundSDBConnectionConstructor(
bool BackgroundParentImpl::DeallocPBackgroundSDBConnectionParent(
PBackgroundSDBConnectionParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -255,7 +255,7 @@ BackgroundParentImpl::PBackgroundLSDatabaseParent*
BackgroundParentImpl::AllocPBackgroundLSDatabaseParent(
const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
const uint64_t& aDatastoreId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundLSDatabaseParent(
@ -266,7 +266,7 @@ mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPBackgroundLSDatabaseConstructor(
PBackgroundLSDatabaseParent* aActor, const PrincipalInfo& aPrincipalInfo,
const uint32_t& aPrivateBrowsingId, const uint64_t& aDatastoreId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -279,7 +279,7 @@ BackgroundParentImpl::RecvPBackgroundLSDatabaseConstructor(
bool BackgroundParentImpl::DeallocPBackgroundLSDatabaseParent(
PBackgroundLSDatabaseParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -289,7 +289,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLSDatabaseParent(
BackgroundParentImpl::PBackgroundLSObserverParent*
BackgroundParentImpl::AllocPBackgroundLSObserverParent(
const uint64_t& aObserverId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundLSObserverParent(aObserverId);
@ -298,7 +298,7 @@ BackgroundParentImpl::AllocPBackgroundLSObserverParent(
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPBackgroundLSObserverConstructor(
PBackgroundLSObserverParent* aActor, const uint64_t& aObserverId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -311,7 +311,7 @@ BackgroundParentImpl::RecvPBackgroundLSObserverConstructor(
bool BackgroundParentImpl::DeallocPBackgroundLSObserverParent(
PBackgroundLSObserverParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -321,7 +321,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLSObserverParent(
BackgroundParentImpl::PBackgroundLSRequestParent*
BackgroundParentImpl::AllocPBackgroundLSRequestParent(
const LSRequestParams& aParams) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundLSRequestParent(this, aParams);
@ -330,7 +330,7 @@ BackgroundParentImpl::AllocPBackgroundLSRequestParent(
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPBackgroundLSRequestConstructor(
PBackgroundLSRequestParent* aActor, const LSRequestParams& aParams) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -342,7 +342,7 @@ BackgroundParentImpl::RecvPBackgroundLSRequestConstructor(
bool BackgroundParentImpl::DeallocPBackgroundLSRequestParent(
PBackgroundLSRequestParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -352,7 +352,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLSRequestParent(
BackgroundParentImpl::PBackgroundLSSimpleRequestParent*
BackgroundParentImpl::AllocPBackgroundLSSimpleRequestParent(
const LSSimpleRequestParams& aParams) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundLSSimpleRequestParent(this, aParams);
@ -362,7 +362,7 @@ mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPBackgroundLSSimpleRequestConstructor(
PBackgroundLSSimpleRequestParent* aActor,
const LSSimpleRequestParams& aParams) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -375,7 +375,7 @@ BackgroundParentImpl::RecvPBackgroundLSSimpleRequestConstructor(
bool BackgroundParentImpl::DeallocPBackgroundLSSimpleRequestParent(
PBackgroundLSSimpleRequestParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -386,7 +386,7 @@ BackgroundParentImpl::PBackgroundLocalStorageCacheParent*
BackgroundParentImpl::AllocPBackgroundLocalStorageCacheParent(
const PrincipalInfo& aPrincipalInfo, const nsACString& aOriginKey,
const uint32_t& aPrivateBrowsingId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundLocalStorageCacheParent(
@ -398,7 +398,7 @@ BackgroundParentImpl::RecvPBackgroundLocalStorageCacheConstructor(
PBackgroundLocalStorageCacheParent* aActor,
const PrincipalInfo& aPrincipalInfo, const nsACString& aOriginKey,
const uint32_t& aPrivateBrowsingId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -408,7 +408,7 @@ BackgroundParentImpl::RecvPBackgroundLocalStorageCacheConstructor(
bool BackgroundParentImpl::DeallocPBackgroundLocalStorageCacheParent(
PBackgroundLocalStorageCacheParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -418,7 +418,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLocalStorageCacheParent(
auto BackgroundParentImpl::AllocPBackgroundStorageParent(
const nsAString& aProfilePath, const uint32_t& aPrivateBrowsingId)
-> PBackgroundStorageParent* {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::AllocPBackgroundStorageParent(aProfilePath,
@ -428,7 +428,7 @@ auto BackgroundParentImpl::AllocPBackgroundStorageParent(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundStorageConstructor(
PBackgroundStorageParent* aActor, const nsAString& aProfilePath,
const uint32_t& aPrivateBrowsingId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -438,7 +438,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundStorageConstructor(
bool BackgroundParentImpl::DeallocPBackgroundStorageParent(
PBackgroundStorageParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -448,7 +448,7 @@ bool BackgroundParentImpl::DeallocPBackgroundStorageParent(
already_AddRefed<BackgroundParentImpl::PBackgroundSessionStorageManagerParent>
BackgroundParentImpl::AllocPBackgroundSessionStorageManagerParent(
const uint64_t& aTopContextId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return dom::AllocPBackgroundSessionStorageManagerParent(aTopContextId);
@ -456,7 +456,7 @@ BackgroundParentImpl::AllocPBackgroundSessionStorageManagerParent(
already_AddRefed<mozilla::dom::PBackgroundSessionStorageServiceParent>
BackgroundParentImpl::AllocPBackgroundSessionStorageServiceParent() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return MakeAndAddRef<mozilla::dom::BackgroundSessionStorageServiceParent>();
@ -635,7 +635,7 @@ bool BackgroundParentImpl::DeallocPTemporaryIPCBlobParent(
already_AddRefed<BackgroundParentImpl::PVsyncParent>
BackgroundParentImpl::AllocPVsyncParent() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
RefPtr<mozilla::dom::VsyncParent> actor = new mozilla::dom::VsyncParent();
@ -647,7 +647,7 @@ BackgroundParentImpl::AllocPVsyncParent() {
}
camera::PCamerasParent* BackgroundParentImpl::AllocPCamerasParent() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
#ifdef MOZ_WEBRTC
@ -662,7 +662,7 @@ camera::PCamerasParent* BackgroundParentImpl::AllocPCamerasParent() {
#ifdef MOZ_WEBRTC
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPCamerasConstructor(
camera::PCamerasParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
return static_cast<camera::CamerasParent*>(aActor)->RecvPCamerasConstructor();
@ -671,7 +671,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPCamerasConstructor(
bool BackgroundParentImpl::DeallocPCamerasParent(
camera::PCamerasParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -693,7 +693,7 @@ auto BackgroundParentImpl::AllocPUDPSocketParent(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPUDPSocketConstructor(
PUDPSocketParent* aActor, const Maybe<PrincipalInfo>& aOptionalPrincipal,
const nsACString& aFilter) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (aOptionalPrincipal.isSome()) {
@ -730,7 +730,7 @@ mozilla::dom::PBroadcastChannelParent*
BackgroundParentImpl::AllocPBroadcastChannelParent(
const PrincipalInfo& aPrincipalInfo, const nsACString& aOrigin,
const nsAString& aChannel) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
nsString originChannelKey;
@ -758,7 +758,7 @@ class CheckPrincipalRunnable final : public Runnable {
mContentParent(aParent),
mPrincipalInfo(aPrincipalInfo),
mOrigin(aOrigin) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(mContentParent);
@ -805,7 +805,7 @@ class CheckPrincipalRunnable final : public Runnable {
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBroadcastChannelConstructor(
PBroadcastChannelParent* actor, const PrincipalInfo& aPrincipalInfo,
const nsACString& aOrigin, const nsAString& aChannel) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
RefPtr<ThreadsafeContentParentHandle> parent =
@ -825,7 +825,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBroadcastChannelConstructor(
bool BackgroundParentImpl::DeallocPBroadcastChannelParent(
PBroadcastChannelParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -835,7 +835,7 @@ bool BackgroundParentImpl::DeallocPBroadcastChannelParent(
mozilla::dom::PServiceWorkerManagerParent*
BackgroundParentImpl::AllocPServiceWorkerManagerParent() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
RefPtr<dom::ServiceWorkerManagerParent> agent =
@ -845,7 +845,7 @@ BackgroundParentImpl::AllocPServiceWorkerManagerParent() {
bool BackgroundParentImpl::DeallocPServiceWorkerManagerParent(
PServiceWorkerManagerParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -857,7 +857,7 @@ bool BackgroundParentImpl::DeallocPServiceWorkerManagerParent(
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvShutdownServiceWorkerRegistrar() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (BackgroundParent::IsOtherProcessActor(this)) {
@ -881,7 +881,7 @@ BackgroundParentImpl::AllocPCacheStorageParent(
PMessagePortParent* BackgroundParentImpl::AllocPMessagePortParent(
const nsID& aUUID, const nsID& aDestinationUUID,
const uint32_t& aSequenceID) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return new MessagePortParent(aUUID);
@ -890,7 +890,7 @@ PMessagePortParent* BackgroundParentImpl::AllocPMessagePortParent(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPMessagePortConstructor(
PMessagePortParent* aActor, const nsID& aUUID, const nsID& aDestinationUUID,
const uint32_t& aSequenceID) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MessagePortParent* mp = static_cast<MessagePortParent*>(aActor);
@ -902,7 +902,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPMessagePortConstructor(
bool BackgroundParentImpl::DeallocPMessagePortParent(
PMessagePortParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -913,7 +913,7 @@ bool BackgroundParentImpl::DeallocPMessagePortParent(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvMessagePortForceClose(
const nsID& aUUID, const nsID& aDestinationUUID,
const uint32_t& aSequenceID) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (!MessagePortParent::ForceClose(aUUID, aDestinationUUID, aSequenceID)) {
@ -924,14 +924,14 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvMessagePortForceClose(
}
BackgroundParentImpl::PQuotaParent* BackgroundParentImpl::AllocPQuotaParent() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return mozilla::dom::quota::AllocPQuotaParent();
}
bool BackgroundParentImpl::DeallocPQuotaParent(PQuotaParent* aActor) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
@ -939,7 +939,7 @@ bool BackgroundParentImpl::DeallocPQuotaParent(PQuotaParent* aActor) {
}
mozilla::ipc::IPCResult BackgroundParentImpl::RecvShutdownQuotaManager() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (BackgroundParent::IsOtherProcessActor(this)) {
@ -954,7 +954,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvShutdownQuotaManager() {
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvShutdownBackgroundSessionStorageManagers() {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (BackgroundParent::IsOtherProcessActor(this)) {
@ -970,7 +970,7 @@ BackgroundParentImpl::RecvShutdownBackgroundSessionStorageManagers() {
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPropagateBackgroundSessionStorageManager(
const uint64_t& aCurrentTopContextId, const uint64_t& aTargetTopContextId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (BackgroundParent::IsOtherProcessActor(this)) {
@ -986,7 +986,7 @@ BackgroundParentImpl::RecvPropagateBackgroundSessionStorageManager(
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvRemoveBackgroundSessionStorageManager(
const uint64_t& aTopContextId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (BackgroundParent::IsOtherProcessActor(this)) {
@ -1040,7 +1040,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvLoadSessionStorageManagerData(
already_AddRefed<dom::PFileSystemRequestParent>
BackgroundParentImpl::AllocPFileSystemRequestParent(
const FileSystemParams& aParams) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
RefPtr<FileSystemRequestParent> result = new FileSystemRequestParent();
@ -1084,7 +1084,7 @@ bool BackgroundParentImpl::DeallocPWebAuthnTransactionParent(
already_AddRefed<net::PHttpBackgroundChannelParent>
BackgroundParentImpl::AllocPHttpBackgroundChannelParent(
const uint64_t& aChannelId) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
RefPtr<net::HttpBackgroundChannelParent> actor =
@ -1096,7 +1096,7 @@ mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPHttpBackgroundChannelConstructor(
net::PHttpBackgroundChannelParent* aActor, const uint64_t& aChannelId) {
MOZ_ASSERT(aActor);
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
net::HttpBackgroundChannelParent* aParent =
@ -1112,7 +1112,7 @@ BackgroundParentImpl::RecvPHttpBackgroundChannelConstructor(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateMIDIPort(
Endpoint<PMIDIPortParent>&& aEndpoint, const MIDIPortInfo& aPortInfo,
const bool& aSysexEnabled) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (!aEndpoint.IsValid()) {
@ -1131,7 +1131,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateMIDIPort(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateMIDIManager(
Endpoint<PMIDIManagerParent>&& aEndpoint) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
if (!aEndpoint.IsValid()) {
@ -1151,7 +1151,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateMIDIManager(
mozilla::ipc::IPCResult BackgroundParentImpl::RecvHasMIDIDevice(
HasMIDIDeviceResolver&& aResolver) {
AssertIsInMainOrSocketProcess();
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
InvokeAsync(MIDIPlatformService::OwnerThread(), __func__,
@ -1380,6 +1380,6 @@ already_AddRefed<dom::PFetchParent> BackgroundParentImpl::AllocPFetchParent() {
} // namespace mozilla::ipc
void TestParent::ActorDestroy(ActorDestroyReason aWhy) {
mozilla::ipc::AssertIsInMainOrSocketProcess();
mozilla::ipc::AssertIsInMainProcess();
AssertIsOnBackgroundThread();
}

View File

@ -10,7 +10,6 @@ include protocol PWebrtcTCPSocket;
include protocol PHttpTransaction;
include protocol PHttpConnectionMgr;
include protocol PInputChannelThrottleQueue;
include protocol PBackgroundStarter;
include protocol PAltService;
include protocol PAltSvcTransaction;
include protocol PTRRService;
@ -121,7 +120,6 @@ parent:
PRTime aTimestamp,
uint64_t aExtraSizeData,
nsCString aExtraStringData);
async InitBackground(Endpoint<PBackgroundStarterParent> aEndpoint);
async InitSocketBackground(Endpoint<PSocketProcessBackgroundParent> aEndpoint);
async PAltService();
async PProxyConfigLookup(nullable nsIURI aUri, uint32_t aFlags);

View File

@ -18,7 +18,6 @@
#include "mozilla/FOGIPC.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/net/AltSvcTransactionChild.h"
#include "mozilla/net/BackgroundDataBridgeParent.h"
@ -170,9 +169,6 @@ bool SocketProcessChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
return false;
}
BackgroundChild::Startup();
BackgroundChild::InitSocketStarter(this);
InitSocketBackground();
SetThisProcessName("Socket Process");

View File

@ -248,16 +248,6 @@ mozilla::ipc::IPCResult SocketProcessParent::RecvObserveHttpActivity(
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessParent::RecvInitBackground(
Endpoint<PBackgroundStarterParent>&& aEndpoint) {
LOG(("SocketProcessParent::RecvInitBackground\n"));
if (!ipc::BackgroundParent::AllocStarter(nullptr, std::move(aEndpoint))) {
return IPC_FAIL(this, "BackgroundParent::Alloc failed");
}
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessParent::RecvInitSocketBackground(
Endpoint<PSocketProcessBackgroundParent>&& aEndpoint) {
if (!aEndpoint.IsValid()) {

View File

@ -7,7 +7,6 @@
#define mozilla_net_SocketProcessParent_h
#include "mozilla/UniquePtr.h"
#include "mozilla/ipc/BackgroundParent.h"
#include "mozilla/ipc/CrashReporterHelper.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/net/PSocketProcessParent.h"
@ -76,9 +75,6 @@ class SocketProcessParent final
const uint32_t& aActivitySubtype, const PRTime& aTimestamp,
const uint64_t& aExtraSizeData, const nsACString& aExtraStringData);
mozilla::ipc::IPCResult RecvInitBackground(
Endpoint<PBackgroundStarterParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitSocketBackground(
Endpoint<PSocketProcessBackgroundParent>&& aEndpoint);

View File

@ -8,7 +8,7 @@
#include "WebSocketConnectionChild.h"
#include "WebSocketConnection.h"
#include "mozilla/net/SocketProcessbackgroundChild.h"
#include "mozilla/net/SocketProcessBackgroundChild.h"
#include "nsISerializable.h"
#include "nsITLSSocketControl.h"
#include "nsITransportSecurityInfo.h"